powerpc/pseries: Auto-online hotplugged memory
v2 cover powerpc/pseries: Auto-online hotplugged memory
Recent updates to the core mm code allow for auto-onlining of added memory, commit id 31bc3858ea3. This update to the pseries hotplug memory code takes advantage of this by setting the config option CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=y so that we online added memory by default, this maintains the current functionality, and removes the code that explicitly onlines added memory.
Additionally the call to memblock_add() is removed, this is already done in memory_add().
Changes from v1:
- The memhp_auto_online variable is no longer explicitly set.
- The patch is split into two patches
1/2 - Update to us auto-onlining capabilities 2/2 - Remove the call to memblock_add
-Nathan
--- configs/pseries_defconfig | 1 platforms/pseries/hotplug-memory.c | 51 +++++++------------------------------ 2 files changed, 11 insertions(+), 41 deletions(-)
PATCH v2 1/2 powerpc/pseries: Auto-online hotplugged memory
A recent update (commit id 31bc3858ea3) allows for automatically onlining memory that is added. This patch sets the config option CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=y for pseries and updates the pseries memory hotplug code so that DLPAR added memory can be automatically onlined instead of explicitly onlining the memory.
--- arch/powerpc/configs/pseries_defconfig | 1 + arch/powerpc/platforms/pseries/hotplug-memory.c | 14 -------------- 2 files changed, 1 insertion(+), 14 deletions(-)
arch/powerpc/configs/pseries_defconfig +1 -0
@@ -53,6 +53,7 @@ CONFIG_KEXEC=y CONFIG_IRQ_ALL_CPUS=y CONFIG_MEMORY_HOTPLUG=y CONFIG_MEMORY_HOTREMOVE=y +CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=y CONFIG_KSM=y CONFIG_TRANSPARENT_HUGEPAGE=y CONFIG_PPC_64K_PAGES=y
arch/powerpc/platforms/pseries/hotplug-memory.c +0 -14
@@ -535,7 +535,6 @@ static int dlpar_memory_remove_by_index(u32 drc_index, struct property *prop)static int dlpar_add_lmb_memory (struct of_drconf_cell *lmb) { -struct memory_block *mem_block;unsigned long block_sz;int nid, rc;
@@ -556,19 +555,6 @@ static int dlpar_add_lmb_memory(struct of_drconf_cell *lmb)return rc; } - mem_block =lmb_to_memblock (lmb); -if (!mem_block) { -remove_memory (nid, lmb->base_addr, block_sz); -return -EINVAL ; - } - - rc =device_online (&mem_block->dev); -put_device (&mem_block->dev); -if (rc) { -remove_memory (nid, lmb->base_addr, block_sz); -return rc; - } - lmb->flags |=DRCONF_MEM_ASSIGNED ;return 0 ; }
Michael Ellerman
reviewerQuoted 7 lines · Nathan Fontenot
A recent update (commit id
31bc3858ea3) allows for automatically onlining memory that is added. This patch sets the config optionCONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=yfor pseries and updates the pseries memory hotplug code so that DLPAR added memory can be automatically onlined instead of explicitly onlining the memory.Signed-off-by Nathan Fontenot <[email protected]>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/ec999072442ad531cccbecbd6d
cheers
PATCH v2 2/2 powerpc/pseries: Remove call to memblock_add()
In reply to Nathan FontenotThe call to memblock_add is not needed, this is already done by memory_add(). This patch removes this call which shrinks dlpar_add_lmb_memory() enough that it can be merged into dlpar_add_lmb().
--- arch/powerpc/platforms/pseries/hotplug-memory.c | 37 ++++++----------------- 1 file changed, 10 insertions(+), 27 deletions(-)
arch/powerpc/platforms/pseries/hotplug-memory.c +10 -27
@@ -533,36 +533,11 @@ static int dlpar_memory_remove_by_index(u32 drc_index, struct property *prop)#endif /* CONFIG_MEMORY_HOTREMOVE */ -static int dlpar_add_lmb_memory (struct of_drconf_cell *lmb) +static int dlpar_add_lmb (struct of_drconf_cell *lmb) {unsigned long block_sz;int nid, rc; - block_sz =memory_block_size_bytes (); - -/* Find the node id for this address */ - nid =memory_add_physaddr_to_nid (lmb->base_addr); - -/* Add the memory */ - rc =add_memory (nid, lmb->base_addr, block_sz); -if (rc) -return rc; - -/* Register this block of memory */ - rc =memblock_add (lmb->base_addr, block_sz); -if (rc) { -remove_memory (nid, lmb->base_addr, block_sz); -return rc; - } - - lmb->flags |=DRCONF_MEM_ASSIGNED ; -return 0 ; -} - -static int dlpar_add_lmb (struct of_drconf_cell *lmb) -{ -int rc; -if (lmb->flags &DRCONF_MEM_ASSIGNED )return -EINVAL ;
@@ -578,10 +553,18 @@ static int dlpar_add_lmb(struct of_drconf_cell *lmb)return rc; } - rc =dlpar_add_lmb_memory (lmb); + block_sz =memory_block_size_bytes (); + +/* Find the node id for this address */ + nid =memory_add_physaddr_to_nid (lmb->base_addr); + +/* Add the memory */ + rc =add_memory (nid, lmb->base_addr, block_sz);if (rc) {dlpar_remove_device_tree_lmb (lmb);dlpar_release_drc (lmb->drc_index); + }else { + lmb->flags |=DRCONF_MEM_ASSIGNED ; }return rc;