Skip to content

Commit cc65155

Browse files
davidhildenbrandtorvalds
authored andcommitted
drivers/base/node: rename link_mem_sections() to register_memory_block_under_node()
Patch series "drivers/base/memory: determine and store zone for single-zone memory blocks", v2. I remember talking to Michal in the past about removing test_pages_in_a_zone(), which we use for: * verifying that a memory block we intend to offline is really only managed by a single zone. We don't support offlining of memory blocks that are managed by multiple zones (e.g., multiple nodes, DMA and DMA32) * exposing that zone to user space via /sys/devices/system/memory/memory*/valid_zones Now that I identified some more cases where test_pages_in_a_zone() might go wrong, and we received an UBSAN report (see patch #3), let's get rid of this PFN walker. So instead of detecting the zone at runtime with test_pages_in_a_zone() by scanning the memmap, let's determine and remember for each memory block if it's managed by a single zone. The stored zone can then be used for the above two cases, avoiding a manual lookup using test_pages_in_a_zone(). This avoids eventually stumbling over uninitialized memmaps in corner cases, especially when ZONE_DEVICE ranges partly fall into memory block (that are responsible for managing System RAM). Handling memory onlining is easy, because we online to exactly one zone. Handling boot memory is more tricky, because we want to avoid scanning all zones of all nodes to detect possible zones that overlap with the physical memory region of interest. Fortunately, we already have code that determines the applicable nodes for a memory block, to create sysfs links -- we'll hook into that. Patch #1 is a simple cleanup I had laying around for a longer time. Patch #2 contains the main logic to remove test_pages_in_a_zone() and further details. [1] https://lkml.kernel.org/r/[email protected] [2] https://lkml.kernel.org/r/[email protected] This patch (of 2): Let's adjust the stale terminology, making it match unregister_memory_block_under_nodes() and do_register_memory_block_under_node(). We're dealing with memory block devices, which span 1..X memory sections. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: David Hildenbrand <[email protected]> Acked-by: Oscar Salvador <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Cc: Rafael Parra <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 36ba30b commit cc65155

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

drivers/base/node.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,8 +892,9 @@ void unregister_memory_block_under_nodes(struct memory_block *mem_blk)
892892
kobject_name(&node_devices[mem_blk->nid]->dev.kobj));
893893
}
894894

895-
void link_mem_sections(int nid, unsigned long start_pfn, unsigned long end_pfn,
896-
enum meminit_context context)
895+
void register_memory_blocks_under_node(int nid, unsigned long start_pfn,
896+
unsigned long end_pfn,
897+
enum meminit_context context)
897898
{
898899
walk_memory_blocks_func_t func;
899900

include/linux/node.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ extern struct node *node_devices[];
9999
typedef void (*node_registration_func_t)(struct node *);
100100

101101
#if defined(CONFIG_MEMORY_HOTPLUG) && defined(CONFIG_NUMA)
102-
void link_mem_sections(int nid, unsigned long start_pfn,
103-
unsigned long end_pfn,
104-
enum meminit_context context);
102+
void register_memory_blocks_under_node(int nid, unsigned long start_pfn,
103+
unsigned long end_pfn,
104+
enum meminit_context context);
105105
#else
106-
static inline void link_mem_sections(int nid, unsigned long start_pfn,
107-
unsigned long end_pfn,
108-
enum meminit_context context)
106+
static inline void register_memory_blocks_under_node(int nid, unsigned long start_pfn,
107+
unsigned long end_pfn,
108+
enum meminit_context context)
109109
{
110110
}
111111
#endif
@@ -129,8 +129,8 @@ static inline int register_one_node(int nid)
129129
error = __register_one_node(nid);
130130
if (error)
131131
return error;
132-
/* link memory sections under this node */
133-
link_mem_sections(nid, start_pfn, end_pfn, MEMINIT_EARLY);
132+
register_memory_blocks_under_node(nid, start_pfn, end_pfn,
133+
MEMINIT_EARLY);
134134
}
135135

136136
return error;

mm/memory_hotplug.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,9 +1383,9 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)
13831383
BUG_ON(ret);
13841384
}
13851385

1386-
/* link memory sections under this node.*/
1387-
link_mem_sections(nid, PFN_DOWN(start), PFN_UP(start + size - 1),
1388-
MEMINIT_HOTPLUG);
1386+
register_memory_blocks_under_node(nid, PFN_DOWN(start),
1387+
PFN_UP(start + size - 1),
1388+
MEMINIT_HOTPLUG);
13891389

13901390
/* create new memmap entry */
13911391
if (!strcmp(res->name, "System RAM"))

0 commit comments

Comments
 (0)