From patchwork Sat Apr 22 10:15:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 86575 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1618205vqo; Sat, 22 Apr 2023 03:18:44 -0700 (PDT) X-Google-Smtp-Source: AKy350ZsxaE1qZgXC+p17cxQau3G48+75OOV5HjmFLqxmUtxpq1ay2rpW04PeMLDqC6HGHYkJhm0 X-Received: by 2002:a05:6a00:124c:b0:639:c88b:c3e0 with SMTP id u12-20020a056a00124c00b00639c88bc3e0mr10189055pfi.22.1682158723673; Sat, 22 Apr 2023 03:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682158723; cv=none; d=google.com; s=arc-20160816; b=qxCrzlxIQYWn0KUrYhE3x4+25QcYblIkrooONVXEQgDoHGzoLP/wGQxTwAksCVtsm9 Ifo87NMdEEjO2OaGywspox8E/MfIKvu0PAqJhQgJfSlEjhh7hRE6JjllKHIK6iv895ZN fhcrqMVC61L6r5qq82KWdH4ZaVikTxl0mEDxXCGGfrUks0x2mxpSKXppIv7EwUTHDFvg QOrnDCOftH7uuu7/fRHlGkTsmgn8qTiE34q681Fy90kcUg4y0P6i12Hj70ZdjWysH5uT 8vggxa+ydV7LQg50WrfvrqdUSQN0e0S8i7mRKRlnZXCGT4yzt622Z/SeOsUDfGj3zBLY hEpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=mijX5G9vkIVUU+zycbfVU49M9mUY+uZK3RiHQt+rXiM=; b=no3OyfEs2PTxbJOoaZ1T9/r1TVzvtfLj1daV0grsUx8Zy1IM1dTDshir4uIi4YnRH6 Sg9MpBJPoOq2ONUVrNuemN12lPjODHeQFRfPLURRhTsOjGy8XFsVoLbfhGJvs0Oubh7p zyqNxNNctiewBQUiemUHCVBRu5wKSrJ61oOm2Ul5X4ihQLb1V1Rv3WwZixSY1Y+6Qrzp 76Iz1enL7BcbMIwMZ2DDqKttVkCgRfoyOby51l7SOBEA8b7oZ2LLqj84yw8F+2YE6yFq jbIfsT40fcXVH//vMJnP8KDz5LzBfwgYuI8C0OkaqtC+M4PHBS4sChoiysfe+FBcwKM9 OwhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x13-20020aa79acd000000b0063b8a36cbedsi6663305pfp.148.2023.04.22.03.18.28; Sat, 22 Apr 2023 03:18:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbjDVKQF (ORCPT + 99 others); Sat, 22 Apr 2023 06:16:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229957AbjDVKPl (ORCPT ); Sat, 22 Apr 2023 06:15:41 -0400 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0409E26B5 for ; Sat, 22 Apr 2023 03:15:31 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VgfnVJl_1682158527; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VgfnVJl_1682158527) by smtp.aliyun-inc.com; Sat, 22 Apr 2023 18:15:28 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: ying.huang@intel.com, mgorman@techsingularity.net, vbabka@suse.cz, mhocko@suse.com, david@redhat.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm/page_alloc: drop the unnecessary pfn_valid() for start pfn Date: Sat, 22 Apr 2023 18:15:17 +0800 Message-Id: X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763871265812973908?= X-GMAIL-MSGID: =?utf-8?q?1763871265812973908?= We've already used pfn_to_online_page() for start pfn to make sure it is online and valid, so the pfn_valid() for the start pfn is unnecessary, drop it. Signed-off-by: Baolin Wang Reviewed-by: David Hildenbrand Reviewed-by: "Huang, Ying" --- 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 9de2a18519a1..6457b64fe562 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1512,7 +1512,7 @@ struct page *__pageblock_pfn_to_page(unsigned long start_pfn, /* end_pfn is one past the range we are checking */ end_pfn--; - if (!pfn_valid(start_pfn) || !pfn_valid(end_pfn)) + if (!pfn_valid(end_pfn)) return NULL; start_page = pfn_to_online_page(start_pfn); From patchwork Sat Apr 22 10:15:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 86574 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1617829vqo; Sat, 22 Apr 2023 03:17:45 -0700 (PDT) X-Google-Smtp-Source: AKy350brUD503VIPt5leblQqxnfluzSlyAQIpxgn4cCm8416iPPMj9WNpPNGWTDciFXDPUT/lb8X X-Received: by 2002:a05:6a21:100e:b0:f1:8f7:eeb5 with SMTP id nk14-20020a056a21100e00b000f108f7eeb5mr8647911pzb.60.1682158664698; Sat, 22 Apr 2023 03:17:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682158664; cv=none; d=google.com; s=arc-20160816; b=07i4gYk1e3khTKLkbH6t+/qdyeVj8dYZ5QS81gufM2m5BRAzEvN0AM6lRgUQHl7CFt lFBIxBrEVb46VHa6XeI2akCjefP/pkCwulh7+qtM1TwVEPh5GsislaA+DQppPsA0fA51 Oslz00ul5ZgANz2PFQAWvwTYUBGgRpcryhNN6pYKQeNTz5cvAfZF0yyszrQjM+PTTy5h PGS7LP4FWgsYtcsJtcmg/5G8UqeC9DkvucIsWTZSTYDCB8kHEShrmlCR28iAcWWHHPrm i52FBgQHluHzU2ZccS/8r6KZQ/FuLmIN5g/9Mf2zWPUcAWrR/4/8Ig5VbXZCcNysMU4f lNmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=YcLa0KSM8wD3Sx5aB5eDsccrbn1dqKcpDuLQ6Mqt8Ks=; b=W0xdwEjEoZHxl135qcnDcHgo99QJYBiS3oQSwspg/6J4Gpn+lBughrhu4hh28mByeY 3D+Ed9a9O659MCzeJl1eVHX21Ii62ePSftfpidV72Tcp4kdMBlfSV2uUgjRF/+jUJasq 1DU0TwE0n2raEGjQHx0DChsEJ6+Fc5eKDoYNfF+qXdx9ndh3avkD/AC0MRH1F2GwOxO2 xWOumshhEqv/tQylkqOQ0Ww1gTSqSgBnmjj+i9sduH7MH1N4dpiEHpFtxiEkdw3GW8Op /9hhXUJKgljnB018Awlm297cl+vX4zRuCzBP9nPKx5rQI4fvyNGmxkAuOEzmVwiYG+B5 bZKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a3-20020a63e843000000b0051ba9b9c3f3si2622993pgk.321.2023.04.22.03.17.29; Sat, 22 Apr 2023 03:17:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229810AbjDVKQJ (ORCPT + 99 others); Sat, 22 Apr 2023 06:16:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229684AbjDVKPl (ORCPT ); Sat, 22 Apr 2023 06:15:41 -0400 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD7601FEB for ; Sat, 22 Apr 2023 03:15:32 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R691e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VgfnVKn_1682158528; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VgfnVKn_1682158528) by smtp.aliyun-inc.com; Sat, 22 Apr 2023 18:15:29 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: ying.huang@intel.com, mgorman@techsingularity.net, vbabka@suse.cz, mhocko@suse.com, david@redhat.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mm/page_alloc: add some comments to explain the possible hole in __pageblock_pfn_to_page() Date: Sat, 22 Apr 2023 18:15:18 +0800 Message-Id: <02defcbe9d7a797a2257e5f6a28ff7ea78e394e5.1682158312.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763871203526823343?= X-GMAIL-MSGID: =?utf-8?q?1763871203526823343?= Now the __pageblock_pfn_to_page() is used by set_zone_contiguous(), which checks whether the given zone contains holes, and uses pfn_to_online_page() to validate if the start pfn is online and valid, as well as using pfn_valid() to validate the end pfn. However, though the start pfn of a pageblock is valid, it can not always guarantee the end pfn of the pageblock is also valid (may be holes) in some cases. For example, if the pageblock order is MAX_ORDER - 1, which will fall into 2 sub-sections, and the end pfn of the pageblock may be hole even though the start pfn is online and valid. This did not break anything until now, but the zone continuous is fragile in this possible scenario. So as previous discussion[1], it is better to add some comments to explain this possible issue in case there are some future pfn walkers that rely on this. [1] https://lore.kernel.org/all/87r0sdsmr6.fsf@yhuang6-desk2.ccr.corp.intel.com/ Signed-off-by: Baolin Wang --- mm/page_alloc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 6457b64fe562..dc4005b32ae0 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1502,6 +1502,14 @@ void __free_pages_core(struct page *page, unsigned int order) * interleaving within a single pageblock. It is therefore sufficient to check * the first and last page of a pageblock and avoid checking each individual * page in a pageblock. + * + * Note: if the start pfn of a pageblock is valid, but it can not always guarantee + * the end pfn of the pageblock is also valid (may be holes) in some cases. For + * example, if the pageblock order is MAX_ORDER - 1, which will fall into 2 + * sub-sections, and the end pfn of the pageblock may be hole even though the + * start pfn is online and valid. This did not break anything until now, but be + * careful this possible issue when checking if the whole pfns are valid of a + * pageblock. */ struct page *__pageblock_pfn_to_page(unsigned long start_pfn, unsigned long end_pfn, struct zone *zone)