Skip to content

Commit 0a947c1

Browse files
Hannes Reineckeakpm00
authored andcommitted
drivers/base: move memory_block_add_nid() into the caller
Now the node id only needs to be set for early memory, so move memory_block_add_nid() into the caller and rename it into memory_block_add_nid_early(). This allows us to further simplify the code by dropping the 'context' argument to do_register_memory_block_under_node(). Link: https://lkml.kernel.org/r/[email protected] Suggested-by: David Hildenbrand <[email protected]> Signed-off-by: Hannes Reinecke <[email protected]> Acked-by: David Hildenbrand <[email protected]> Acked-by: Oscar Salvador <[email protected]> Reviewed-by: Donet Tom <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent b8179af commit 0a947c1

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

drivers/base/memory.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -769,21 +769,22 @@ static struct zone *early_node_zone_for_memory_block(struct memory_block *mem,
769769

770770
#ifdef CONFIG_NUMA
771771
/**
772-
* memory_block_add_nid() - Indicate that system RAM falling into this memory
773-
* block device (partially) belongs to the given node.
772+
* memory_block_add_nid_early() - Indicate that early system RAM falling into
773+
* this memory block device (partially) belongs
774+
* to the given node.
774775
* @mem: The memory block device.
775776
* @nid: The node id.
776-
* @context: The memory initialization context.
777777
*
778-
* Indicate that system RAM falling into this memory block (partially) belongs
779-
* to the given node. If the context indicates ("early") that we are adding the
780-
* node during node device subsystem initialization, this will also properly
781-
* set/adjust mem->zone based on the zone ranges of the given node.
778+
* Indicate that early system RAM falling into this memory block (partially)
779+
* belongs to the given node. This will also properly set/adjust mem->zone based
780+
* on the zone ranges of the given node.
781+
*
782+
* Memory hotplug handles this on memory block creation, where we can only have
783+
* a single nid span a memory block.
782784
*/
783-
void memory_block_add_nid(struct memory_block *mem, int nid,
784-
enum meminit_context context)
785+
void memory_block_add_nid_early(struct memory_block *mem, int nid)
785786
{
786-
if (context == MEMINIT_EARLY && mem->nid != nid) {
787+
if (mem->nid != nid) {
787788
/*
788789
* For early memory we have to determine the zone when setting
789790
* the node id and handle multiple nodes spanning a single
@@ -797,15 +798,14 @@ void memory_block_add_nid(struct memory_block *mem, int nid,
797798
mem->zone = early_node_zone_for_memory_block(mem, nid);
798799
else
799800
mem->zone = NULL;
801+
/*
802+
* If this memory block spans multiple nodes, we only indicate
803+
* the last processed node. If we span multiple nodes (not applicable
804+
* to hotplugged memory), zone == NULL will prohibit memory offlining
805+
* and consequently unplug.
806+
*/
807+
mem->nid = nid;
800808
}
801-
802-
/*
803-
* If this memory block spans multiple nodes, we only indicate
804-
* the last processed node. If we span multiple nodes (not applicable
805-
* to hotplugged memory), zone == NULL will prohibit memory offlining
806-
* and consequently unplug.
807-
*/
808-
mem->nid = nid;
809809
}
810810
#endif
811811

drivers/base/node.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -781,13 +781,10 @@ int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
781781

782782
#ifdef CONFIG_MEMORY_HOTPLUG
783783
static void do_register_memory_block_under_node(int nid,
784-
struct memory_block *mem_blk,
785-
enum meminit_context context)
784+
struct memory_block *mem_blk)
786785
{
787786
int ret;
788787

789-
memory_block_add_nid(mem_blk, nid, context);
790-
791788
ret = sysfs_create_link_nowarn(&node_devices[nid]->dev.kobj,
792789
&mem_blk->dev.kobj,
793790
kobject_name(&mem_blk->dev.kobj));
@@ -815,7 +812,7 @@ static int register_mem_block_under_node_hotplug(struct memory_block *mem_blk,
815812
{
816813
int nid = *(int *)arg;
817814

818-
do_register_memory_block_under_node(nid, mem_blk, MEMINIT_HOTPLUG);
815+
do_register_memory_block_under_node(nid, mem_blk);
819816
return 0;
820817
}
821818

@@ -855,7 +852,8 @@ static void register_memory_blocks_under_nodes(void)
855852
if (!mem)
856853
continue;
857854

858-
do_register_memory_block_under_node(nid, mem, MEMINIT_EARLY);
855+
memory_block_add_nid_early(mem, nid);
856+
do_register_memory_block_under_node(nid, mem);
859857
put_device(&mem->dev);
860858
}
861859

include/linux/memory.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ static inline unsigned long phys_to_block_id(unsigned long phys)
202202
}
203203

204204
#ifdef CONFIG_NUMA
205-
void memory_block_add_nid(struct memory_block *mem, int nid,
206-
enum meminit_context context);
205+
void memory_block_add_nid_early(struct memory_block *mem, int nid);
207206
#endif /* CONFIG_NUMA */
208207
int memory_block_advise_max_size(unsigned long size);
209208
unsigned long memory_block_advised_max_size(void);

0 commit comments

Comments
 (0)