xref: /linux/Documentation/driver-api/cxl/allocation/reclaim.rst (revision e9ef810dfee7a2227da9d423aecb0ced35faddbe)
1.. SPDX-License-Identifier: GPL-2.0
2
3=======
4Reclaim
5=======
6Another way CXL memory can be utilized *indirectly* is via the reclaim system
7in :code:`mm/vmscan.c`.  Reclaim is engaged when memory capacity on the system
8becomes pressured based on global and cgroup-local `watermark` settings.
9
10In this section we won't discuss the `watermark` configurations, just how CXL
11memory can be consumed by various pieces of reclaim system.
12
13Demotion
14========
15By default, the reclaim system will prefer swap (or zswap) when reclaiming
16memory.  Enabling :code:`kernel/mm/numa/demotion_enabled` will cause vmscan
17to opportunistically prefer distant NUMA nodes to swap or zswap, if capacity
18is available.
19
20Demotion engages the :code:`mm/memory_tier.c` component to determine the
21next demotion node.  The next demotion node is based on the :code:`HMAT`
22or :code:`CDAT` performance data.
23
24cpusets.mems_allowed quirk
25--------------------------
26In Linux v6.15 and below, demotion does not respect :code:`cpusets.mems_allowed`
27when migrating pages.  As a result, if demotion is enabled, vmscan cannot
28guarantee isolation of a container's memory from nodes not set in mems_allowed.
29
30In Linux v6.XX and up, demotion does attempt to respect
31:code:`cpusets.mems_allowed`; however, certain classes of shared memory
32originally instantiated by another cgroup (such as common libraries - e.g.
33libc) may still be demoted.  As a result, the mems_allowed interface still
34cannot provide perfect isolation from the remote nodes.
35
36ZSwap and Node Preference
37=========================
38In Linux v6.15 and below, ZSwap allocates memory from the local node of the
39processor for the new pages being compressed.  Since pages being compressed
40are typically cold, the result is a cold page becomes promoted - only to
41be later demoted as it ages off the LRU.
42
43In Linux v6.XX, ZSwap tries to prefer the node of the page being compressed
44as the allocation target for the compression page.  This helps prevent
45thrashing.
46
47Demotion with ZSwap
48===================
49When enabling both Demotion and ZSwap, you create a situation where ZSwap
50will prefer the slowest form of CXL memory by default until that tier of
51memory is exhausted.
52