From mboxrd@z Thu Jan 1 00:00:00 1970 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 6D565C77B60 for ; Mon, 24 Apr 2023 02:25:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD7A1900002; Sun, 23 Apr 2023 22:25:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A61216B0074; Sun, 23 Apr 2023 22:25:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 901D0900002; Sun, 23 Apr 2023 22:25:35 -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 7BA8D6B0071 for ; Sun, 23 Apr 2023 22:25:35 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 41FFC40363 for ; Mon, 24 Apr 2023 02:25:35 +0000 (UTC) X-FDA: 80714693430.28.B3B6664 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf28.hostedemail.com (Postfix) with ESMTP id EB6E3C0008 for ; Mon, 24 Apr 2023 02:25:31 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=OlSDe8IO; spf=pass (imf28.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682303133; a=rsa-sha256; cv=none; b=aThCNOpc6gHFSFci2QUHT+U1oFX20UGAt8mu+KE/R17BMPNXxuIIrkhyGgRSosovjZsKMt INaOBP7L7ApQYFfWZc1N0ot2yPG4PrugW6MO3kKG7ciB0aOCDXThNiLRQK4PofGzAnr+Xs SeaKiGfLlgm4ATuYIKBrT2yb/abzJwc= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=OlSDe8IO; spf=pass (imf28.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682303133; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=iOjC4rIO0V98HI8ahcRq53WGT43Kw6q2L2qzw/hhk40=; b=tbul6mTXQDjEy99YgLKUuuGxapCfnLxqlqTyp3508ebuaqPBMdyYC31PQde9jUdd654rWD D1fNT9gtFvAW9Cr3OEySUQjIalXG1mCamTBCi5Z5/+qKnpS03lWAEwWLUnEuZ5vYnxBsbB G+/vcLGCmqCYdjzZcqsvKwo9iUnnHTs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682303132; x=1713839132; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=mFgWMHVptgTptbXo4KBicjciW2/3ffbL7luHMBnQ60k=; b=OlSDe8IOkInPP8HigTZWEmH8VRFb5Z0dT+qVSqoAbOYX81z8UQTkrMbF 98rQ5KrOqB5/4kYTJAklKk+dJcgIU5COJXflAiwc+PQyEW1WGxYw7oSEA wnbX9C9MlWDj7BirtBzQNvVq9lLewm/y4NC91CRRnN2owinBZOlxHPwgF TVxgV7TGrN6HX6Tp1H2vPYo+nCBcSH1ywfUUka6opVxvlND+KR4mfj8Lx TFxhBS01NQdVFxJsh7UMBC/ilce9SWp8RfqT108u9J5iLHVopTEppMV3l zWoHxYFpk7OClWiHWFMQyMyHmWvraBpU0c54xEM+g76XlIXV3ke+oJXal w==; X-IronPort-AV: E=McAfee;i="6600,9927,10689"; a="325944840" X-IronPort-AV: E=Sophos;i="5.99,221,1677571200"; d="scan'208";a="325944840" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2023 19:25:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10689"; a="670343291" X-IronPort-AV: E=Sophos;i="5.99,221,1677571200"; d="scan'208";a="670343291" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2023 19:25:27 -0700 From: "Huang, Ying" To: Baolin Wang Cc: , , , , , , , Subject: Re: [PATCH v2 2/2] mm/page_alloc: add some comments to explain the possible hole in __pageblock_pfn_to_page() References: <9fc85cce8908938f4fd75ff50bc981c073779aa5.1682229876.git.baolin.wang@linux.alibaba.com> <0733a4cf57109a4136de5ae46fac83fb15bdd528.1682229876.git.baolin.wang@linux.alibaba.com> Date: Mon, 24 Apr 2023 10:24:17 +0800 In-Reply-To: <0733a4cf57109a4136de5ae46fac83fb15bdd528.1682229876.git.baolin.wang@linux.alibaba.com> (Baolin Wang's message of "Sun, 23 Apr 2023 18:59:11 +0800") Message-ID: <874jp6kofi.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspam-User: X-Rspamd-Queue-Id: EB6E3C0008 X-Rspamd-Server: rspam01 X-Stat-Signature: mijo81qcorifwn81nkd5udigrgagtcf4 X-HE-Tag: 1682303131-912239 X-HE-Meta: U2FsdGVkX18WP4hT3LcLntK5ECB/43Wbn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Kexn36o0B/kombOfwdTIgBnjIL/gKT5IAJyn5UnA8DWM+1OoeKsB2yy8I4b08jzOSOK64pVF+qttCzgcBUvwDAsqnMxGjRvbAN3vGhlKehHscw+SqrOf86K9MWhToWunBqcHArnHsLMCxlFB7oG6NQ+nqR4W3F2YS4emZa16+sBxyYuUFp8IB+94a6uaWzFqxPLP5Dq8GOjQ6iZTazRNZ9nhs6bNenb7sUHT0Sg= 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: Baolin Wang writes: > 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, the __pageblock_pfn_to_page() function may return non-NULL even > if the end pfn of a pageblock is in a memory hole in some situations. For > example, if the pageblock order is MAX_ORDER, 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 Looks good to me! Thanks! Reviewed-by: "Huang, Ying" > --- > Changes from v1: > - Update the comments per Ying and Mike, thanks. > --- > mm/page_alloc.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 6457b64fe562..9756d66f471c 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -1502,6 +1502,13 @@ 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: the function may return non-NULL even if the end pfn of a pageblock > + * is in a memory hole in some situations. For example, if the pageblock > + * order is MAX_ORDER, 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 about this possible > + * issue when checking whether all pfns of a pageblock are valid. > */ > struct page *__pageblock_pfn_to_page(unsigned long start_pfn, > unsigned long end_pfn, struct zone *zone)