From patchwork Thu Dec 14 07:37:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 13492511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3ECC6C4167B for ; Thu, 14 Dec 2023 07:38:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8ACFB8D009C; Thu, 14 Dec 2023 02:38:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 85D5C8D00A2; Thu, 14 Dec 2023 02:38:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D5418D009C; Thu, 14 Dec 2023 02:38:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 480AA8D00A2 for ; Thu, 14 Dec 2023 02:38:21 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 162041C0BFC for ; Thu, 14 Dec 2023 07:38:21 +0000 (UTC) X-FDA: 81564620802.24.06EE2F2 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by imf22.hostedemail.com (Postfix) with ESMTP id C5F95C000F for ; Thu, 14 Dec 2023 07:38:17 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=LGBGch3u; spf=pass (imf22.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702539498; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fh20T2gB/B6w0dTGtnuH7g/9myiyWlxtGzmDSKX8rWg=; b=ByTkcdKbV8dZC+ZkvsxsnoYLBpmANPBrsVF8mSN/OeioAoB6P/yPnnwFlDo6kLEwP8jegx m3AAlr0jmjqJR0obrZGIjq1jXHeviyZLF/4tbdgqboAwddULLoG3n4ADWUtxyrRjcdx79e Pmf17mtkNYAU5qGooxp2XdnxV/EAwSA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702539498; a=rsa-sha256; cv=none; b=eR2V00VjF9adS2Dmesa+qFuG2GLqeO2KxjINw+LDnGkhVTPfCcpx4WwXEHisAK8oUvpWEn QOgI55nDGTBD0HeAGCsB2TxtR9EjB09niFhSPYfvOnuJPbR4P5Ud0ca/JH+lcClsg4ZUzG zR5pBrEPXVadKyhbEWKagMnFVKwww7U= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=LGBGch3u; spf=pass (imf22.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702539497; x=1734075497; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=VTyAcMOb3p9TMnLFpPQVGZqQ3IoF/IW/eEzVelz5aSE=; b=LGBGch3u/EkEEHUb2MISE+BMie8tv3gt0yzIiaTLxo2gywL1EDPERoEt 2ml1I1ev1M05jr8MQV+x2SaxA8qq5klEA66D8rW5yun0YPHsFTEJqCQA7 Sf4kdAEGGuxEFdJv5oaCUhREwrZvrEaFuJECAiEsGZbJ3YCs+Urbx7AVH xhCizd7yz17XAvzJFyv9enX0UcOWzPguAkeuLf5wDEx+wrE8QBNBG6r14 b/fT9toBaTICfQJ4ew6+m5Vk0ddrPyOpJk7MfUvaRZ69pfoBSLue2Udev W1OIStQQXhqRvkSDDrQRLdNn9KJCnpWBJcU6/C5eg+4Vs22oX7LVSEv8t A==; X-IronPort-AV: E=McAfee;i="6600,9927,10923"; a="481275532" X-IronPort-AV: E=Sophos;i="6.04,274,1695711600"; d="scan'208";a="481275532" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2023 23:38:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10923"; a="723972068" X-IronPort-AV: E=Sophos;i="6.04,274,1695711600"; d="scan'208";a="723972068" Received: from llblake-mobl1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.213.191.124]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2023 23:38:13 -0800 From: Vishal Verma Date: Thu, 14 Dec 2023 00:37:56 -0700 Subject: [PATCH v5 3/4] mm/memory_hotplug: export mhp_supports_memmap_on_memory() MIME-Version: 1.0 Message-Id: <20231214-vv-dax_abi-v5-3-3f7b006960b4@intel.com> References: <20231214-vv-dax_abi-v5-0-3f7b006960b4@intel.com> In-Reply-To: <20231214-vv-dax_abi-v5-0-3f7b006960b4@intel.com> To: Dan Williams , Vishal Verma , Dave Jiang , Andrew Morton , Oscar Salvador Cc: linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, David Hildenbrand , Dave Hansen , Huang Ying , Greg Kroah-Hartman , linux-mm@kvack.org, Michal Hocko X-Mailer: b4 0.13-dev-433a8 X-Developer-Signature: v=1; a=openpgp-sha256; l=4625; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=VTyAcMOb3p9TMnLFpPQVGZqQ3IoF/IW/eEzVelz5aSE=; b=owGbwMvMwCXGf25diOft7jLG02pJDKlVGx4pb98Uu1/qmbru9H/PH6bM1J0/7UV3iMK//UUCo ZtfqC/k7ihlYRDjYpAVU2T5u+cj4zG57fk8gQmOMHNYmUCGMHBxCsBEUiMYGVbuX/Wr9FcXs9aM oDlX6jRyr1fI/1s065G+YX6fQ+ehP6sYGV4/iDWrnHaq9Xa2THW3oGnTxgemL7ds3qmhVXMi5Nu BHB4A X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Rspamd-Queue-Id: C5F95C000F X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 4j6ojmkizfcmz9jm3ubkk9z5xdc5jjiq X-HE-Tag: 1702539497-821046 X-HE-Meta: U2FsdGVkX19ehw1Tdn+SlICZ9mvcW6na2hZF9KRTSefEq/pvXS7Us2Mw1Fi1QAKZes+9sik6q+YKk2igQNz0tUdwsuaMeqjE0vVVvgnzsZgFW79doT4TWJVurw+ZaErNJjvv9PqgdFmNc6r2vPjc7iBSxAYet1F8FpyWssVc4Ox3Y492WqwT3lMcyEs1ydFbcwjzPNIb4XbbkrMBbf0Dra/DIQNO+l/vYoMFTmgES9GBydARmuIdfGIfmFtz9wLOC4DamheDDTzd1g0l9/oCc2MtR4F8HgOzKYVldUvlAfOi2AEfdNNoPzb7McIIvVEfVDHQSRbw9p92Jv/MPqraDDM2iirNrWbptNQdKYFpOMzlddAAESwnr8kOhihEC875aQVGwF5UwD1H1MgcsUgbhi8U8HfMj+u4jOTMfFKtEevDhsfwdyv05OwkHFGoNsz0NNuX6X4cew1NeR1OfbUF9JxnR7JARrJcNhpqcCtssHtBiVm+A6+urr2nPN8ZY6eFK760dNgXUHagP2uxip1xi+8nyRfs56aXEqKjlM0DEnpFrWGGHh2yzGVyaL/rJDm1L9OUQQl6uWlrWMNazXCGrI5X1UX0C4kyX8ThCZkZqNk5f2GxE3OSqiFR2xdZ3RLtLN9jtk93TNAaEI9EUhKIkFgtqrbACfkvDtXI7ZV24Zj8y8VPgruZjXHf+/QLfgODm1HCJZMEy/bzwGwtRy00Z037oIduEm0Ulpjoayyy7MdrWoyeWNYPBg/I2wLRLtvFRfBGQVeOvsm8IQsbXoQoGoN9XL/y8RtXqqo+u2FdkYNCAGbHromd1l8hjiP4yRlakYzrbdpKjdA6iDv/rwKozo6Ak8e0aADUSG7RvdBdSiZBOWT2Z6IVoMGY2dhl3mz5dAbQdJUJfp6vTp8j7RQzPE7wNQC3/Ni6jXx0oJF7PKz51Mu9xikDT0oqShQWek24f2Kh69zaMMmFIijo1Fp E+jSLbX3 5Ic+1YIlNIX6Qm9mHZqek5vPlOEBDQBT+LOW5/g5XjSXWWG1accLE9Y9/OfC3QlwLnQcbyfSynjIVl2HNWPxLNWD5/lzlMbW4d/ObMV/5ZHaRLPBR+uDMXvGzc20M5N1Ppte7l1UYzXjY1Lu4l2RXv1didMdIgJfllELTng/aLUujLxPu1iqvDTvQiR6H/+ZF9Fo3d/nmkh7EoqutMv1wNKLQVDfPDTAhm79t/1IZpyjRcdyF92Z5kDH9upizOLcv2L3Q2TQs7JhglzRk/jAgmpDYcZI9N/KqprujRUPXRs55JMbz7p6pyZzn1sP/GI9iDwK8VecSAOYdqeRdjJSbptBrS3LV2/TcS8pH 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: List-Subscribe: List-Unsubscribe: In preparation for adding sysfs ABI to toggle memmap_on_memory semantics for drivers adding memory, export the mhp_supports_memmap_on_memory() helper. This allows drivers to check if memmap_on_memory support is available before trying to request it, and display an appropriate message if it isn't available. As part of this, remove the size argument to this - with recent updates to allow memmap_on_memory for larger ranges, and the internal splitting of altmaps into respective memory blocks, the size argument is meaningless. Cc: Andrew Morton Cc: David Hildenbrand Cc: Michal Hocko Cc: Oscar Salvador Cc: Dan Williams Cc: Dave Jiang Cc: Dave Hansen Cc: Huang Ying Suggested-by: David Hildenbrand Signed-off-by: Vishal Verma Acked-by: David Hildenbrand --- include/linux/memory_hotplug.h | 6 ++++++ mm/memory_hotplug.c | 17 ++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 7d2076583494..ebc9d528f00c 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -121,6 +121,7 @@ struct mhp_params { bool mhp_range_allowed(u64 start, u64 size, bool need_mapping); struct range mhp_get_pluggable_range(bool need_mapping); +bool mhp_supports_memmap_on_memory(void); /* * Zone resizing functions @@ -262,6 +263,11 @@ static inline bool movable_node_is_enabled(void) return false; } +static bool mhp_supports_memmap_on_memory(void) +{ + return false; +} + static inline void pgdat_kswapd_lock(pg_data_t *pgdat) {} static inline void pgdat_kswapd_unlock(pg_data_t *pgdat) {} static inline void pgdat_kswapd_lock_init(pg_data_t *pgdat) {} diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 926e1cfb10e9..751664c519f7 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1325,7 +1325,7 @@ static inline bool arch_supports_memmap_on_memory(unsigned long vmemmap_size) } #endif -static bool mhp_supports_memmap_on_memory(unsigned long size) +bool mhp_supports_memmap_on_memory(void) { unsigned long vmemmap_size = memory_block_memmap_size(); unsigned long memmap_pages = memory_block_memmap_on_memory_pages(); @@ -1334,17 +1334,11 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) * Besides having arch support and the feature enabled at runtime, we * need a few more assumptions to hold true: * - * a) We span a single memory block: memory onlining/offlinin;g happens - * in memory block granularity. We don't want the vmemmap of online - * memory blocks to reside on offline memory blocks. In the future, - * we might want to support variable-sized memory blocks to make the - * feature more versatile. - * - * b) The vmemmap pages span complete PMDs: We don't want vmemmap code + * a) The vmemmap pages span complete PMDs: We don't want vmemmap code * to populate memory from the altmap for unrelated parts (i.e., * other memory blocks) * - * c) The vmemmap pages (and thereby the pages that will be exposed to + * b) The vmemmap pages (and thereby the pages that will be exposed to * the buddy) have to cover full pageblocks: memory onlining/offlining * code requires applicable ranges to be page-aligned, for example, to * set the migratetypes properly. @@ -1356,7 +1350,7 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) * altmap as an alternative source of memory, and we do not exactly * populate a single PMD. */ - if (!mhp_memmap_on_memory() || size != memory_block_size_bytes()) + if (!mhp_memmap_on_memory()) return false; /* @@ -1379,6 +1373,7 @@ static bool mhp_supports_memmap_on_memory(unsigned long size) return arch_supports_memmap_on_memory(vmemmap_size); } +EXPORT_SYMBOL_GPL(mhp_supports_memmap_on_memory); static void __ref remove_memory_blocks_and_altmaps(u64 start, u64 size) { @@ -1512,7 +1507,7 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) * Self hosted memmap array */ if ((mhp_flags & MHP_MEMMAP_ON_MEMORY) && - mhp_supports_memmap_on_memory(memory_block_size_bytes())) { + mhp_supports_memmap_on_memory()) { ret = create_altmaps_and_memory_blocks(nid, group, start, size); if (ret) goto error;