memory-hotplug.rst 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ==============
  3. Memory Hotplug
  4. ==============
  5. The final phase of surfacing CXL memory to the kernel page allocator is for
  6. the `DAX` driver to surface a `Driver Managed` memory region via the
  7. memory-hotplug component.
  8. There are four major configurations to consider:
  9. 1) Default Online Behavior (on/off and zone)
  10. 2) Hotplug Memory Block size
  11. 3) Memory Map Resource location
  12. 4) Driver-Managed Memory Designation
  13. Default Online Behavior
  14. =======================
  15. The default-online behavior of hotplug memory is dictated by the following,
  16. in order of precedence:
  17. - :code:`CONFIG_MHP_DEFAULT_ONLINE_TYPE` Build Configuration
  18. - :code:`memhp_default_state` Boot parameter
  19. - :code:`/sys/devices/system/memory/auto_online_blocks` value
  20. These dictate whether hotplugged memory blocks arrive in one of three states:
  21. 1) Offline
  22. 2) Online in :code:`ZONE_NORMAL`
  23. 3) Online in :code:`ZONE_MOVABLE`
  24. :code:`ZONE_NORMAL` implies this capacity may be used for almost any allocation,
  25. while :code:`ZONE_MOVABLE` implies this capacity should only be used for
  26. migratable allocations.
  27. :code:`ZONE_MOVABLE` attempts to retain the hotplug-ability of a memory block
  28. so that it the entire region may be hot-unplugged at a later time. Any capacity
  29. onlined into :code:`ZONE_NORMAL` should be considered permanently attached to
  30. the page allocator.
  31. Hotplug Memory Block Size
  32. =========================
  33. By default, on most architectures, the Hotplug Memory Block Size is either
  34. 128MB or 256MB. On x86, the block size increases up to 2GB as total memory
  35. capacity exceeds 64GB. As of v6.15, Linux does not take into account the
  36. size and alignment of the ACPI CEDT CFMWS regions (see Early Boot docs) when
  37. deciding the Hotplug Memory Block Size.
  38. Memory Map
  39. ==========
  40. The location of :code:`struct folio` allocations to represent the hotplugged
  41. memory capacity are dictated by the following system settings:
  42. - :code:`/sys_module/memory_hotplug/parameters/memmap_on_memory`
  43. - :code:`/sys/bus/dax/devices/daxN.Y/memmap_on_memory`
  44. If both of these parameters are set to true, :code:`struct folio` for this
  45. capacity will be carved out of the memory block being onlined. This has
  46. performance implications if the memory is particularly high-latency and
  47. its :code:`struct folio` becomes hotly contended.
  48. If either parameter is set to false, :code:`struct folio` for this capacity
  49. will be allocated from the local node of the processor running the hotplug
  50. procedure. This capacity will be allocated from :code:`ZONE_NORMAL` on
  51. that node, as it is a :code:`GFP_KERNEL` allocation.
  52. Systems with extremely large amounts of :code:`ZONE_MOVABLE` memory (e.g.
  53. CXL memory pools) must ensure that there is sufficient local
  54. :code:`ZONE_NORMAL` capacity to host the memory map for the hotplugged capacity.
  55. Driver Managed Memory
  56. =====================
  57. The DAX driver surfaces this memory to memory-hotplug as "Driver Managed". This
  58. is not a configurable setting, but it's important to note that driver managed
  59. memory is explicitly excluded from use during kexec. This is required to ensure
  60. any reset or out-of-band operations that the CXL device may be subject to during
  61. a functional system-reboot (such as a reset-on-probe) will not cause portions of
  62. the kexec kernel to be overwritten.