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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 550AAC433DB for ; Wed, 20 Jan 2021 10:24:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B9E9923330 for ; Wed, 20 Jan 2021 10:24:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9E9923330 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D7B9D6B0007; Wed, 20 Jan 2021 05:24:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D2D1C6B0008; Wed, 20 Jan 2021 05:24:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C41DB6B000A; Wed, 20 Jan 2021 05:24:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0251.hostedemail.com [216.40.44.251]) by kanga.kvack.org (Postfix) with ESMTP id AF9846B0007 for ; Wed, 20 Jan 2021 05:24:03 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6F1DF1EE6 for ; Wed, 20 Jan 2021 10:24:03 +0000 (UTC) X-FDA: 77725767966.07.coal83_4904def27559 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 35E321803F9A3 for ; Wed, 20 Jan 2021 10:24:03 +0000 (UTC) X-HE-Tag: coal83_4904def27559 X-Filterd-Recvd-Size: 4171 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 Jan 2021 10:24:02 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611138241; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pR0wawllqar92e+0i/G2KHzH+n7trSGvXHpnYgU8y9E=; b=OMcPSYXBHvSJXBnY9ADeFvqbIefQc34k/bofJwAESHWDlgJj6QJMQFpNonxfi7gFOPdNCo C/SRaUQwAARGE0wlbU87CkKpBkWAPMxm2XRePeEsoP4ORVMoSL4uGibNxEW2xHKP/lkivf 4nMw4yVlBW2j+LG8oE/xHFp7HWrpbXo= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9833AAC97; Wed, 20 Jan 2021 10:24:01 +0000 (UTC) Date: Wed, 20 Jan 2021 11:24:00 +0100 From: Michal Hocko To: Dan Williams Cc: akpm@linux-foundation.org, Qian Cai , Oscar Salvador , David Hildenbrand , linux-mm@kvack.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/5] mm: Teach pfn_to_online_page() to consider subsection validity Message-ID: <20210120102400.GG9371@dhcp22.suse.cz> References: <161058499000.1840162.702316708443239771.stgit@dwillia2-desk3.amr.corp.intel.com> <161058500148.1840162.4365921007820501696.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <161058500148.1840162.4365921007820501696.stgit@dwillia2-desk3.amr.corp.intel.com> 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: On Wed 13-01-21 16:43:21, Dan Williams wrote: > pfn_section_valid() determines pfn validity on subsection granularity > where pfn_valid() may be limited to coarse section granularity. > Explicitly validate subsections after pfn_valid() succeeds. The changelog is not really clear on the underlying problem. It would benefit from some clarification. What about something like this? " pfn_to_online_page is primarily used to filter out offline or fully uninitialized pages. pfn_valid resp. online_section_nr have a coarse per memory section granularity. If a section shared with a partially offline memory (e.g. part of ZONE_DEVICE) then pfn_to_online_page would lead to a false positive on some pfns. Fix this by adding pfn_section_valid check which is subsection aware. " > > Fixes: b13bc35193d9 ("mm/hotplug: invalid PFNs from pfn_to_online_page()") > Cc: Qian Cai > Cc: Michal Hocko > Cc: Oscar Salvador > Reported-by: David Hildenbrand > Reviewed-by: David Hildenbrand > Reviewed-by: Oscar Salvador > Signed-off-by: Dan Williams With that feel free to add Acked-by: Michal Hocko > --- > mm/memory_hotplug.c | 23 +++++++++++++++++++---- > 1 file changed, 19 insertions(+), 4 deletions(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 55a69d4396e7..d0c81f7a3347 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -308,11 +308,26 @@ static int check_hotplug_memory_addressable(unsigned long pfn, > struct page *pfn_to_online_page(unsigned long pfn) > { > unsigned long nr = pfn_to_section_nr(pfn); > + struct mem_section *ms; > + > + if (nr >= NR_MEM_SECTIONS) > + return NULL; > + > + ms = __nr_to_section(nr); > + if (!online_section(ms)) > + return NULL; > + > + /* > + * Save some code text when online_section() + > + * pfn_section_valid() are sufficient. > + */ > + if (IS_ENABLED(CONFIG_HAVE_ARCH_PFN_VALID) && !pfn_valid(pfn)) > + return NULL; > + > + if (!pfn_section_valid(ms, pfn)) > + return NULL; > > - if (nr < NR_MEM_SECTIONS && online_section_nr(nr) && > - pfn_valid_within(pfn)) > - return pfn_to_page(pfn); > - return NULL; > + return pfn_to_page(pfn); > } > EXPORT_SYMBOL_GPL(pfn_to_online_page); > > -- Michal Hocko SUSE Labs