fake-numa-for-cpusets 3.0 KB

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