Show memory section to node relationship in sysfs
Subsystems (4)
PATCH 1/1 Show memory section to node relationship in sysfs
Show memory section to node relationship in sysfs
Add /sys/devices/system/memory/memoryX/node files to show the node on which each memory section resides.
--- Documentation/memory-hotplug.txt | 1 - drivers/base/memory.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-)
drivers/base/memory.c +20 -0
@@ -150,6 +150,22 @@return len; } +/* +* node on which memory section resides +*/ +static ssize_t show_mem_node (struct sys_device *dev, +struct sysdev_attribute *attr,char *buf) +{ +unsigned long start_pfn; +int ret; +struct memory_block *mem = + container_of(dev, struct memory_block, sysdev); + + start_pfn =section_nr_to_pfn (mem->phys_index); + ret =pfn_to_nid (start_pfn); +return sprintf (buf,"%d\n" , ret); +} +int memory_notify (unsigned long val,void *v) {return blocking_notifier_call_chain (&memory_chain, val, v);
@@ -278,6 +294,7 @@ static SYSDEV_ATTR(state, 0644, show_mem_state, store_mem_state); static SYSDEV_ATTR(phys_device, 0444, show_phys_device, NULL); static SYSDEV_ATTR(removable, 0444, show_mem_removable, NULL); +static SYSDEV_ATTR(node, 0444, show_mem_node, NULL);#define mem_create_simple_file (mem, attr_name) \ sysdev_create_file(&mem->sysdev, &attr_##attr_name)
@@ -368,6 +385,8 @@ ret =mem_create_simple_file (mem, phys_device);if (!ret) ret =mem_create_simple_file (mem, removable); +if (!ret) + ret =mem_create_simple_file (mem, node);return ret; }
@@ -413,6 +432,7 @@mem_remove_simple_file (mem, state);mem_remove_simple_file (mem, phys_device);mem_remove_simple_file (mem, removable); +mem_remove_simple_file (mem, node);unregister_memory (mem, section);return 0 ;
Documentation/memory-hotplug.txt +0 -1
@@ -365,7 +365,6 @@ - allowing memory hot-add to ZONE_MOVABLE. maybe we need some switch like sysctl or new control file. - showing memory section and physical device relationship. - - showing memory section and node relationship (maybe good for NUMA) - showing memory section is under ZONE_MOVABLE or not - test and make it better memory offlining. - support HugeTLB page migration and offlining.
--
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>
Quoted 4 lines · Gary Hade
Show memory section to node relationship in sysfs
Add
/sys/devices/system/memory/memoryX/nodefiles to show the node on which each memory section resides.
I think this patch needs an additional bit for Documentation/ABI (might be other parts of /sys/devices/system/memory missing from there).
Also, I wonder if it might not make more sense to use a symlink here? That is
/sys/devices/system/memory/memoryX/node -> /sys/devices/system/node/nodeY ?
And then we could, potentially, have symlinks returning from the node side to indicate all memory sections on that node (might be handy for node offline?):
/sys/devices/system/node/nodeX/memory1 -> /sys/devices/system/memory/memoryY /sys/devices/system/node/nodeX/memory2 -> /sys/devices/system/memory/memoryZ
Dunno, the latter probably should be a separate patch, but does seem more like the sysfs behavior (and the number (node or memory section) should be easily obtained from the symlinks via readlink, as opposed to cat with the current patch?).
Thanks,
Nish
--
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>
Quoted 4 lines · Nish Aravamudan
Quoted 2 lines · Gary Hade
Show memory section to node relationship in sysfs
Quoted 9 lines
Quoted 3 lines
Add
/sys/devices/system/memory/memoryX/nodefiles to show the node on which each memory section resides.I think this patch needs an additional bit for
Documentation/ABI(might be other parts of/sys/devices/system/memorymissing from there).
Yes. I added Documentation/ABI for "removable". We should update it for this too.
Quoted 5 lines
Also, I wonder if it might not make more sense to use a symlink here? That is
/sys/devices/system/memory/memoryX/node->/sys/devices/system/node/nodeY?
Makes sense. Since we already have "node/nodeY", we might as well make use of it instead of duplicating it.
Quoted 8 lines
And then we could, potentially, have symlinks returning from the node side to indicate all memory sections on that node (might be handy for node offline?):
/sys/devices/system/node/nodeX/memory1->/sys/devices/system/memory/memoryY/sys/devices/system/node/nodeX/memory2->/sys/devices/system/memory/memoryZ
I don't think we need both. Gary wants to do "node removal/offline" and wants to find out all the memory sections that belong to nodeX. May be this is a a better interface. This way, we can quickly get through all the memory sections without looking at all the sections. Gary ?
Quoted 8 lines
Dunno, the latter probably should be a separate patch, but does seem more like the sysfs behavior (and the number (node or memory section) should be easily obtained from the symlinks via readlink, as opposed to cat with the current patch?).
Thanks,
Nish
Thanks,
Badari
--
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>
Quoted 32 lines · Badari Pulavarty
Quoted 4 lines · Nish Aravamudan
Quoted 2 lines · Gary Hade
Show memory section to node relationship in sysfs
Quoted 9 lines
Quoted 3 lines
Add
/sys/devices/system/memory/memoryX/nodefiles to show the node on which each memory section resides.I think this patch needs an additional bit for
Documentation/ABI(might be other parts of/sys/devices/system/memorymissing from there).Yes. I added
Documentation/ABIfor "removable". We should update it for this too.Quoted 5 lines
Also, I wonder if it might not make more sense to use a symlink here? That is
/sys/devices/system/memory/memoryX/node->/sys/devices/system/node/nodeY?Makes sense. Since we already have "node/nodeY", we might as well make use of it
instead of duplicating it.Quoted 8 lines
And then we could, potentially, have symlinks returning from the node side to indicate all memory sections on that node (might be handy for node offline?):
/sys/devices/system/node/nodeX/memory1->/sys/devices/system/memory/memoryY/sys/devices/system/node/nodeX/memory2->/sys/devices/system/memory/memoryZ
Quoted 5 lines
I don't think we need both. Gary wants to do "node removal/offline" and wants
to find out all the memory sections that belong to nodeX. May be this is a a better interface. This way, we can quickly get through all the memory sections without looking at all the sections. Gary ?
Yes, either way would work fine but I think symlinks in the /sys/devices/system/node/nodeX directories would make the
script or program driven memory section offlining complete
a little more quickly. However, if we do this we might want to make the symlink names to match the memory section directory names.
/sys/devices/system/node/nodeX/memoryY -> /sys/devices/system/memory/memoryY /sys/devices/system/node/nodeX/memoryZ -> /sys/devices/system/memory/memoryZ
Do you or others have a preference?
Thanks,
Gary
Signature · 12 lines
Gary Hade System x Enablement IBM Linux Technology Center 503-578-4503 IBM T/L: 775-4503 [email protected] http://www.ibm.com/linux/ltc -- 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>
Quoted 39 lines · Badari Pulavarty
Quoted 32 lines
Quoted 4 lines · Nish Aravamudan
Quoted 2 lines · Gary Hade
Show memory section to node relationship in sysfs
Quoted 9 lines
Quoted 3 lines
Add
/sys/devices/system/memory/memoryX/nodefiles to show the node on which each memory section resides.I think this patch needs an additional bit for
Documentation/ABI(might be other parts of/sys/devices/system/memorymissing from there).Yes. I added
Documentation/ABIfor "removable". We should update it for this too.Quoted 5 lines
Also, I wonder if it might not make more sense to use a symlink here? That is
/sys/devices/system/memory/memoryX/node->/sys/devices/system/node/nodeY?Makes sense. Since we already have "node/nodeY", we might as well make use of it
instead of duplicating it.Quoted 8 lines
And then we could, potentially, have symlinks returning from the node side to indicate all memory sections on that node (might be handy for node offline?):
/sys/devices/system/node/nodeX/memory1->/sys/devices/system/memory/memoryY/sys/devices/system/node/nodeX/memory2->/sys/devices/system/memory/memoryZQuoted 5 lines
I don't think we need both. Gary wants to do "node removal/offline" and wants
to find out all the memory sections that belong to nodeX. May be this is a a better interface. This way, we can quickly get through all the memory sections without looking at all the sections. Gary ?
Quoted 7 lines
Yes, either way would work fine but I think symlinks in the
/sys/devices/system/node/nodeXdirectories would make the
script or program driven memory section offlining complete
a little more quickly. However, if we do this we might want to make the symlink names to match the memory section directory names.
/sys/devices/system/node/nodeX/memoryY->/sys/devices/system/memory/memoryY/sys/devices/system/node/nodeX/memoryZ->/sys/devices/system/memory/memoryZ
Agree. I think this is better way.
Thanks.
Signature · 8 lines
Yasunori Goto -- 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>
Quoted 12 lines · Gary Hade
drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 renamed from drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700 +5
-0@@ -150,6 +150,22 @@ return len; } +/* + * node on which memory section resides + */ +static ssize_t show_mem_node(struct sys_device *dev, + struct sysdev_attribute *attr, char *buf)
drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 line 167
Quoted 10 lines
drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 renamed from drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700 +10
-0+{ + unsigned long start_pfn; + int ret; + struct memory_block *mem = + container_of(dev, struct memory_block, sysdev); + + start_pfn = section_nr_to_pfn(mem->phys_index); + ret = pfn_to_nid(start_pfn); + return sprintf(buf, "%d\n", ret); +}
I only wonder if this is the "sysfs" way to do it.
I mean, we don't put a file with the PCI id of a device in the device's sysfs directory. We put a symlink to its place in the bus tree.
Should we just link over to the NUMA node directory? We have it there, so we might as well use it.
-- Dave
--
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>
Quoted 26 lines · Dave Hansen
Quoted 12 lines · Gary Hade
drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 renamed from drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700 +5
-0@@ -150,6 +150,22 @@ return len; } +/* + * node on which memory section resides + */ +static ssize_t show_mem_node(struct sys_device *dev, + struct sysdev_attribute *attr, char *buf)drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 line 167
Quoted 10 lines
drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 renamed from drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700 +10
-0+{ + unsigned long start_pfn; + int ret; + struct memory_block *mem = + container_of(dev, struct memory_block, sysdev); + + start_pfn = section_nr_to_pfn(mem->phys_index); + ret = pfn_to_nid(start_pfn); + return sprintf(buf, "%d\n", ret); +}I only wonder if this is the "sysfs" way to do it.
Quoted 5 lines
I mean, we don't put a file with the PCI id of a device in the device's sysfs directory. We put a symlink to its place in the bus tree.
Should we just link over to the NUMA node directory? We have it there, so we might as well use it.
That sounds reasonable to me. Someone is documenting this new addition with an entry in Documentation/ABI/, right?
thanks,
greg k-h
--
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>
Quoted 27 lines · Greg KH
Quoted 26 lines · Dave Hansen
Quoted 12 lines · Gary Hade
drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 renamed from drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700 +5
-0@@ -150,6 +150,22 @@ return len; } +/* + * node on which memory section resides + */ +static ssize_t show_mem_node(struct sys_device *dev, + struct sysdev_attribute *attr, char *buf)drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 line 167
Quoted 10 lines
drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 renamed from drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700 +10
-0+{ + unsigned long start_pfn; + int ret; + struct memory_block *mem = + container_of(dev, struct memory_block, sysdev); + + start_pfn = section_nr_to_pfn(mem->phys_index); + ret = pfn_to_nid(start_pfn); + return sprintf(buf, "%d\n", ret); +}I only wonder if this is the "sysfs" way to do it.
Quoted 8 lines
Quoted 5 lines
I mean, we don't put a file with the PCI id of a device in the device's sysfs directory. We put a symlink to its place in the bus tree.
Should we just link over to the NUMA node directory? We have it there, so we might as well use it.
That sounds reasonable to me. Someone is documenting this new addition with an entry in
Documentation/ABI/, right?
Yes, my bad. Revision will add that to Documentation/memory-hotplug.txt as well as a description of the 'removable' file that Badari mentioned, if OK to include both in the same patch.
Gary
Signature · 12 lines
Gary Hade System x Enablement IBM Linux Technology Center 503-578-4503 IBM T/L: 775-4503 [email protected] http://www.ibm.com/linux/ltc -- 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>
Quoted 34 lines · Gary Hade
Quoted 33 lines · Greg KH
Quoted 31 lines · Dave Hansen
Quoted 12 lines · Gary Hade
drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 renamed from drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700 +5
-0@@ -150,6 +150,22 @@ return len; } +/* + * node on which memory section resides + */ +static ssize_t show_mem_node(struct sys_device *dev, + struct sysdev_attribute *attr, char *buf)drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 line 167
Quoted 10 lines
drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 renamed from drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700 +10
-0+{ + unsigned long start_pfn; + int ret; + struct memory_block *mem = + container_of(dev, struct memory_block, sysdev); + + start_pfn = section_nr_to_pfn(mem->phys_index); + ret = pfn_to_nid(start_pfn); + return sprintf(buf, "%d\n", ret); +}I only wonder if this is the "sysfs" way to do it.
I mean, we don't put a file with the PCI id of a device in the device's sysfs directory. We put a symlink to its place in the bus tree.
Should we just link over to the NUMA node directory? We have it there, so we might as well use it.
Quoted 6 lines
Quoted 2 lines
That sounds reasonable to me. Someone is documenting this new addition with an entry in
Documentation/ABI/, right?Yes, my bad. Revision will add that to
Documentation/memory-hotplug.txtas well as a description of the 'removable' file that Badari mentioned, if OK to include both in the same patch.
Care to move the information from memory-hotplug.txt into the proper place for this kind of stuff (Documentation/ABI for all external kernel ABIs).
thanks,
greg k-h
--
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>
Quoted 38 lines · Greg KH
Quoted 37 lines · Gary Hade
Quoted 35 lines · Greg KH
Quoted 26 lines · Dave Hansen
Quoted 12 lines · Gary Hade
drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 renamed from drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700 +5
-0@@ -150,6 +150,22 @@ return len; } +/* + * node on which memory section resides + */ +static ssize_t show_mem_node(struct sys_device *dev, + struct sysdev_attribute *attr, char *buf)drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 line 167
Quoted 10 lines
drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 renamed from drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700 +10
-0+{ + unsigned long start_pfn; + int ret; + struct memory_block *mem = + container_of(dev, struct memory_block, sysdev); + + start_pfn = section_nr_to_pfn(mem->phys_index); + ret = pfn_to_nid(start_pfn); + return sprintf(buf, "%d\n", ret); +}I only wonder if this is the "sysfs" way to do it.
Quoted 5 lines
I mean, we don't put a file with the PCI id of a device in the device's sysfs directory. We put a symlink to its place in the bus tree.
Should we just link over to the NUMA node directory? We have it there, so we might as well use it.
That sounds reasonable to me. Someone is documenting this new addition with an entry in
Documentation/ABI/, right?
Quoted 7 lines
Quoted 3 lines
Yes, my bad. Revision will add that to
Documentation/memory-hotplug.txtas well as a description of the 'removable' file that Badari mentioned, if OK to include both in the same patch.Care to move the information from memory-hotplug.txt into the proper place for this kind of stuff (
Documentation/ABIfor all external kernel ABIs).
Sorry, I think I got it now. Badari has already documented the memory section 'removable' file in
Documentation/ABI/testing/sysfs-devices-memory
but descriptions for the other memory section files are not yet included there. I will make sure this gets fixed.
Gary
Signature · 12 lines
Gary Hade System x Enablement IBM Linux Technology Center 503-578-4503 IBM T/L: 775-4503 [email protected] http://www.ibm.com/linux/ltc -- 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>
Quoted 26 lines · Dave Hansen
Quoted 12 lines · Gary Hade
drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 renamed from drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700 +5
-0@@ -150,6 +150,22 @@ return len; } +/* + * node on which memory section resides + */ +static ssize_t show_mem_node(struct sys_device *dev, + struct sysdev_attribute *attr, char *buf)drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 line 167
Quoted 10 lines
drivers/base/memory.c 2008-09-03 14:25:14.000000000 -0700 renamed from drivers/base/memory.c 2008-09-03 14:24:54.000000000 -0700 +10
-0+{ + unsigned long start_pfn; + int ret; + struct memory_block *mem = + container_of(dev, struct memory_block, sysdev); + + start_pfn = section_nr_to_pfn(mem->phys_index); + ret = pfn_to_nid(start_pfn); + return sprintf(buf, "%d\n", ret); +}I only wonder if this is the "sysfs" way to do it.
Quoted 5 lines
I mean, we don't put a file with the PCI id of a device in the device's sysfs directory. We put a symlink to its place in the bus tree.
Should we just link over to the NUMA node directory? We have it there, so we might as well use it.
Dave, Good comment from both you and Nish.
The "sysfs" way appears to be a bit inconsistent. :)
w/2.6.27-rc5:
elm3a153:~ # ls -ld /sys/devices/pci0000:0f/0000:0f:00.0/numa_node -r--r--r-- 1 root root 4096 2008-09-04 15:14 /sys/devices/pci0000:0f/0000:0f:00.0/numa_node elm3a153:~ # cat /sys/devices/pci0000:0f/0000:0f:00.0/numa_node
1
I think this may have been the model I was trying to follow.
Also, Using your PCI id example there are already instances of PCI address containing files in the sysfs tree which I believe could have been symlinks. When the 'pci_slot' or 'acpiphp' drivers are loaded /sys/bus/pci/slots/<slot num>/address files are created. I believe these PCI address containing files could have been symlinks. Alex Chiang recently posted a change that adds /sys/bus/pci/slots/<slot_num>/device symlinks pointing to the approproate place in /sys/devices which will be quite useful but I think the PCI address containing files are also useful.
In any case, the symlink sounds like a good idea and would be sufficient by itself but I'm wondering if it would be overkill to provide both? e.g. a 'node' symlink and a 'node_num' file.
Gary
Signature · 12 lines
Gary Hade System x Enablement IBM Linux Technology Center 503-578-4503 IBM T/L: 775-4503 [email protected] http://www.ibm.com/linux/ltc -- 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>
Quoted 4 lines · Gary Hade
In any case, the symlink sounds like a good idea and would be sufficient by itself but I'm wondering if it would be overkill to provide both? e.g. a 'node' symlink and a '
node_num' file.
Yep, that's overkill. I'd just do the symlink.
-- Dave
--
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>
Quoted 7 lines · Dave Hansen
Quoted 4 lines · Gary Hade
In any case, the symlink sounds like a good idea and would be sufficient by itself but I'm wondering if it would be overkill to provide both? e.g. a 'node' symlink and a '
node_num' file.Yep, that's overkill. I'd just do the symlink.
My later conclusion as well. Thanks.
Gary
Signature · 12 lines
Gary Hade System x Enablement IBM Linux Technology Center 503-578-4503 IBM T/L: 775-4503 [email protected] http://www.ibm.com/linux/ltc -- 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>