From patchwork Wed Sep 27 09:44:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13399798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32471E7F14B for ; Wed, 27 Sep 2023 01:44:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 38A086B0132; Tue, 26 Sep 2023 21:44:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 337386B013C; Tue, 26 Sep 2023 21:44:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C58D6B013E; Tue, 26 Sep 2023 21:44:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0878F6B0132 for ; Tue, 26 Sep 2023 21:44:49 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CC5AA80C5A for ; Wed, 27 Sep 2023 01:44:48 +0000 (UTC) X-FDA: 81280683456.19.BF76B11 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf13.hostedemail.com (Postfix) with ESMTP id A7CDF2000E for ; Wed, 27 Sep 2023 01:44:45 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=none (imf13.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695779086; a=rsa-sha256; cv=none; b=2KCfU8sJK4Pp2SDDcotTt1mgccVmIQHnLsg8B39aawslTEqvsTEzJBSJ70JerF5hvQEHi6 bZln6FWb0Mn1loi1Fff0DNujcMA4bSzW+U2w7UFyVvSkZ4APM5KEpO4omNZHZWf9zw+aAA w6OIevLbyUhkBmQwAFyKv+h7p8oALI8= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=none (imf13.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695779086; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=HxsZAEkbpQ0mK0O2i45b4f5PSk1kawwXd3Gu3oXmepo=; b=3tXPt2vDC0ASSOuS8ONacX8zRMHSVQS/prdPvJ5EmppSTAKjAwRTt+dRXLyfHOG02z2AzG aO8GNxOScgSBacAHleng1CNNByOSVIWduFRLHZgOI/8YZMDs1UowHnLGRp35UZ6trzl6h9 YRZ/8SjNx9FM/9YRYS/rRo5l2v/NXmk= Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RwKD715fPz4f3k5w for ; Wed, 27 Sep 2023 09:44:39 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP3 (Coremail) with SMTP id _Ch0CgCnB1cGiRNl7AWaBQ--.25675S2; Wed, 27 Sep 2023 09:44:40 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, naoya.horiguchi@nec.com, osalvador@suse.de, willy@infradead.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm/page_alloc: correct start page when guard page debug is enabled Date: Wed, 27 Sep 2023 17:44:01 +0800 Message-Id: <20230927094401.68205-1-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 MIME-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VZ0Tby8Ap8eAHIFDAl9K5mS+XBk0pR4HOCYg4IpzJbW35h8jXsmgfpcUXpFdeTLF4xLBCpo36BVb5YPsRItUwL2yOTnx/uWhxyL7jjLb0lfjR1f5jjfKjxp0GltYyw EVyO/mVS zDK7juSaXuzSuWRiiBbsvP7gmW7ar0OjRiTRoFqE49GB+jlfwu/NXFDNNaAZtygBoHElLHYkhw6Aqg+O10zfG5wIuud9Y+XLheCv8Wra81u0zOB+PnGKXNHzHv8k7gEUqhG8X8z4pRdp3O7GNA8ZNJ5qE3WoRe4SXz3sCNFku7d753uN9aAvh4GTjnzhdLBKeULtusBVp7Sx60GsR/8N1KPKQagvy9s+EsBD636g9jBjMYaO9s5YyO2S7geZOwaUd+snSA5PYMj/eBD3HMSBPKJ6JUs3HTB9gXXRj2li+r9QE0B1P5ouxoHe9mxSU8UhXskHFidtS3Dxj2wBZdWwarL7SjJaslc3f5qz5IPMeZghytrgfZOxzCj3zfLxzbyVL11UCdG8QWVwg8Mk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When guard page debug is enabled and set_page_guard returns success, we miss to forward page to point to start of next split range and we will do split unexpectedly in page range without target page. Move start page update before set_page_guard to fix this. As we split to wrong target page, then splited pages are not able to merge back to original order when target page is put back and splited pages except target page is not usable. To be specific: Consider target page is the third page in buddy page with order 2. | buddy-2 | Page | Target | Page | After break down to target page, we will only set first page to Guard because of bug. | Guard | Page | Target | Page | When we try put_page_back_buddy with target page, the buddy page of target if neither guard nor buddy, Then it's not able to construct original page with order 2 | Guard | Page | buddy-0 | Page | All pages except target page is not in free list and is not usable. Fixes: 06be6ff3d2ec ("mm,hwpoison: rework soft offline for free pages") Signed-off-by: Kemeng Shi Acked-by: Naoya Horiguchi Cc: stable@vger.kernel.org --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 191e552a4c83..e18e0e20eff8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6691,6 +6691,7 @@ static void break_down_buddy_pages(struct zone *zone, struct page *page, next_page = page; current_buddy = page + size; } + page = next_page; if (set_page_guard(zone, current_buddy, high, migratetype)) continue; @@ -6698,7 +6699,6 @@ static void break_down_buddy_pages(struct zone *zone, struct page *page, if (current_buddy != target) { add_to_free_list(current_buddy, zone, high, migratetype); set_buddy_order(current_buddy, high); - page = next_page; } } }