The memory control group (memcg) backend asynchronous reclaim feature is provided
by Alibaba Cloud Linux 2 kernel version 4.19.81-17.al7
and later. This topic describes the interfaces that implement the memcg backend asynchronous
reclaim feature.
Background information
In community versions of the Linux kernel, the system allocates memory and triggers memcg-level direct memory reclaim when the memory reaches a limit set by a memcg. Direct memory reclaim is synchronous reclaim that occurs in the context of memory allocation and affects the performance of the current process.
To resolve this problem, Alibaba Cloud Linux 2 provides the backend asynchronous reclaim feature for memcgs. This feature differs from the global kswapd kernel thread in that this feature uses the workqueue mechanism instead of creating a corresponding memcg kswapd kernel thread. Additionally, four memcg control interfaces are added in each of the cgroup v1 and cgroup v2 interfaces.
- Memory allocation of the current memcg may recursively trigger the backend asynchronous reclaim of the parent group.
- When backend asynchronous reclaim is triggered, it starts from the memcg on which the feature is triggered and is performed in sequence down the hierarchy.
- When memory.high is configured and the value of memory.high is smaller than that of memory.limit_in_bytes, the values of memory.wmark_high and memory.wmark_low are calculated based on memory.high instead of memory.limit_in_bytes.
Interface description
Interface | Description |
---|---|
memory.wmark_ratio | Specifies whether to enable the memcg backend asynchronous reclaim feature and sets
the memcg memory watermark where asynchronous reclaim starts. Unit: percent of the
memcg memory limit. Valid values: 0 to 100.
|
memory.wmark_high | A read-only interface.
|
memory.wmark_low | A read-only interface.
|
memory.wmark_scale_factor | Controls the difference between values of memory.wmark_high and memory.wmark_low. Unit: 0.01 percent of the memcg memory limit. Valid values: 1 to 1000.
|