From patchwork Sat Aug 26 15:47:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13366518 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 549CAC83F11 for ; Sat, 26 Aug 2023 07:48:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A13EE2800DF; Sat, 26 Aug 2023 03:48:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94F562800E8; Sat, 26 Aug 2023 03:48:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 662222800DF; Sat, 26 Aug 2023 03:48:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 50AD82800E4 for ; Sat, 26 Aug 2023 03:48:06 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1FA3E16014D for ; Sat, 26 Aug 2023 07:48:06 +0000 (UTC) X-FDA: 81165477372.07.8D5AA03 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf24.hostedemail.com (Postfix) with ESMTP id 3B1CC18000F for ; Sat, 26 Aug 2023 07:48:02 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=none; spf=none (imf24.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693036084; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=29asQCuVu+7kKE8VL4Hf5FRk9nOld3+GYgBeua+XHZQ=; b=HRZTBPtTYi/D8MPKYOAlGEfOc9AgUw9UhD50wAs5MfAjE23M/87D8oQSLmXSD589h9eYzf JHAtchopsBbrRKT62VXj0L16Nt+s799csQFANDVi1U9zN5RsUYHBLgcA7oPapW4qUhImnJ 76LCsEAK1uKFHQ28cfKcoWvJzbcZe98= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=none; spf=none (imf24.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693036084; a=rsa-sha256; cv=none; b=YuP7HsiOo/wcbDWWMWJrMh2GNNbk9jPYOZwMZA+Seteak81XCVM20e9stAJBRR/1f7gvqY 55UqHjhF/j71XWnHAXzu0KwbsuDrP6l8F1kcfq80FweXFbDEa3eMR5p/sgNDfswmRa3UI2 t6+Vm8DDhyMBSSGrauAtC1OIszrST74= Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RXpp51mr3z4f3lVD for ; Sat, 26 Aug 2023 15:47:57 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgB3B6osrulk6+l0Bg--.52079S3; Sat, 26 Aug 2023 15:47:58 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, willy@infradead.org, naoya.horiguchi@nec.com, osalvador@suse.de Subject: [PATCH v2 1/3] mm/page_alloc: correct start page when guard page debug is enabled Date: Sat, 26 Aug 2023 23:47:43 +0800 Message-Id: <20230826154745.4019371-2-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230826154745.4019371-1-shikemeng@huaweicloud.com> References: <20230826154745.4019371-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgB3B6osrulk6+l0Bg--.52079S3 X-Coremail-Antispam: 1UD129KBjvJXoW7WFWrWF4DJrWUAryrZrWkJFb_yoW8Aw18pF yIkw1jkw4UJ3y5Ca1xAFZFkr1fJrZ09FWkCryxXw48XwnxJry2kw17trnruF18GF9rGFW5 JFs0yryrJF4UAFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBYb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUGwA2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l 84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x 0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU0IoGJUUUUU== X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 3B1CC18000F X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: stcyharaax6iaiydnypquhu7kfjpxhc5 X-HE-Tag: 1693036082-670408 X-HE-Meta: U2FsdGVkX1/OTBhe/R/q2Y1DfDloBq1DiHW8y5ikvFtQIX7j9NLQPqVSy+SqVjIIgm2hNiShSoKDGOOcztKfmIMHJAGrbA4V9cd4meaqjblGFEX2OO2z9SGfCsT+7/EmMihKJZGEvMhqaWt2t+/C3EkgMH7y77yUzs7MEDGaaWzYB1b1lckAeuxRZcdJ9/9DOsQZv0+pteCKzGkcaGTW3kxi9X5/d4Z2bsyZSIIHvxlZb/05wWzRXcrOPEOv7lsRKIU0RBEvMA5T3K/R+PpffkxzoJh0k4ux8B8GapdLMGnxrWIV80w4VY3gC3Cuw80vthIaJCf1Mg7lvMpvW5a7qxpREnu+3L4XXvd/rihi5HD2n4cx15TCb7rmgdklMcnCyPw808ltDfuuzt3YRxKiDvrFuDRBL8U7z9RYYXguRplPyuSUqmSrk+5iOPib8XpfEQbQvroNzHunDSp+gtHkwpxWTPAOBokOtoZ+9Cb7AQLxGyXnmoHh6yWvZ4J9HC18BfQpY/89kuAdFY5RkZbUAjYoFL+YeezMhQtHI+YsEIzsbgWRtz20bQrGL7WKfgnS/iIP2JrP8SMN9q4XIsD7v1hKM8DV2ugdmZmq2pmtgiHPVHuy6P4oXn5U9gLZCJPZT199rMkBMVx7uOykYY9R6LXxE19pXjHRb+2oGDmqJ+14QrgSm/GeijCBg4djgtDEDQa+S83b+8jKyXenXDAebZ/dtTqs5ogCNeeVILNstITs0wfBm/G4blabgjKiVGaupTsi6/LQsFOnjveX/ldc2hu+091Zf6B0zfuu40XiTh8eIMHEL2Lqq0VyPuPc8V2q5Xa6dg17dojTVmSKl/PtaJDiU9gXZtmvt8fgH4MrhqTVMXsJaFwn9pPfCIW3REAm7rgGzA7k/FSB/EG5kPEeZUWljKpmO086wWNtfq1Avja/k/lxa22qJfd2t+qM7PKyt6jcc4qQy5PuRWdofmQ NWMVfMTo iFU6J8GwZUDRMZUmt9Az8+jB/LtKYKkxudkO1AhYnBGWCnWrgf3buWzxpg6vitTViW8NqYFdwwkH104nligTibSOtk560YQFUD9qUOgn3bfBK7AxufEnOw/lTxxRzFT+SZCp2EfCbyJe3UIWLlOtxVgxi3OgcNIwNbm4ET1h4V5sbfhT0i4SbGt94WsdcC9hTPl/5gcaETU2VqVvHmXqPxNAKHrWPJ5+6WTPRkR+n4YdIBqrN8du3tWHUWBIbblK+rXbAnK76xdr1Dak= 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 --- 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 fefc4074d9d0..88c5f5aea9b0 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6505,6 +6505,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; @@ -6512,7 +6513,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; } } }