Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp810214pxb; Wed, 13 Jan 2021 17:07:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/qkIzYBC4qLNhmtz/5rWljMthHOaFhwYsSD9Q2yWHHdBbj75pgWsI1Cg7eG9iHbZeNU37 X-Received: by 2002:a17:906:fb1a:: with SMTP id lz26mr3495074ejb.194.1610586478934; Wed, 13 Jan 2021 17:07:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610586478; cv=none; d=google.com; s=arc-20160816; b=Wy1D4BSd7UgrpaDBR/OJ25aVEQcvZpFx7TgTYXynm042KHDwvPkhxXqeSvfNyjf0kk 2xT0USX1kv9yxXzgvwz2uiRz5Vnj/o7XCO0QWxR/mMvxiS1+HN7g2M07xpPd5FbrfQPx Lb+E60tkVK1EHhGN0ZxPigUddBtxJKXE/SuQNUpheJvS7NAhhXJ5f8izYNqPwdwgxGdx CKoi0UTX02C3G0WJfFcloKisHxhNwrrr57naBFW1gEwy2kh8PPO2M8UmkbF7fndVPpEm tzyl4TFMTPZR5wsvJVhvXoFb68RpGOLWLTRW73xnUyfA1zBoS4vQFMa8uRsNWq6LoGY8 0s2Q== 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=V5eAUqVWcndmv8STx1bf+M2gfcyHV6nmjwRyq5Re1uN3i0vvUHUhHyLXndbH+WFjWY JriS7W0Kn3cbqCldoDobywhEvK9GY+9/UbA+ESjfxAYxLyHuxy1aIFec6ENy83f2MwVd KbymtRf+wt3oyhq9V4NCSY2RknkrPu/3fz933KoVXb0Vr7y2Ktc0m13Bps04iN+RyFfF zAXIo3ZIv3oshTHh+Ov/swoGW5OCr9PqJ4+0/vUNEY8GWFKCXqg5OGopN6JcCCPZ6+y9 N7Wa7JPMeIsx7U4cxgk7T2soxnLQ0cpoLtq5o+8bwqk03NMcVW3tXph21NKYJcKv6O0M UgzA== 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 i25si25164ejc.587.2021.01.13.17.07.35; Wed, 13 Jan 2021 17:07:58 -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 S1727024AbhANBDt (ORCPT + 99 others); Wed, 13 Jan 2021 20:03:49 -0500 Received: from mga18.intel.com ([134.134.136.126]:43797 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726773AbhANA4I (ORCPT ); Wed, 13 Jan 2021 19:56:08 -0500 IronPort-SDR: lfm+jt1H5zM3QXqvp1+E5XDG8nRMYyG0OxFlBkiyQNCZ4tDK/vuy7tuTIhMjFY3i6QHJsJMiR4 bcOwz5yCOSUg== X-IronPort-AV: E=McAfee;i="6000,8403,9863"; a="165963396" X-IronPort-AV: E=Sophos;i="5.79,345,1602572400"; d="scan'208";a="165963396" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2021 16:43:16 -0800 IronPort-SDR: 115jzHosqSjA608xwh/hG5WnzVebIk5BCHEyB+oFTxzD9/L652pWRDfYgK/3swoa2h56CJIW3w Swad5KOTXWEg== X-IronPort-AV: E=Sophos;i="5.79,345,1602572400"; d="scan'208";a="364059362" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2021 16:43:16 -0800 Subject: [PATCH v4 1/5] mm: Move pfn_to_online_page() out of line From: Dan Williams To: akpm@linux-foundation.org Cc: Michal Hocko , David Hildenbrand , Oscar Salvador , linux-mm@kvack.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Date: Wed, 13 Jan 2021 16:43:16 -0800 Message-ID: <161058499608.1840162.10165648147615238793.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <161058499000.1840162.702316708443239771.stgit@dwillia2-desk3.amr.corp.intel.com> References: <161058499000.1840162.702316708443239771.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