Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp163689pxb; Wed, 20 Jan 2021 04:04:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwk3AO2GfUhbII2l4/BxNq+0Sax6C7ktmAzXtB3Uw333vd3qR+H6VWGQxINe+GI7hzbdX/n X-Received: by 2002:a17:906:f950:: with SMTP id ld16mr6043814ejb.553.1611144254926; Wed, 20 Jan 2021 04:04:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611144254; cv=none; d=google.com; s=arc-20160816; b=fNVYFX3OKW++jZe/9IUm6sM7friB/fCs1FRvZlRbYczxNJGrsQYdvKO/sNJm1skrp9 /+6R6030Cn0DYyqTiKrizPFU7xZOaNH9vL+hA/Z3wN4+OqWireAS+o/O5fByL0LK3gLA bHEKOvl7R07o4RJnfwo4pPVERjBhGdIzBa+nOceba0Gq6P+NBtUHv/rdnXrHMISgjsDI E1Acf/iyUcjUdbKB7t1DVyIebvmYFuMKmJc6UeHKZCaTAPxnTSr07h6PDvfw3CnFJIEC 2FR61/ogAOUpTQgoIcS+pBbJ9y7c0DTAeB8XnOXWXDrh7NQqkK+PVyTENRLpcNhGEyXJ f9MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pR0wawllqar92e+0i/G2KHzH+n7trSGvXHpnYgU8y9E=; b=sVV+8u43BYI7cO+LkuzhWUd28uS8jCrClZXw4bDGO85CZBGLAsCtqqkx7ZWdtmYLP2 JzNKATpdNFZhFHuRHYXoaSvewbO72Kr7GUbDMZyRu9Vc8d0EcYcvbHbTQDbXFEcfvOpg PV148eXovavjVNp/K9emAOd+GvN2TnY9SfgyUPSp9eZHHEkVm8Eybj504imYgvM8CpoB oe0SVD9seW/4hesUAG86bTs6DA44vVTCfpF68vzP5uvUwbTT7Lae7GTrnA78Kx0AO/zR +9YCfm0ZNTxCDXRWgsvNSuvE09IME9SSI0QIx0+6t7bmNbfWxOjR6TZN95Z5CnNrENWP U08w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=OMcPSYXB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si810307edc.19.2021.01.20.04.03.41; Wed, 20 Jan 2021 04:04:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=OMcPSYXB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730674AbhATLhC (ORCPT + 99 others); Wed, 20 Jan 2021 06:37:02 -0500 Received: from mx2.suse.de ([195.135.220.15]:59472 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726683AbhATKYs (ORCPT ); Wed, 20 Jan 2021 05:24:48 -0500 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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