Skip to content

Commit 64f47c3

Browse files
committed
mm/memory_hotplug: export mhp_supports_memmap_on_memory()
JIRA: https://issues.redhat.com/browse/RHEL-23824 Conflicts: Contextual difference due to missing commit c5f1e2d ("mm/memory_hotplug: introduce MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE notifiers"). commit 42d9358 Author: Vishal Verma <vishal.l.verma@intel.com> Date: Wed Jan 24 12:03:49 2024 -0800 mm/memory_hotplug: export mhp_supports_memmap_on_memory() 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. [akpm@linux-foundation.org: fix build] Link: https://lkml.kernel.org/r/20240124-vv-dax_abi-v7-4-20d16cb8d23d@intel.com Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Acked-by: David Hildenbrand <david@redhat.com> Suggested-by: David Hildenbrand <david@redhat.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Li Zhijian <lizhijian@fujitsu.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Dave Jiang <dave.jiang@intel.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Huang Ying <ying.huang@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
1 parent 3668a22 commit 64f47c3

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

include/linux/memory_hotplug.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ struct mhp_params {
121121

122122
bool mhp_range_allowed(u64 start, u64 size, bool need_mapping);
123123
struct range mhp_get_pluggable_range(bool need_mapping);
124+
bool mhp_supports_memmap_on_memory(void);
124125

125126
/*
126127
* Zone resizing functions
@@ -262,6 +263,11 @@ static inline bool movable_node_is_enabled(void)
262263
return false;
263264
}
264265

266+
static inline bool mhp_supports_memmap_on_memory(void)
267+
{
268+
return false;
269+
}
270+
265271
static inline void pgdat_kswapd_lock(pg_data_t *pgdat) {}
266272
static inline void pgdat_kswapd_unlock(pg_data_t *pgdat) {}
267273
static inline void pgdat_kswapd_lock_init(pg_data_t *pgdat) {}

mm/memory_hotplug.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ static inline bool arch_supports_memmap_on_memory(unsigned long vmemmap_size)
13611361
}
13621362
#endif
13631363

1364-
static bool mhp_supports_memmap_on_memory(unsigned long size)
1364+
bool mhp_supports_memmap_on_memory(void)
13651365
{
13661366
unsigned long vmemmap_size = memory_block_memmap_size();
13671367
unsigned long memmap_pages = memory_block_memmap_on_memory_pages();
@@ -1370,17 +1370,11 @@ static bool mhp_supports_memmap_on_memory(unsigned long size)
13701370
* Besides having arch support and the feature enabled at runtime, we
13711371
* need a few more assumptions to hold true:
13721372
*
1373-
* a) We span a single memory block: memory onlining/offlinin;g happens
1374-
* in memory block granularity. We don't want the vmemmap of online
1375-
* memory blocks to reside on offline memory blocks. In the future,
1376-
* we might want to support variable-sized memory blocks to make the
1377-
* feature more versatile.
1378-
*
1379-
* b) The vmemmap pages span complete PMDs: We don't want vmemmap code
1373+
* a) The vmemmap pages span complete PMDs: We don't want vmemmap code
13801374
* to populate memory from the altmap for unrelated parts (i.e.,
13811375
* other memory blocks)
13821376
*
1383-
* c) The vmemmap pages (and thereby the pages that will be exposed to
1377+
* b) The vmemmap pages (and thereby the pages that will be exposed to
13841378
* the buddy) have to cover full pageblocks: memory onlining/offlining
13851379
* code requires applicable ranges to be page-aligned, for example, to
13861380
* set the migratetypes properly.
@@ -1392,7 +1386,7 @@ static bool mhp_supports_memmap_on_memory(unsigned long size)
13921386
* altmap as an alternative source of memory, and we do not exactly
13931387
* populate a single PMD.
13941388
*/
1395-
if (!mhp_memmap_on_memory() || size != memory_block_size_bytes())
1389+
if (!mhp_memmap_on_memory())
13961390
return false;
13971391

13981392
/*
@@ -1415,6 +1409,7 @@ static bool mhp_supports_memmap_on_memory(unsigned long size)
14151409

14161410
return arch_supports_memmap_on_memory(vmemmap_size);
14171411
}
1412+
EXPORT_SYMBOL_GPL(mhp_supports_memmap_on_memory);
14181413

14191414
static void __ref remove_memory_blocks_and_altmaps(u64 start, u64 size)
14201415
{
@@ -1548,7 +1543,7 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)
15481543
* Self hosted memmap array
15491544
*/
15501545
if ((mhp_flags & MHP_MEMMAP_ON_MEMORY) &&
1551-
mhp_supports_memmap_on_memory(memory_block_size_bytes())) {
1546+
mhp_supports_memmap_on_memory()) {
15521547
ret = create_altmaps_and_memory_blocks(nid, group, start, size);
15531548
if (ret)
15541549
goto error;

0 commit comments

Comments
 (0)