[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CA+B+MYRNsdKcYxC8kbyzVrdH9fT8c2if5UxGguKep36ZHe6HMQ@mail.gmail.com>
Date: Thu, 19 Dec 2024 17:06:31 +0800
From: Jin Guojie <guojie.jin@...il.com>
To: Waiman Long <longman@...hat.com>
Cc: cgroups@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] cgroup/cpuset: fmeter_getrate() returns 0 when
cpuset.memory_pressure disabled
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@...il.com>
---
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
Powered by blists - more mailing lists