fake-numa-for-cpusets 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Using numa=fake and CPUSets for Resource Management
  2. Written by David Rientjes <rientjes@cs.washington.edu>
  3. This document describes how the numa=fake x86_64 command-line option can be used
  4. in conjunction with cpusets for coarse memory management. Using this feature,
  5. you can create fake NUMA nodes that represent contiguous chunks of memory and
  6. assign them to cpusets and their attached tasks. This is a way of limiting the
  7. amount of system memory that are available to a certain class of tasks.
  8. For more information on the features of cpusets, see
  9. Documentation/cgroups/cpusets.txt.
  10. There are a number of different configurations you can use for your needs. For
  11. more information on the numa=fake command line option and its various ways of
  12. configuring fake nodes, see Documentation/x86/x86_64/boot-options.txt.
  13. For the purposes of this introduction, we'll assume a very primitive NUMA
  14. emulation setup of "numa=fake=4*512,". This will split our system memory into
  15. four equal chunks of 512M each that we can now use to assign to cpusets. As
  16. you become more familiar with using this combination for resource control,
  17. you'll determine a better setup to minimize the number of nodes you have to deal
  18. with.
  19. A machine may be split as follows with "numa=fake=4*512," as reported by dmesg:
  20. Faking node 0 at 0000000000000000-0000000020000000 (512MB)
  21. Faking node 1 at 0000000020000000-0000000040000000 (512MB)
  22. Faking node 2 at 0000000040000000-0000000060000000 (512MB)
  23. Faking node 3 at 0000000060000000-0000000080000000 (512MB)
  24. ...
  25. On node 0 totalpages: 130975
  26. On node 1 totalpages: 131072
  27. On node 2 totalpages: 131072
  28. On node 3 totalpages: 131072
  29. Now following the instructions for mounting the cpusets filesystem from
  30. Documentation/cgroups/cpusets.txt, you can assign fake nodes (i.e. contiguous memory
  31. address spaces) to individual cpusets:
  32. [root@xroads /]# mkdir exampleset
  33. [root@xroads /]# mount -t cpuset none exampleset
  34. [root@xroads /]# mkdir exampleset/ddset
  35. [root@xroads /]# cd exampleset/ddset
  36. [root@xroads /exampleset/ddset]# echo 0-1 > cpus
  37. [root@xroads /exampleset/ddset]# echo 0-1 > mems
  38. Now this cpuset, 'ddset', will only allowed access to fake nodes 0 and 1 for
  39. memory allocations (1G).
  40. You can now assign tasks to these cpusets to limit the memory resources
  41. available to them according to the fake nodes assigned as mems:
  42. [root@xroads /exampleset/ddset]# echo $$ > tasks
  43. [root@xroads /exampleset/ddset]# dd if=/dev/zero of=tmp bs=1024 count=1G
  44. [1] 13425
  45. Notice the difference between the system memory usage as reported by
  46. /proc/meminfo between the restricted cpuset case above and the unrestricted
  47. case (i.e. running the same 'dd' command without assigning it to a fake NUMA
  48. cpuset):
  49. Unrestricted Restricted
  50. MemTotal: 3091900 kB 3091900 kB
  51. MemFree: 42113 kB 1513236 kB
  52. This allows for coarse memory management for the tasks you assign to particular
  53. cpusets. Since cpusets can form a hierarchy, you can create some pretty
  54. interesting combinations of use-cases for various classes of tasks for your
  55. memory management needs.