When running LTP's cpuset_memory_pressure case, the following error occurs: (1) mount a cgroup v1 hierarchy, enable cpuset, set memory limit (2) write 1 to memory_pressure_enabled (2) create a process in this group, allocate a large amount of memory to generate pressure (3) write 0 to memory_pressure_enabled (4) immediately read cpuset.memory_pressure: the kernel returns a non-zero value, and LTP determines it as FAIL According to admin-guide/cgroup-v1/cpusets.rst, "1.5 What is memory_pressure ? ... So only systems that enable this feature (i.e. memory_pressure_enabled) will compute the metric." To be consistent with the documentation, when memory_pressure_enabled is 0, cpuset.memory_pressure should always returns 0. Signed-off-by: Jin Guojie <guojie.jin@xxxxxxxxx> --- kernel/cgroup/cpuset-v1.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cpuset-v1.c b/kernel/cgroup/cpuset-v1.c index 25c1d7b77e2f..940beff47772 100644 --- a/kernel/cgroup/cpuset-v1.c +++ b/kernel/cgroup/cpuset-v1.c @@ -105,8 +105,15 @@ static int fmeter_getrate(struct fmeter *fmp) int val; spin_lock(&fmp->lock); - fmeter_update(fmp); - val = fmp->val; + if (cpuset_memory_pressure_enabled) { + fmeter_update(fmp); + val = fmp->val; + } else { + fmp->cnt = 0; + fmp->val = 0; + fmp->time = 0; + val = 0; + } spin_unlock(&fmp->lock); return val; } -- 2.34.1