Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp157495pxb; Tue, 12 Jan 2021 23:37:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyN/6ttsxxheT7U8oOhm1RY09DZk4RARWWv3RoKQjauI/jUE/nd3MLmldUm2DZLtuPxUD1 X-Received: by 2002:a50:d484:: with SMTP id s4mr723151edi.13.1610523475699; Tue, 12 Jan 2021 23:37:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610523475; cv=none; d=google.com; s=arc-20160816; b=lT6+BnS9+TwQ9V2HMdDXkF7Zs6TtIaWjc9Cmc5oaxLEDEpsIN5OIP1CFis9jOYRw1b YNNoAW0q7ew2D0lyXYukE2luSnuEJm380ufk70RU9UyZft3ctmJHH0VEApZHc/XHLMI/ Y7KSgHrrEKnVE/PKw1m+tcoGZ+NU9u/mXdxRwLWpzKRFWf8tZ1hIy1Bdr5C25AsqWo8y /UEuwfbhapS5zaEO16ZsoEr2Gu+qXhhcSh8wjnwSNTUIl69YrjMiZpUPfRsxI1vPtQsp zJGDxdmLumC4hZZz8TxqNla32lx49mPsw+i4sjlmqQ1lIQshq/D2v+REkk0nRumUcEZZ zh9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:ironport-sdr:ironport-sdr; bh=IYRVWdJNy8LIAu9v6iHri3hxrN1ijXwmYST+uw5skOY=; b=fC32kYf7AJuNOy2bFgFGMXrHs8hoP9B+Y4RS3TD4Zfg2HhGI5E6KAmHtOs82sYTxtq Rk0iiTHkbpkX6cSiAL8Yoy9kdpPcW0MVEJRNHWflPV1Mo2BB8YrUFJ+P9DTZdiMjYeMz zYoFciuqIBsH7RpdRSyH7X/zlapDu/ngdl7YQAjv/ofxqLNHE6Etjc0ElZlYDO1520oj qJpijafWHcclvGoWLEjxmSFw0dZlnDi2ItOvFwE9cvS0pK0TqUYySLJ5znqvehGCcsnq xUZhrr4HOFxGYynZHgYsYApn8KyFKx1t043WJTZUk6/PQI+0Oh5xIwFbmW+sklNswuLr MOBQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u22si563704ejo.574.2021.01.12.23.37.32; Tue, 12 Jan 2021 23:37:55 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726288AbhAMHgD (ORCPT + 99 others); Wed, 13 Jan 2021 02:36:03 -0500 Received: from mga12.intel.com ([192.55.52.136]:47936 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbhAMHgD (ORCPT ); Wed, 13 Jan 2021 02:36:03 -0500 IronPort-SDR: CH5ASZKTYhkNXKGWsYB1ltNRzGgXDHF/+mkEP9qCL2ggdopFY8ovZTMEOE+5rFuX5y6aT8qWMo FOZX9M900CfA== X-IronPort-AV: E=McAfee;i="6000,8403,9862"; a="157345233" X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="157345233" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 23:35:22 -0800 IronPort-SDR: 7ft/S9SXYS17BgAO+zRFAtUO6aO7vn7AS1CmXPcxiVz1u10rMW79+z0AuIJEE2A/4jQI83e5p8 fgd+P8bO38Nw== X-IronPort-AV: E=Sophos;i="5.79,343,1602572400"; d="scan'208";a="404741003" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 23:35:22 -0800 Subject: [PATCH v3 1/6] mm: Move pfn_to_online_page() out of line From: Dan Williams To: linux-mm@kvack.org Cc: Michal Hocko , David Hildenbrand , Oscar Salvador , vishal.l.verma@intel.com, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Date: Tue, 12 Jan 2021 23:35:21 -0800 Message-ID: <161052332150.1805594.6767273540561236770.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <161052331545.1805594.2356512831689786960.stgit@dwillia2-desk3.amr.corp.intel.com> References: <161052331545.1805594.2356512831689786960.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pfn_to_online_page() is already too large to be a macro or an inline function. In anticipation of further logic changes / growth, move it out of line. No functional change, just code movement. Reported-by: Michal Hocko Reviewed-by: David Hildenbrand Reviewed-by: Oscar Salvador Signed-off-by: Dan Williams --- include/linux/memory_hotplug.h | 17 +---------------- mm/memory_hotplug.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 15acce5ab106..3d99de0db2dd 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -16,22 +16,7 @@ struct resource; struct vmem_altmap; #ifdef CONFIG_MEMORY_HOTPLUG -/* - * Return page for the valid pfn only if the page is online. All pfn - * walkers which rely on the fully initialized page->flags and others - * should use this rather than pfn_valid && pfn_to_page - */ -#define pfn_to_online_page(pfn) \ -({ \ - struct page *___page = NULL; \ - unsigned long ___pfn = pfn; \ - unsigned long ___nr = pfn_to_section_nr(___pfn); \ - \ - if (___nr < NR_MEM_SECTIONS && online_section_nr(___nr) && \ - pfn_valid_within(___pfn)) \ - ___page = pfn_to_page(___pfn); \ - ___page; \ -}) +struct page *pfn_to_online_page(unsigned long pfn); /* * Types for free bootmem stored in page->lru.next. These have to be in diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index f9d57b9be8c7..55a69d4396e7 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -300,6 +300,22 @@ static int check_hotplug_memory_addressable(unsigned long pfn, return 0; } +/* + * Return page for the valid pfn only if the page is online. All pfn + * walkers which rely on the fully initialized page->flags and others + * should use this rather than pfn_valid && pfn_to_page + */ +struct page *pfn_to_online_page(unsigned long pfn) +{ + unsigned long nr = pfn_to_section_nr(pfn); + + if (nr < NR_MEM_SECTIONS && online_section_nr(nr) && + pfn_valid_within(pfn)) + return pfn_to_page(pfn); + return NULL; +} +EXPORT_SYMBOL_GPL(pfn_to_online_page); + /* * Reasonably generic function for adding memory. It is * expected that archs that support memory hotplug will