Commit dee5d0d518defd0337a41f1a504428c9acc87be5
Committed by
Linus Torvalds
1 parent
d99be1a8ec
mm: add numa node symlink for memory section in sysfs
Commit c04fc586c (mm: show node to memory section relationship with symlinks in sysfs) created symlinks from nodes to memory sections, e.g. /sys/devices/system/node/node1/memory135 -> ../../memory/memory135 If you're examining the memory section though and are wondering what node it might belong to, you can find it by grovelling around in sysfs, but it's a little cumbersome. Add a reverse symlink for each memory section that points back to the node to which it belongs. Signed-off-by: Alex Chiang <achiang@hp.com> Cc: Gary Hade <garyhade@us.ibm.com> Cc: Badari Pulavarty <pbadari@us.ibm.com> Cc: Ingo Molnar <mingo@elte.hu> Acked-by: David Rientjes <rientjes@google.com> Cc: Greg KH <greg@kroah.com> Cc: Randy Dunlap <randy.dunlap@oracle.com> Cc: David Rientjes <rientjes@google.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 3 changed files with 30 additions and 6 deletions Side-by-side Diff
Documentation/ABI/testing/sysfs-devices-memory
... | ... | @@ -60,6 +60,19 @@ |
60 | 60 | Users: hotplug memory remove tools |
61 | 61 | https://w3.opensource.ibm.com/projects/powerpc-utils/ |
62 | 62 | |
63 | + | |
64 | +What: /sys/devices/system/memoryX/nodeY | |
65 | +Date: October 2009 | |
66 | +Contact: Linux Memory Management list <linux-mm@kvack.org> | |
67 | +Description: | |
68 | + When CONFIG_NUMA is enabled, a symbolic link that | |
69 | + points to the corresponding NUMA node directory. | |
70 | + | |
71 | + For example, the following symbolic link is created for | |
72 | + memory section 9 on node0: | |
73 | + /sys/devices/system/memory/memory9/node0 -> ../../node/node0 | |
74 | + | |
75 | + | |
63 | 76 | What: /sys/devices/system/node/nodeX/memoryY |
64 | 77 | Date: September 2008 |
65 | 78 | Contact: Gary Hade <garyhade@us.ibm.com> |
Documentation/memory-hotplug.txt
... | ... | @@ -160,11 +160,14 @@ |
160 | 160 | NOTE: |
161 | 161 | These directories/files appear after physical memory hotplug phase. |
162 | 162 | |
163 | -If CONFIG_NUMA is enabled the | |
164 | -/sys/devices/system/memory/memoryXXX memory section | |
165 | -directories can also be accessed via symbolic links located in | |
166 | -the /sys/devices/system/node/node* directories. For example: | |
163 | +If CONFIG_NUMA is enabled the memoryXXX/ directories can also be accessed | |
164 | +via symbolic links located in the /sys/devices/system/node/node* directories. | |
165 | + | |
166 | +For example: | |
167 | 167 | /sys/devices/system/node/node0/memory9 -> ../../memory/memory9 |
168 | + | |
169 | +A backlink will also be created: | |
170 | +/sys/devices/system/memory/memory9/node0 -> ../../node/node0 | |
168 | 171 | |
169 | 172 | -------------------------------- |
170 | 173 | 4. Physical memory hot-add phase |
drivers/base/node.c
... | ... | @@ -312,6 +312,7 @@ |
312 | 312 | /* register memory section under specified node if it spans that node */ |
313 | 313 | int register_mem_sect_under_node(struct memory_block *mem_blk, int nid) |
314 | 314 | { |
315 | + int ret; | |
315 | 316 | unsigned long pfn, sect_start_pfn, sect_end_pfn; |
316 | 317 | |
317 | 318 | if (!mem_blk) |
318 | 319 | |
... | ... | @@ -328,9 +329,15 @@ |
328 | 329 | continue; |
329 | 330 | if (page_nid != nid) |
330 | 331 | continue; |
331 | - return sysfs_create_link_nowarn(&node_devices[nid].sysdev.kobj, | |
332 | + ret = sysfs_create_link_nowarn(&node_devices[nid].sysdev.kobj, | |
332 | 333 | &mem_blk->sysdev.kobj, |
333 | 334 | kobject_name(&mem_blk->sysdev.kobj)); |
335 | + if (ret) | |
336 | + return ret; | |
337 | + | |
338 | + return sysfs_create_link_nowarn(&mem_blk->sysdev.kobj, | |
339 | + &node_devices[nid].sysdev.kobj, | |
340 | + kobject_name(&node_devices[nid].sysdev.kobj)); | |
334 | 341 | } |
335 | 342 | /* mem section does not span the specified node */ |
336 | 343 | return 0; |
... | ... | @@ -359,6 +366,8 @@ |
359 | 366 | continue; |
360 | 367 | sysfs_remove_link(&node_devices[nid].sysdev.kobj, |
361 | 368 | kobject_name(&mem_blk->sysdev.kobj)); |
369 | + sysfs_remove_link(&mem_blk->sysdev.kobj, | |
370 | + kobject_name(&node_devices[nid].sysdev.kobj)); | |
362 | 371 | } |
363 | 372 | return 0; |
364 | 373 | } |