powerpc/mm: movable hotplug memory nodes
Subsystems (5)
v2 cover powerpc/mm: movable hotplug memory nodes
These changes enable onlining memory into ZONE_MOVABLE on power, and the creation of discrete nodes of movable memory.
We provide a way to describe the extents and numa associativity of such a node in the device tree, yet still defer the memory addition to take place post-boot through hotplug.
In v1, this patchset introduced a new dt compatible id to explicitly create a memoryless node at boot. Here, things have been simplified to be applicable regardless of the status of node hotplug on power. We still intend to enable hotadding a pgdat, but that's now untangled as a separate topic.
v2:
* Use the "status" property of standard dt memory nodes instead of introducing a new "ibm,hotplug-aperture" compatible id.
* Remove the patch which explicitly creates a memoryless node. This set no longer has any bearing on whether the pgdat is created at boot or at the time of memory addition.
v1:
* http://lkml.kernel.org/r/[email protected]
Reza Arbab (3):
drivers/of: recognize status property of dt memory nodes powerpc/mm: allow memory hotplug into a memoryless node
mm: enable CONFIG_MOVABLE_NODE on powerpc
Documentation/kernel-parameters.txt | 2 +- arch/powerpc/mm/numa.c | 13 +------------ drivers/of/fdt.c | 8 ++++++++ mm/Kconfig | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-)
Signature · 7 lines
1.8.3.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 1/3 drivers/of: recognize status property of dt memory nodes
Respect the standard dt "status" property when scanning memory nodes in early_init_dt_scan_memory(), so that if the property is present and not "okay", no memory will be added.
The use case at hand is accelerator or device memory, which may be unusable until post-boot initialization of the memory link. Such a node can be described in the dt as any other, given its status is "disabled". Per the device tree specification,
"disabled"
Indicates that the device is not presently operational, but it might become operational in the future (for example, something is not plugged in, or switched off).
Once such memory is made operational, it can then be hotplugged.
--- drivers/of/fdt.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/of/fdt.c +8 -0
@@ -1022,8 +1022,10 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname, int depth, void *data) {const char *type =of_get_flat_dt_prop (node,"device_type" ,NULL ); +const char *status;const __be32 *reg, *endp;int l; +bool add_memory;/* We are scanning "memory" nodes only */ if (type ==NULL ) {
@@ -1044,6 +1046,9 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname, endp = reg + (l /sizeof (__be32)); + status =of_get_flat_dt_prop (node,"status" ,NULL ); + add_memory = !status || !strcmp (status,"okay" ); +pr_debug ("memory scan node %s, reg size %d,\n" , uname, l);while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
@@ -1057,6 +1062,9 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,pr_debug (" - %llx , %llx\n" , (unsigned long long )base, (unsigned long long )size); +if (!add_memory) +continue ; +early_init_dt_add_memory_arch (base, size); }
Signature · 1 line
1.8.3.1
Re: [PATCH v2 1/3] drivers/of: recognize status property of dt memory nodes
Quoted 37 lines · Reza Arbab
Respect the standard dt "status" property when scanning memory nodes in
early_init_dt_scan_memory(), so that if the property is present and not "okay", no memory will be added.The use case at hand is accelerator or device memory, which may be unusable until post-boot initialization of the memory link. Such a node can be described in the dt as any other, given its status is "disabled". Per the device tree specification,
"disabled"
Indicates that the device is not presently operational, but it might become operational in the future (for example, something is not plugged in, or switched off).Once such memory is made operational, it can then be hotplugged.
Signed-off-by Reza Arbab <[email protected]>--- drivers/of/fdt.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/of/fdt.c +2
-0@@ -1022,8 +1022,10 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname, int depth, void *data) {const char *type =of_get_flat_dt_prop (node,"device_type" ,NULL ); +const char *status;const __be32 *reg, *endp;int l; +bool add_memory;/* We are scanning "memory" nodes only */ if (type ==NULL ) {
drivers/of/fdt.c int __init early_init_dt_scan_memory(unsigned long node, const char *uname, · line 1050
Quoted 5 lines
drivers/of/fdt.c +2
-0@@ -1044,6 +1046,9 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname, endp = reg + (l /sizeof (__be32)); + status =of_get_flat_dt_prop (node,"status" ,NULL ); + add_memory = !status || !strcmp (status,"okay" );
Move this into it's own function to mirror the unflattened version (of_device_is_available). Also, make sure the logic is the same. IIRC, "ok" is also allowed.
drivers/of/fdt.c int __init early_init_dt_scan_memory(unsigned long node, const char *uname, · line 1066
Quoted 10 lines
drivers/of/fdt.c +3
-0+pr_debug ("memory scan node %s, reg size %d,\n" , uname, l);while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {@@ -1057,6 +1062,9 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,pr_debug (" - %llx , %llx\n" , (unsigned long long )base, (unsigned long long )size); +if (!add_memory) +continue ;
There's no point in checking this in the loop. status applies to the whole node. Just return up above.
Rob
Re: [PATCH v2 1/3] drivers/of: recognize status property of dt memory nodes
Quoted 7 lines · Rob Herring
drivers/of/fdt.c int __init early_init_dt_scan_memory(unsigned long node, const char *uname, · line 1050
Quoted 2 lines · Reza Arbab
drivers/of/fdt.c +2
-0+ status =of_get_flat_dt_prop (node,"status" ,NULL ); + add_memory = !status || !strcmp (status,"okay" );Move this into it's own function to mirror the unflattened version (
of_device_is_available). Also, make sure the logic is the same. IIRC, "ok" is also allowed.
Will do.
Quoted 9 lines
drivers/of/fdt.c int __init early_init_dt_scan_memory(unsigned long node, const char *uname, · line 1066
Quoted 6 lines
drivers/of/fdt.c +2
-0@@ -1057,6 +1062,9 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,pr_debug (" - %llx , %llx\n" , (unsigned long long )base, (unsigned long long )size); +if (!add_memory) +continue ;There's no point in checking this in the loop. status applies to the whole node. Just return up above.
I was trying to preserve that pr_debug output for these nodes, but I'm also fine with skipping it.
Thanks for your feedback! I'll spin a v3 of this patchset soon.
Signature · 7 lines
Reza Arbab -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2 1/3] drivers/of: recognize status property of dt memory nodes
In reply to Reza ArbabQuoted 9 lines · Reza Arbab
Respect the standard dt "status" property when scanning memory nodes in
early_init_dt_scan_memory(), so that if the property is present and not "okay", no memory will be added.The use case at hand is accelerator or device memory, which may be unusable until post-boot initialization of the memory link. Such a node can be described in the dt as any other, given its status is "disabled". Per the device tree specification,
Quoted 8 lines
"disabled"
Indicates that the device is not presently operational, but it might become operational in the future (for example, something is not plugged in, or switched off).Once such memory is made operational, it can then be hotplugged.
Signed-off-by Reza Arbab <[email protected]>
Makes sense, so basically a /memory@ with missing status or status = "okay" are added, others are skipped. No memblocks corresponding to those nodes are created either.
Balbir Singh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 2/3 powerpc/mm: allow memory hotplug into a memoryless node
In reply to Reza ArbabRemove the check which prevents us from hotplugging into an empty node.
This limitation has been questioned before [1], and judging by the response, there doesn't seem to be a reason we can't remove it. No issues have been found in light testing.
[1] http://lkml.kernel.org/r/CAGZKiBrmkSa1yyhbf5hwGxubcjsE5SmkSMY4tpANERMe2UG4bg@mail.gmail.com
http://lkml.kernel.org/r/[email protected]
--- arch/powerpc/mm/numa.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
arch/powerpc/mm/numa.c +1 -12
@@ -1121,7 +1121,7 @@ static int hot_add_node_scn_to_nid(unsigned long scn_addr)int hot_add_scn_to_nid (unsigned long scn_addr) {struct device_node *memory =NULL ; -int nid, found =0 ; +int nid;if (!numa_enabled || (min_common_depth <0 ))return first_online_node;
@@ -1137,17 +1137,6 @@ int hot_add_scn_to_nid(unsigned long scn_addr)if (nid <0 || !node_online (nid)) nid = first_online_node; -if (NODE_DATA (nid)->node_spanned_pages) -return nid; - -for_each_online_node (nid) { -if (NODE_DATA (nid)->node_spanned_pages) { - found =1 ; -break ; - } - } - -BUG_ON (!found);return nid; }
Signature · 7 lines
1.8.3.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2 2/3] powerpc/mm: allow memory hotplug into a memoryless node
Quoted 9 lines · Reza Arbab
Remove the check which prevents us from hotplugging into an empty node.
This limitation has been questioned before [1], and judging by the response, there doesn't seem to be a reason we can't remove it. No issues have been found in light testing.
[1] http://lkml.kernel.org/r/CAGZKiBrmkSa1yyhbf5hwGxubcjsE5SmkSMY4tpANERMe2UG4bg@mail.gmail.com
http://lkml.kernel.org/r/[email protected]
Quoted 8 lines
Signed-off-by Reza Arbab <[email protected]>Acked-by Balbir Singh <[email protected]>Cc Nathan Fontenot <[email protected]>Cc Bharata B Rao <[email protected]>--- arch/powerpc/mm/numa.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
I presume you've tested with CONFIG_NODES_SHIFT of 8 (255 nodes?)
Balbir Singh.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2 2/3] powerpc/mm: allow memory hotplug into a memoryless node
Quoted 1 line · Balbir Singh
I presume you've tested with
CONFIG_NODES_SHIFTof 8 (255 nodes?)
Oh yes, definitely.
The large number of possible nodes does not come into play here.
Signature · 1 line
Reza Arbab
PATCH v2 3/3 mm: enable CONFIG_MOVABLE_NODE on powerpc
In reply to Reza ArbabOnlining memory into ZONE_MOVABLE requires CONFIG_MOVABLE_NODE. Enable the use of this config option on PPC64 platforms.
--- Documentation/kernel-parameters.txt | 2 +- mm/Kconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/kernel-parameters.txt +1 -1
@@ -2344,7 +2344,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted. that the amount of memory usable for all allocations is not too small. - movable_node [KNL,X86] Boot-time switch to enable the effects + movable_node [KNL,X86,PPC] Boot-time switch to enable the effects of CONFIG_MOVABLE_NODE=y. See mm/Kconfig for details. MTD_Partition= [MTD]
mm/Kconfig +1 -1
@@ -153,7 +153,7 @@ config MOVABLE_NODE bool "Enable to assign a node which has only movable memory" depends on HAVE_MEMBLOCK depends on NO_BOOTMEM - depends on X86_64 + depends on X86_64 || PPC64 depends on NUMA default n help
Signature · 1 line
1.8.3.1
Re: [PATCH v2 3/3] mm: enable CONFIG_MOVABLE_NODE on powerpc
Quoted 14 lines · Reza Arbab
Onlining memory into
ZONE_MOVABLErequiresCONFIG_MOVABLE_NODE. Enable the use of this config option on PPC64 platforms.Signed-off-by Reza Arbab <[email protected]>--- Documentation/kernel-parameters.txt | 2 +- mm/Kconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)Documentation/kernel-parameters.txt +0
-0
Documentation/kernel-parameters.txt bytes respectively. Such letter suffixes can also be entirely omitted. · line 2349
Quoted 7 lines
Documentation/kernel-parameters.txt +1
-1@@ -2344,7 +2344,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted. that the amount of memory usable for all allocations is not too small. - movable_node [KNL,X86] Boot-time switch to enable the effects + movable_node [KNL,X86,PPC] Boot-time switch to enable the effects of CONFIG_MOVABLE_NODE=y. See mm/Kconfig for details.
Movable node also does.
memblock_set_bottom_up(true);
What is the impact of that. Do we need changes equivalent to that ? Also where are we marking the nodes which can be hotplugged, ie where do we do memblock_mark_hotplug() ?
Quoted 6 lines
Documentation/kernel-parameters.txt +0
-0MTD_Partition= [MTD]mm/Kconfig +0
-0
mm/Kconfig config MOVABLE_NODE · line 159
Quoted 8 lines
mm/Kconfig +1
-1@@ -153,7 +153,7 @@ config MOVABLE_NODE bool "Enable to assign a node which has only movable memory" depends on HAVE_MEMBLOCK depends on NO_BOOTMEM - depends on X86_64 + depends on X86_64 || PPC64 depends on NUMA default n help
-aneesh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2 3/3] mm: enable CONFIG_MOVABLE_NODE on powerpc
Quoted 5 lines · Aneesh Kumar K.V
Movable node also does.
memblock_set_bottom_up(true);What is the impact of that. Do we need changes equivalent to that ? Also where are we marking the nodes which can be hotplugged, ie where do we do
memblock_mark_hotplug()?
These are related to the mechanism x86 uses to create movable nodes at boot. The SRAT is parsed to mark any hotplug memory. That marking is used later when initializing ZONE_MOVABLE for each node. [1]
The bottom-up allocation is due to a timing issue [2]. There is a window where kernel memory may be allocated before the SRAT is parsed. Any bottom-up allocations done during that time will likely be in the same (nonmovable) node as the kernel image.
On power, I don't think we have a heuristic equivalent to that SRAT memory hotplug info. So, we'll be limited to dynamically adding movable nodes after boot.
1. http://events.linuxfoundation.org/sites/events/files/lcjp13_chen.pdf
2. commit 79442ed189ac ("mm/memblock.c: introduce bottom-up allocation mode")
Signature · 7 lines
Reza Arbab -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2 3/3] mm: enable CONFIG_MOVABLE_NODE on powerpc
Quoted 16 lines · Reza Arbab
Quoted 5 lines · Aneesh Kumar K.V
Movable node also does.
memblock_set_bottom_up(true);What is the impact of that. Do we need changes equivalent to that ? Also where are we marking the nodes which can be hotplugged, ie where do we do
memblock_mark_hotplug()?These are related to the mechanism x86 uses to create movable nodes at boot. The SRAT is parsed to mark any hotplug memory. That marking is used later when initializing
ZONE_MOVABLEfor each node. [1]The bottom-up allocation is due to a timing issue [2]. There is a window where kernel memory may be allocated before the SRAT is parsed. Any bottom-up allocations done during that time will likely be in the same (nonmovable) node as the kernel image.
Quoted 8 lines
On power, I don't think we have a heuristic equivalent to that SRAT memory hotplug info. So, we'll be limited to dynamically adding movable nodes after boot.
1. http://events.linuxfoundation.org/sites/events/files/lcjp13_chen.pdf
2. commit79442ed189ac("mm/memblock.c: introduce bottom-up allocation mode")
What I was checking was how will one mark a node movable in ppc64 ? I don't see ppc64 code doing the equivalent of memblock_mark_hotplug().
So when you say "Onlining memory into ZONE_MOVABLE requires CONFIG_MOVABLE_NODE" where is that restriction ?. IIUC, should_add_memory_movable() will only return ZONE_MOVABLE only if it is non empty and MOVABLE_NODE will create a ZONE_MOVABLE zone by default only if it finds a memblock marked hotpluggable. So wondering if we are not calling memblock_mark_hotplug() how is it working. Or am I missing something ?
-aneesh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2 3/3] mm: enable CONFIG_MOVABLE_NODE on powerpc
Quoted 2 lines · Aneesh Kumar K.V
What I was checking was how will one mark a node movable in ppc64 ? I don't see ppc64 code doing the equivalent of
memblock_mark_hotplug().
Post boot, the marking mechanism is not necessary. You can create a movable node by putting all of the node's memory into ZONE_MOVABLE during the hotplug.
Quoted 7 lines
So when you say "Onlining memory into
ZONE_MOVABLErequiresCONFIG_MOVABLE_NODE" where is that restriction ?. IIUC,should_add_memory_movable()will only returnZONE_MOVABLEonly if it is non empty andMOVABLE_NODEwill create aZONE_MOVABLEzone by default only if it finds a memblock marked hotpluggable. So wondering if we are not callingmemblock_mark_hotplug()how is it working. Or am I missing something ?
You are looking at the addition step of hotplug. You're correct there, the memory is added to the default zone, not ZONE_MOVABLE. The transition to ZONE_MOVABLE takes place during the onlining step. In online_pages():
zone = move_pfn_range(zone_shift, pfn, pfn + nr_pages);
The reason we need CONFIG_MOVABLE_NODE is right before that:
if ((zone_idx(zone) > ZONE_NORMAL || online_type == MMOP_ONLINE_MOVABLE) && !can_online_high_movable(zone)) return -EINVAL;
where can_online_high_movable() is defined like this:
#ifdef CONFIG_MOVABLE_NODE
/*
* When CONFIG_MOVABLE_NODE, we permit onlining of a node which doesn't have
* normal memory.
*/
static bool can_online_high_movable(struct zone *zone)
{
return true;
}
#else /* CONFIG_MOVABLE_NODE */
/* ensure every online node has NORMAL memory */
static bool can_online_high_movable(struct zone *zone)
{
return node_state(zone_to_nid(zone), N_NORMAL_MEMORY);
}
#endif /* CONFIG_MOVABLE_NODE */To be more clear, I can change the commit log to say "Onlining all of a node's memory into ZONE_MOVABLE requires CONFIG_MOVABLE_NODE".
Signature · 1 line
Reza Arbab
Re: [PATCH v2 3/3] mm: enable CONFIG_MOVABLE_NODE on powerpc
Quoted 21 lines · Reza Arbab
Quoted 2 lines · Aneesh Kumar K.V
What I was checking was how will one mark a node movable in ppc64 ? I don't see ppc64 code doing the equivalent of
memblock_mark_hotplug().Post boot, the marking mechanism is not necessary. You can create a movable node by putting all of the node's memory into
ZONE_MOVABLEduring the hotplug.Quoted 7 lines
So when you say "Onlining memory into
ZONE_MOVABLErequiresCONFIG_MOVABLE_NODE" where is that restriction ?. IIUC,should_add_memory_movable()will only returnZONE_MOVABLEonly if it is non empty andMOVABLE_NODEwill create aZONE_MOVABLEzone by default only if it finds a memblock marked hotpluggable. So wondering if we are not callingmemblock_mark_hotplug()how is it working. Or am I missing something ?You are looking at the addition step of hotplug. You're correct there, the memory is added to the default zone, not
ZONE_MOVABLE. The transition toZONE_MOVABLEtakes place during the onlining step. Inonline_pages():
Quoted 9 lines
zone = move_pfn_range(zone_shift, pfn, pfn + nr_pages);The reason we need
CONFIG_MOVABLE_NODEis right before that:if ((zone_idx(zone) > ZONE_NORMAL || online_type == MMOP_ONLINE_MOVABLE) && !can_online_high_movable(zone)) return -EINVAL;
So we are looking at two step online process here. The above explained the details nicely. Can you capture these details in the commit message. ie, to say that when using 'echo online-movable > state' we allow the move from normal to movable only if movable node is set. Also you may want to mention that we still don't support the auto-online to movable.
Quoted 19 lines
where
can_online_high_movable()is defined like this:#ifdef CONFIG_MOVABLE_NODE /* * When CONFIG_MOVABLE_NODE, we permit onlining of a node which doesn't have * normal memory. */ static bool can_online_high_movable(struct zone *zone) { return true; } #else /* CONFIG_MOVABLE_NODE */ /* ensure every online node has NORMAL memory */ static bool can_online_high_movable(struct zone *zone) { return node_state(zone_to_nid(zone), N_NORMAL_MEMORY); } #endif /* CONFIG_MOVABLE_NODE */
Quoted 5 lines
To be more clear, I can change the commit log to say "Onlining all of a node's memory into
ZONE_MOVABLErequiresCONFIG_MOVABLE_NODE".Signature · 1 line
Reza Arbab
-aneesh
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 3/3] mm: enable CONFIG_MOVABLE_NODE on powerpc
Quoted 5 lines · Aneesh Kumar K.V
So we are looking at two step online process here. The above explained the details nicely. Can you capture these details in the commit message. ie, to say that when using 'echo online-movable > state' we allow the move from normal to movable only if movable node is set. Also you may want to mention that we still don't support the auto-online to movable.
Sure, no problem. I'll use a more verbose commit message in v3.
Signature · 7 lines
Reza Arbab -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>