All Products
Search
Document Center

Alibaba Cloud Linux:Memcg QoS feature of the cgroup v1 interface

Last Updated:Oct 10, 2023

The memory control group (memcg) quality of service (QoS) feature can be used to control locks and limits on memory usage in a memcg. In community versions of the Linux kernel, this feature is supported only by the cgroup v2 interface. In Alibaba Cloud Linux 2 starting with kernel version 4.19.91-18.al7 and Alibaba Cloud Linux 3, the memcg QoS feature is supported by the cgroup v1 interface.

Background information

In the Alibaba Cloud Linux kernel, the memcg QoS feature is enabled in the cgroup v1 interface by default. For more information about memcg QoS, see Documentation/admin-guide/cgroup-v2.rst. You can obtain the kernel document from the Debuginfo package and source code package of Alibaba Cloud Linux. For more information, see Use Alibaba Cloud Linux 2.

Precautions

When you use the memcg QoS feature of the cgroup v1 interface, we recommend that you place your tasks in a memcg leaf node. Sample task path: /sys/fs/cgroup/memory/<intermediate node>/<leaf node>/tasks.

Interface description

The following table describes the interfaces that implement the memcg QoS feature of the cgroup v1 interface in the Alibaba Cloud Linux kernel.

Interface

Description

memory.min

Absolutely locks the memory. Memory locked by this interface cannot be reclaimed. You can perform the following read and write operations on the interface:

  • Read the size of locked memory from the interface.

  • Write the size of locked memory to the interface.

memory.low

Relatively locks the memory. Memory locked by this interface may be partially reclaimed if the system has no other memory to reclaim. You can perform the following read and write operations on the interface:

  • Read the size of locked memory from the interface.

  • Write the size of locked memory to the interface.

memory.high

Limits the memory usage. You can perform the following read and write operations on the interface:

  • Read the usage limits on the memory from the interface.

  • Write the usage limits on the memory to the interface.

Examples

Create a test memcg in the memcg mount directory such as /sys/fs/cgroup/memory/. Make sure that the memcg contains the memory.min, memory.low, and memory.high interfaces.

Sample command:

mkdir /sys/fs/cgroup/memory/test
ls /sys/fs/cgroup/memory/test | grep -E "memory.(min|low|high)"

Sample output:

memory.high
memory.low
memory.min