From mboxrd@z Thu Jan 1 00:00:00 1970 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 85349C47DDF for ; Wed, 24 Jan 2024 20:04:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 631856B0089; Wed, 24 Jan 2024 15:04:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DEEA6B008A; Wed, 24 Jan 2024 15:04:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 483D36B008C; Wed, 24 Jan 2024 15:04:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 348E26B0089 for ; Wed, 24 Jan 2024 15:04:31 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 0762CA0C79 for ; Wed, 24 Jan 2024 20:04:29 +0000 (UTC) X-FDA: 81715281900.20.57E70DC Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by imf12.hostedemail.com (Postfix) with ESMTP id C225240003 for ; Wed, 24 Jan 2024 20:04:26 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=gSWo6nAC; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf12.hostedemail.com: domain of vishal.l.verma@intel.com designates 198.175.65.15 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706126667; 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=a6zYS5tHYyD516jLQ0b49vxvCgIzBSqergsiT+dJduA=; b=ZI6qe9sLXq4sJLdJisrf9c5kEg6xehWmFxd2sTtPqzHQFLMKST24Jyo0TqVB+1j6ciB4fy gfqzaBlYuWuccU4En/WGyDB44kka3WozLVs+k/IeqT9ISCja6bEJChUC5d3ZpT3kOjz4ZC rO7POpsiO5y1ga2EqLMbULxv8Sbz0cc= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=gSWo6nAC; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf12.hostedemail.com: domain of vishal.l.verma@intel.com designates 198.175.65.15 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706126667; a=rsa-sha256; cv=none; b=43danTPzaV5Sy9+oDfhB7x3156xBJKgxj4aFQZyPYSAJ2qmHRGzlKCtB8mnR5fTBj6IhRU FDQxlhXwaOKv+diBf7m1FBUiDFQN3xkC6GNMjx0xd474ioENX7Ix67BeuIQvlDi8GtgFw7 zX0IIawRLY5XeeiU21/CyHJIYUIsh/8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706126667; x=1737662667; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=Orl+mZtfo3P92OAi6zjw0XQv4aRvq83sE++FPaqZvSw=; b=gSWo6nACemiOSOltcdG1U02I3JRFe56ZrRV3GBN7cNOF7b4SsrUHeFGk fBNDHKY5/+VHyPeIg0zu2Y9xEinbLwzH3guirQzm5ZjFbFVBRW1JM2vvV MGz46Vdyoik65/AzCDsgYx4PsEZNpBf4pxyNj8apcvKUg4eoOp9nM6+4O ew/9m80fmiENv5pobikSE968uQunrgMI7U+eMSic4fOmfzS/n6da8J+If K7t/Cg7N5J+tNW6rmwj46a0ki6M/EkAk+8NPSCvmZSj6W+peomu/oRoe8 yZIYXp/HeTELZasOAzih7ozYvdC0WEqTTmfA4cMA5TXU4GAKLf5ambFx/ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="1836122" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="1836122" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2024 12:04:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="1117735142" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="1117735142" Received: from vverma7-mobl3.amr.corp.intel.com (HELO [10.0.0.223]) ([10.251.14.61]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2024 12:04:23 -0800 From: Vishal Verma Date: Wed, 24 Jan 2024 12:03:49 -0800 Subject: [PATCH v7 4/5] mm/memory_hotplug: export mhp_supports_memmap_on_memory() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240124-vv-dax_abi-v7-4-20d16cb8d23d@intel.com> References: <20240124-vv-dax_abi-v7-0-20d16cb8d23d@intel.com> In-Reply-To: <20240124-vv-dax_abi-v7-0-20d16cb8d23d@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 , Matthew Wilcox , linux-mm@kvack.org, Michal Hocko X-Mailer: b4 0.13-dev-a684c X-Developer-Signature: v=1; a=openpgp-sha256; l=4673; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=Orl+mZtfo3P92OAi6zjw0XQv4aRvq83sE++FPaqZvSw=; b=owGbwMvMwCXGf25diOft7jLG02pJDKkbc523Ta9vOi09a3bGqYv8n6JOx6T18S1boOA25RJ7L P+fjzrKHaUsDGJcDLJiiix/93xkPCa3PZ8nMMERZg4rE8gQBi5OAZjItkpGhoPKq2Z5afNceV/D XRrhep3dROdqhKT6hrTy71VRU+ReCTIybOX1yTxzjmHHz5CFdRe+Lru4J7D9BkOBr/zmL9+PJae u5AIA X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C225240003 X-Stat-Signature: tgio8wqdtixh6e89nqd8qouh9n35mmq6 X-HE-Tag: 1706126666-245908 X-HE-Meta: U2FsdGVkX19PufaVKx3IbGJIQp7ganrmxzRCya3XP4Q23VfQk3vbIIWGs06+/h05tHQNPOxj9Vxeq9vYcFcNCvGqslVYJgzsgoAfV+8BPCoGvY1EtGhxYmyWjhOKRJaQy532pWGf8G+BUZijCKR5RlRZ6KoLnQJnPlTT51xrLuF2tgsjgkbvrMJ0NqY4HNR1FduBSUOW0nOwhtk0SrtFgu53ycPsDriRJb8EM1BYs3Ede9osULSSzLx+OQZUQ1BD1ava0HjV9bzszfVH3CoEqAy4usu0uNWta8fAFQSY3qBHHkF4+QaAFTEirvPr0veSS/bO4n5evdhJPRFgbXBAuNRQgrSvfHbk/5NexjpfzYoelIXsE52OHPg/B1ZjUhkYy6CGiFAZkQQS/9Y/1EQrIw0yFGDiItkngrz+41iHlGp7IzWnTXSIQ03hH1TXNcZWdfRBbNZcrIgkm0RrLirMqUyxEfJDHrx9mmtFWS9F8T0uPV9tIp4Y8RkpPBhbja96h2Cfdf0kzGivqt4JFBAGHknzMU7SrTy+4LmQ3dC3b7Cj6M8oIG0AnAy7rdevPIitmgjfGiUhfKcgy4tiCLGROEJuy4MKxtf+FGAzQuKF+8c7UFCAsmCNWp7v37ms0xULUaNBzjysP2uqDXRYuUxHMXkfKNFJJN4EUuOXpiULb4i+wv5MrJLwD4C8OaADndkyIYkWcBDPfZ6tHIflO3uy3/Fgze27sdiJuj1MEzh02xqmAbssWhtA2YbNIHBNg+GBBGa5g61A/WfT4+Btj80N/KM6+wJH1X7javrUGLGzMVsmif72NyOb66URCNl2oEvR47unKJSBtfTT+fKwZSHH5k6CG0bpZPjTVGquJ2kG3a6niS1PWZW43DWTYzmty1CXmsTMEWBQ5Sm4B0V294nvnlTn9j9J5Z0SZF97mI7KDmAcFBeUyrrfjNS8hW2/Lfbs5C+xvl2mT8VNOqY2cyZ HadApLMe 7NEB2aodaSBvYBfpP4OLLpDKpw27ryQk7au7LDixifthH03NSTxk3KuOp3ROmz3mUtNlrlIkOC1o5WRCVX6nJFEk+VCsyMb/oOSz9c57F2hZHirmEWDRE0/EcYj+mOFrPkvp3sxbV+bkEqWlspSl2tAtvTHVKbotLrangYYOIeUwRYrdWnooGZY7SyIoSj6H9+vWDkX+5CtcDlSUl/JeTDOctVFV1vyV82CQoOSvpyt83S4qfCLLeSDcboa6cP3l29a2nTq+7GZv4JEP2px1w6EkkGTU3GsUJZ6FZub0IzcwtT4xUZDB7I78+z2VKwCX43SSAJX+9JIrcem//tZ/kG39L4KJhl70D7qkuyXVuf84+PqE= 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 Acked-by: David Hildenbrand Signed-off-by: Vishal Verma --- 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 21890994c1d3..065fb4804f1b 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1328,7 +1328,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(); @@ -1337,17 +1337,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. @@ -1359,7 +1353,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; /* @@ -1382,6 +1376,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) { @@ -1515,7 +1510,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; -- 2.43.0