Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp184276pxb; Wed, 13 Jan 2021 00:34:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwypy5ve3ta/PQuMqiW2wZvoom6Jac7Qo0Ugv/L9qXyFY/oBhFmhHKowOwSrhJheM6CJEek X-Received: by 2002:a17:906:8058:: with SMTP id x24mr751217ejw.262.1610526862110; Wed, 13 Jan 2021 00:34:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610526862; cv=none; d=google.com; s=arc-20160816; b=pku7fGPWyBnEDy4zD8FcvakvQTWhISNr8IoIhd2M0cZ3W5ScJwtxBzwIb+a86NpSBO fjpSyMW01uKacxk7QN/vd/oVHtJktWPvzah3Qkyai1Q1Iju49USZD94DIOuLBOWSHKMn cRph8GiKz8eGZSMHsUHa+F+hN2oA/7+dmbNNHDnhKACxVlq/SPeZPnDXAN+lWp85ePfM Dv5Cyu1c11YCaYVKsbCHl4X5vVQdoQFAyP5paycwVUqTEv7FZ0GUXR4T2GQzx2CCpvCZ WsPO/0/l9O+QTSXfvc+/ZKTAzFh+KgC8XU3XOu8+pVV9qhQbVTLwghg8ivsilVUPsooC 1MxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=cSBBghfeOdmH+Xgq41cJVq3cMWhLpvIrkFcgEcvCpU0=; b=ymDIoMVR+PMofCTT9ZWmGko2seVKPcdD7DMKXokP+a/1eXM+vDrSENYt5eYoiGYjFR cKbnTnv3+JnfeU+AJwJnSxAbTn7jbhN8PW7O3x1lHJPnlZCDbz491PgE3t1NpFd+woy3 H756Mj1IgptLWgp3nWn3OMerQUzeXrAE9Ep+Opjhn0uVNJ9wu54UfYes4i0189d8HyIi Ake5Z02UsTftTFV4Kg+aBSm0PBjbRPo3tz5ibvn9xO/esP6ABhxkjMREPK8/enTBCVuG ld0zQmdaNv/LN2XzeGnyQyJa+eZPWURZ3gJq8QtoAcQvYk4Wbj4W4xQJ4BovoZ+Ontxt dAww== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z13si151436edb.473.2021.01.13.00.33.55; Wed, 13 Jan 2021 00:34:22 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726858AbhAMIbg (ORCPT + 99 others); Wed, 13 Jan 2021 03:31:36 -0500 Received: from mx2.suse.de ([195.135.220.15]:36790 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbhAMIbg (ORCPT ); Wed, 13 Jan 2021 03:31:36 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0F71FAC8F; Wed, 13 Jan 2021 08:30:55 +0000 (UTC) Date: Wed, 13 Jan 2021 09:30:52 +0100 From: Oscar Salvador To: Dan Williams Cc: linux-mm@kvack.org, Qian Cai , Michal Hocko , David Hildenbrand , vishal.l.verma@intel.com, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/6] mm: Teach pfn_to_online_page() to consider subsection validity Message-ID: <20210113083048.GA23676@linux> References: <161052331545.1805594.2356512831689786960.stgit@dwillia2-desk3.amr.corp.intel.com> <161052332755.1805594.9846390935351758277.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <161052332755.1805594.9846390935351758277.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 12, 2021 at 11:35:27PM -0800, 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. > > Fixes: b13bc35193d9 ("mm/hotplug: invalid PFNs from pfn_to_online_page()") > Cc: Qian Cai > Cc: Michal Hocko > Cc: Oscar Salvador > Reported-by: David Hildenbrand > Signed-off-by: Dan Williams Reviewed-by: Oscar Salvador > --- > mm/memory_hotplug.c | 24 ++++++++++++++++++++---- > 1 file changed, 20 insertions(+), 4 deletions(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 55a69d4396e7..9f37f8a68da4 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -308,11 +308,27 @@ 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)) > + if (!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); > > -- Oscar Salvador SUSE L3