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: 13220954 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 521A2C77B78 for ; Sat, 22 Apr 2023 10:15:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C167D6B0075; Sat, 22 Apr 2023 06:15:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B514F6B0078; Sat, 22 Apr 2023 06:15:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A3A66B007B; Sat, 22 Apr 2023 06:15:37 -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 873B36B0075 for ; Sat, 22 Apr 2023 06:15:37 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4697B14015E for ; Sat, 22 Apr 2023 10:15:37 +0000 (UTC) X-FDA: 80708620314.15.711842E Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) by imf20.hostedemail.com (Postfix) with ESMTP id 362551C000C for ; Sat, 22 Apr 2023 10:15:34 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf20.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.99 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682158535; 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=mijX5G9vkIVUU+zycbfVU49M9mUY+uZK3RiHQt+rXiM=; b=0x46dowxkU16LJBBAu6ypXzGkSmWIY2dgX+IT6NuI4rIxdmqZABbSjS8YqC/e7Z4CDrwN4 CS2DTN6QWXfp1InC/6JyS2yLtzOkGr+ALhPKsigAPeJ1ogyS4AF5K//zqUZAwWYc5bNz6L wQPhYRuv9KCUXTWDoAi7gGAsZwWNXKo= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf20.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.99 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682158535; a=rsa-sha256; cv=none; b=L2IF6y+pVK70b6VEYC6y5/1cFNZ0ovlKfzCA0wwaHyrMnJgJNrFGhsFzAXs1775MhvjaQA FSkeCzyZSPAGq9ZBrJyEPckO5slRDVqPOelvJwPc2ykELoS8gQKTkJiCQZsB9RQ7+f0a8b CdWAN57OGyd+ZZZixfO9F/Ng7A5PiN8= 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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 362551C000C X-Stat-Signature: goqing93gydu1iuinsxt1keog5b1r9cp X-HE-Tag: 1682158534-154620 X-HE-Meta: U2FsdGVkX1/CV4DZ3kF4g5DbfJ6Vz/cblMNKKnGpAgfctaqT5t3MO03mxRNi/PXDwwee2JgeW0mkvw98omRdjgmnYWDKjIsDLb4a7tElGFD1Bixo3+NgfQSE4jqct5f5vxJKCyEMx2cp93PsZg+gBYQHHahJxXuV4HK69RQbZ2nE3V1Gfpmh2lRobGptqwDFWCupDX7Z8ILtRJMWnUCwSb2Na4Pg467UmrVZxyOjpz6Rk7kfDHJ8usXOdmTHTCQS8BTL6zr54Z5hCZYx6k7SitFgCvrcRCh7geC2o8rnGUbYDpOVVQK7QMMdrUaBYY9yfG2ooLKyTiA1oN68aZRk16k/GD1Kg8leI2eMl06lTxvSPBuU2+f+hLs66m2KdXGT9GL3Hnjx2I8F7/oiqRDV+WF9p6LnaCPBQmG1KXbV4lDz2/LJNe9cvcpvLWB13E3+xoFMn2MjbveFL/W/lFiP3+cXp/+U9pbI+WCAvZ7+b09Qz4ahRatB8UIuSt5T8yKy9Nw2UEfQzZnJ+juPigyaZJAM6405TEKV8tg7dyxfMftgHyS+AJvUHrjNki53/88b9FFNAb62kW4GKJFlDmzOiz5ulyltHVmNkZWvnYqOGCmdR+L39W2lApihj2s2qb2VHEbfNMrPomaqDGEeERTomc76o3hdaXUevRCFoUQ0V605cE22BGv9U+OCinhIMW9ViEQzlCMzKNU4or33osv3uR3CozP071BYgTJgEZ45gmaWpvK259uWJ4hmOGhrJ9x4YCTZ1Eaco3XZ/lP4xGBfZw6LGNQnex4y5i7rFr1kAW1FRFVWRoDmC/ZgDJMOwk6ohumgrjicOk6BIORfnXV7g44deuoEnYC97Yv+8/adOZJZbL9CckpFbzF57G5xOaAQCJwTX80bqLRX8OQuX+K7GNn4YcR5wni659Snkfkou/jp6fTTsp+gPzXoUBpId3kNYP1ViSrddMSaA3H0FE+ O3BbPzoD +kQ9W2fIKkVYR2ShNOWgKDW6bJ3JpxhSfoDM8N0LbAwJKst9VujmVh5sJiiogr+wTwcyYi4qNfmPpUmA6RrT3JzWOguA67BqRp7o7foo7KmQopwSEGWcdBStPRZ9hQbm8uvXEYJ16UEoFhOQ7Bh3g3kZwTmT2Ej9qtF1rQZRs2jYmMxw= 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: 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: 13220953 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 5943CC6FD18 for ; Sat, 22 Apr 2023 10:15:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D26FA6B0074; Sat, 22 Apr 2023 06:15:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB0136B0075; Sat, 22 Apr 2023 06:15:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B511A6B0078; Sat, 22 Apr 2023 06:15:36 -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 A19006B0074 for ; Sat, 22 Apr 2023 06:15:36 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7273014013F for ; Sat, 22 Apr 2023 10:15:36 +0000 (UTC) X-FDA: 80708620272.24.9FE5E42 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) by imf28.hostedemail.com (Postfix) with ESMTP id 64981C0004 for ; Sat, 22 Apr 2023 10:15:33 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682158534; 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:in-reply-to:references:references; bh=YcLa0KSM8wD3Sx5aB5eDsccrbn1dqKcpDuLQ6Mqt8Ks=; b=a3nCAgjp7gXDEjxDX+kVe+4z6NBuxFkkQn8lqqTbNEeU1MKs1sP1dbeKpbjSYibxEhCvzW NhxeOMmh8/r7cSGFeo4x0vkQrnvo2L95PoZOXpu2CMNW94+hFz2rdWybnEYi56QYT0pltD RwxDrUmGuVf+M9LNa69G54Ckl4vanpk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682158534; a=rsa-sha256; cv=none; b=t5dl7Aa1+bETh6Sg7roOzOQxJbBf9n1H3bZrsgOVjiII5i8kQJTrjkD8VLrQ8ygPO3eMXG BFey0CuzWA/tdzy/Id1H5XvKlnElOy5DszFtoBzGCOQHPaUgc9yaZo8fMuEj1uJANBNwP6 DrFq3DuHEYTaZNrHShXVBTviqFJ3mSo= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com 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-Rspam-User: X-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KI87J 7o5PqAHQgAflLIGmrU1S4T/XfgJEvMcrrykpd5GGJsUFLRspXC2DgQd00TwY/nJ3u8y9rYovqCxKPUSOYn984gr50mD5yDUl0pcZ5fdltDvdCawBy+Ou01ilGpI0/Ho+aRGzimMC8kTcDLn+zhOxx5LL1SPNO3pBVED1gew758xq1UY2IkX9pQdGaLthKDXnBZh3Qo51Gv1H1gRVgX9KCEQeGfDY0TsXrT9ftl/uGzchofX/Piv282Jel9LrBQ8QTOdfd 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: 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)