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; } } } From patchwork Sat Aug 26 15:47:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13366519 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 D48BFC83F01 for ; Sat, 26 Aug 2023 07:48:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 417D02800E8; Sat, 26 Aug 2023 03:48:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C63A2800E4; Sat, 26 Aug 2023 03:48:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 269C92800E8; Sat, 26 Aug 2023 03:48:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1053D2800E4 for ; Sat, 26 Aug 2023 03:48:07 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CADFE8013F for ; Sat, 26 Aug 2023 07:48:06 +0000 (UTC) X-FDA: 81165477372.06.4DAA04B Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf06.hostedemail.com (Postfix) with ESMTP id 38E18180006 for ; Sat, 26 Aug 2023 07:48:02 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=none; spf=none (imf06.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=ffFDmTA/1hpgDYhGzWoNjF7iO2kil+aXv7b+KABxJ3w=; b=3ysltPbZaJdyUd4gqIcZ8O3Nuyhx2/RMMglg2JwEQ2BKBLhBj7rnAj+9gtvUKr5X7LqbYF 1naYTAnt1g4hB+AG/cTD9pXOXQnyDTFFBJLLHWKy3+B0p1VF9xPIJLpvhKSFhasJFcdtp2 8nEAFgD30wpVCXzSoQBJyr/lOSfg2no= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=none; spf=none (imf06.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=iUSMzyKPn8aDzrB/WZ8mv+3pmQGU2ZPME70/5Td8r+gH+OOBAlcMiMIa+B9Jkod1GgNSrP rIroCqUvJRP+QsNmtVWguHyrIBat+0etWxO+hcTfGCZ8SzD418CJBRrnR3NBrVwphlH5gL ECCVwkj5XMOH/rP6DdzbYp0vu6Y4aSc= Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RXpp62N8Lz4f3jZd for ; Sat, 26 Aug 2023 15:47:58 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgB3B6osrulk6+l0Bg--.52079S4; 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 2/3] mm/page_alloc: remove unnecessary check in break_down_buddy_pages Date: Sat, 26 Aug 2023 23:47:44 +0800 Message-Id: <20230826154745.4019371-3-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--.52079S4 X-Coremail-Antispam: 1UD129KBjvdXoW7XF4rWr48Kr18Wr1rWw1xZrb_yoWDAFb_ua n7trn5tFyUKF17KF17C3W7GrWkWw1F9w4xWr4YgF43Ka4UAFn0yan5XFyrJr1Duay8ur98 u3ZxZrW2qr1a9jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbfkYFVCjjxCrM7AC8VAFwI0_Xr0_Wr1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l87I20VAvwVAaII0Ic2I_JFv_Gryl82 xGYIkIc2x26280x7IE14v26r15M28IrcIa0xkI8VCY1x0267AKxVW8JVW5JwA2ocxC64kI II0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7 xvwVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2 z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4 xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v2 6r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwI xGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I 0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUVHGHUUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 38E18180006 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: ptfnh9xeq5ck1ssq14345poczujh5ahs X-HE-Tag: 1693036082-503787 X-HE-Meta: U2FsdGVkX19iBrPo+rWnvCMVy33q2dt6vs2J4KP6VBhZDpgPJ69RMAG9ZHAfyVkztpSSnk269mhGMr1M3obzHaNzx1yIW+z7Mn/kMfSvnuFzTXIAaW/mc0w32S5qIOLNS3e5v/uAGLdjW1DxZYhF3ZZb2JXq/soQwQo9gqx9/sZlXHGUbcNRBAmLWKB4QYXPDqxJCpmyfzH5di0MADT0YZ1p38oAvUGhbhQzfohoKu2VZFtizBKByrrtSDAX1T/4fVXxkOUYHDA3x8DfFwIJ9PM64rGvBwvpMu17U8w+tDex48KXvcpdFndvHP013/Vn2coNSg3yNpe1ZG9J26+6+kWsa0NHE/0NumtDHdni4/SHbPfxxwfeXyyi+mE8h1lplLR+NDbxs32GctvOyeu9Ga/2auXSmXs6c80Jrr9httTQvXHSzO7sJUTpkYjiAZU2AkEehZbThfOCdh1lz/DWeONMjnZUq/sovc734EgJjxb38BRQ+xiktQ4TgStI66ZxjBjhKV+2eg1JgFSYuN/UpJVXZSIeI2Sk5hfBufXY+2Hr10h610VzIKQzKZ090mvpxmQw/9PEKrpu2M+4i6y8fJskT04Rs69YbYVi6VJeWWeJ0Nnnnv0rdXYt2KrThYuvwBsXEyEjoICsodBb8A0XY/TbQmnCXvUD4tsAxtlOo/djGIsjYwep5VTWGX5vW2c85HXTyvwqyZnDZFpztdtneIGnwdn9Fgzp0CWcycYIsdtd+vAGzncuuVH7hNw2/IglNxz6pCY7H90RDLWc+VgFoBZ+5CVWJtQf3va/dL1IE1xQ0qBamIIJU2X3a+cY+PAThTrgO3iptVJvq0nIf9Jpulu69ze5WVh6//pesICnNc0cGQglb9eLurHw+hxlAOfqMK84skFBE8KPX6Pg6TsZC+nPjzinjkIAnJArDCYfjr4Wma8HDBlD4KHw98cFbG08XeSyYi6TymTfoDVqtkG uERskICa xX/ENthnZ74cjqYIWGY3xXLLn2ohiKfRP1u9eMYAWqnXHNxaKEkM4EnFLaPaaeAzCaHlMhVjMyy5JR6aauadOFadAbRW8dDA15OfAX/D1bWbD3hgYYQpGjmbjH5k6+UT897kwZGafKhzltzYTC7xIaagv6cDxrc+ueBWpztRGEPcMjNAci/rP/LsRqBLMPcitoaAbd3MqKSXPns9Dq19OaWcnLZ+UaM77nBQBdmjdOxuUcGS7aSEHBoNZeHIRnGjQkNftrR1sKLc7eXI= 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: 1. We always have target in range started with next_page and full free range started with current_buddy. 2. The last splited range size is 1 << low and low should be >= 0, then size >= 1, then page + size and page will not interleave. As summary, current_page will not equal to target page. Signed-off-by: Kemeng Shi Acked-by: Naoya Horiguchi --- mm/page_alloc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 88c5f5aea9b0..bb74b40dc195 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6510,10 +6510,8 @@ static void break_down_buddy_pages(struct zone *zone, struct page *page, if (set_page_guard(zone, current_buddy, high, migratetype)) continue; - if (current_buddy != target) { - add_to_free_list(current_buddy, zone, high, migratetype); - set_buddy_order(current_buddy, high); - } + add_to_free_list(current_buddy, zone, high, migratetype); + set_buddy_order(current_buddy, high); } } From patchwork Sat Aug 26 15:47:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13366520 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 BE02BC83F11 for ; Sat, 26 Aug 2023 07:48:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65F2F2800EB; Sat, 26 Aug 2023 03:48:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60EAB2800EA; Sat, 26 Aug 2023 03:48:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 461E82800EB; Sat, 26 Aug 2023 03:48:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 356602800EA for ; Sat, 26 Aug 2023 03:48:09 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 29649C011F for ; Sat, 26 Aug 2023 07:48:08 +0000 (UTC) X-FDA: 81165477456.28.021B676 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by imf08.hostedemail.com (Postfix) with ESMTP id E2F8E160006 for ; Sat, 26 Aug 2023 07:48:05 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=none (imf08.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.56) 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=1693036086; 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=Ut+LFIwwXptAQpA3D+G5n0tGS/UjQZCuyKTClyCORU8=; b=DNnARdLPP5MVZQuEaPkMGjo/FhAOkl7t/sOd8QVgGSQaM1xLy/Wk/7/CluI/jii5GMOIQ2 FzpQNbjUV9ReeBQQuSSFj6hoQP8tlrI0EAF3LU2d+Q662Y8pvOEhuEilPRQsTkA9gKcnFl YumzzbXhzAUvf4djQ1fd9N9uEy0K5YU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693036086; a=rsa-sha256; cv=none; b=Y7b+bBggJET1JP6eQrObZLZ/AERvESNpsneYckgPBLXftgJHDPRU1lIhfhjW1xmNwAOq/R tdp/zfE0F1tPIYBfsm0908ff2ZYjHojB3IkXT8C8AQHC6bSvosDKAcxZNPYiNNC44R2xw0 /DWMH+NzccFkQE/KqWtVTeHTmf0Vrzw= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=none (imf08.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.56) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4RXpp35lVnz4f3kj1 for ; Sat, 26 Aug 2023 15:47:55 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgB3B6osrulk6+l0Bg--.52079S5; Sat, 26 Aug 2023 15:47:59 +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 3/3] mm/page_alloc: remove unnecessary next_page in break_down_buddy_pages Date: Sat, 26 Aug 2023 23:47:45 +0800 Message-Id: <20230826154745.4019371-4-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--.52079S5 X-Coremail-Antispam: 1UD129KBjvdXoWrZr48Cr17tF4ktryrZrW3Awb_yoWfKrg_CF s7twnxtFyYgFy7ta13A3WxJayDXasY9r4xXF13tr9xCFyDJFn3X3Z5XFy3CrW5ua4ru348 uasrZ3y7tF4I9jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbfkYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l87I20VAvwVAaII0Ic2I_JFv_Gryl82 xGYIkIc2x26280x7IE14v26r1rM28IrcIa0xkI8VCY1x0267AKxVW8JVW5JwA2ocxC64kI II0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7 xvwVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2 z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4 xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v2 6r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwI xGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I 0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUVVWLUUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: E2F8E160006 X-Rspam-User: X-Stat-Signature: 4kyjsmiozybnfi8sxnw3qsy7s1sge6wa X-Rspamd-Server: rspam03 X-HE-Tag: 1693036085-802442 X-HE-Meta: U2FsdGVkX19+mBCgCP70jXaKLDA/4VfoXVs4geFkYaXtHH5d22QqCk9OFt6N6s7IgFkVw7LCqGwWyvq/eZCpZF/bL677JJJu53UhP6/FdPa/ggBFQEXUhjDW+LXjWildzGXsYhA1lOX0Ur8+VtD1gUR/KvTKsMKXa2F8fKxpeXqhxixM5YWejOVC7dCq9gCXD6bWNXTAsU2buUAoJtF0RNFMPghOKY4ilo0kE6FMiv+qBNRA7zE+MQzRNgLPLo5KWj+nRYwHiMnsrmRkwMC0at3obBPuyhGAnEuZe9FRTJFcN2a2SPjIHviuppooE304nj2pF/jCggUR1SKH78ImgdL7MVGTzKHiDVbOPYJqkebyFdCnTB9nVTOn9Q97mtTh0Drktw4Pjz6+XGuEn9UdREjc/Byp6BRZB3jf6NX5cafAYxbvdWbGVAGsuSXcwFzE4wgkZi9bWP+VpCgQvzw8/dLJOykhma0gVe5IqKEXxAHuSvuoMI6klALlRjlUERSwk5XxC+d9mC767Y+eDby/YSn0hQSxUuOOZxX04xBzAVs0oX9o73x0J+QUmapAHxYI5uIZvjwrtJGNKquKtXh4QhjY4g4D3PcYgKjiFhWhc3OQ8gGyTe4EnSlP5B9AiQqVYjO4kuT4zFJ7/5Z5PRoxuMg8i1vE8w+Fvrk1KklZTkcznjs4a4DbhyVjwivcrHmz0WKTlK7KiAo+R+kBLyC57qjJDGa0lHShcMohW/sCyZ+R+Xs60lvFf7KBH/eF39PHPMifL/pQiaaozMvFLBruj+89Lq1Fx+X1xKqDsgq2BWNJPrGySAl75ZjYKWKKmE39MVTJ8gE1SL7AezjxARW9JE+H+TBkxebz24ctj3QWOyil1vRbmSkWebSuiRhmy+/3RHv9BNwFvEmhA9+dRGjb44eMZfTh5EXKMMuShoDwlgbZpFNGFn4uzlOK2yCUxjmo0XlA0X99Xnq+3V2fdbf ZXjY+uu4 +XtVI8YPR6QCns/77LM7ThxsrtXMDmVsmVZF+bOWKAjGtanIkNiGEU1EULYWQ1P/mn0mXm2NKu4IHut4k5KPOAmP3sf/ccDOwTi/oi9M2d8yZ9idM0JcLB4UQWFxiwrR6G2OI6GbA3O8so5xZeiAXLrS1IhxU4YFRav4YqBl5SczlStC9s27k/jvQj8mMV1g6mIwlgX59VUxOZCDPOSb7DOX5YjfBrSM/bdMhVjUmPubyL2DDuTSpR8bSak+vcXRGt1A+VZmuLQvZ+qeUhkj+sWUihPGkOausFmH9UgKMTVnyOQBgrmcGer9Xjg== 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: The next_page is only used to forward page in case target is in second harf range. Move forward page directly to remove unnecessary next_page. Signed-off-by: Kemeng Shi Acked-by: Naoya Horiguchi --- mm/page_alloc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index bb74b40dc195..1c35ee022dde 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6492,20 +6492,18 @@ static void break_down_buddy_pages(struct zone *zone, struct page *page, int migratetype) { unsigned long size = 1 << high; - struct page *current_buddy, *next_page; + struct page *current_buddy; while (high > low) { high--; size >>= 1; if (target >= &page[size]) { - next_page = page + size; current_buddy = page; + page = page + size; } else { - next_page = page; current_buddy = page + size; } - page = next_page; if (set_page_guard(zone, current_buddy, high, migratetype)) continue;