mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jin Guojie <guojie.jin@gmail.com>
To: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Jin Guojie" <guojie.jin@gmail.com>,
	"Michal Koutný" <mkoutny@suse.com>,
	"Waiman Long" <longman@redhat.com>
Subject: [PATCH] [PATCH v4] cgroup/cpuset: fmeter_getrate() returns 0 when memory_pressure disabled
Date: Tue, 18 Feb 2025 01:03:16 +0000	[thread overview]
Message-ID: <20250218010316.1950017-1-guojie.jin@gmail.com> (raw)

When running LTP's cpuset_memory_pressure program, an error can be
reproduced by the following steps:

(1) Create a cgroup, enable cpuset subsystem, set memory limit, and
then set cpuset_memory_pressure to 1
(2) In this cgroup, create a process to allocate a large amount of
memory and generate pressure counts
(3) Set cpuset_memory_pressure to 0
(4) Check cpuset.memory_pressure: LTP thinks it should be 0, but the
kernel returns a value of 1, so LTP determines it as FAIL

This patch modifies fmeter_getrate() to determine whether to return 0
based on cpuset_memory_pressure_enabled.

Signed-off-by: Jin Guojie <guojie.jin@gmail.com>
Acked-by: Michal Koutný <mkoutny@suse.com>
Acked-by: Waiman Long <longman@redhat.com>
---
 kernel/cgroup/cpuset-v1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cgroup/cpuset-v1.c b/kernel/cgroup/cpuset-v1.c
index 25c1d7b77e2f..14564e91e2b3 100644
--- a/kernel/cgroup/cpuset-v1.c
+++ b/kernel/cgroup/cpuset-v1.c
@@ -108,7 +108,7 @@ static int fmeter_getrate(struct fmeter *fmp)
 	fmeter_update(fmp);
 	val = fmp->val;
 	spin_unlock(&fmp->lock);
-	return val;
+	return cpuset_memory_pressure_enabled ? val : 0;
 }
 
 /*
-- 
2.34.1


             reply	other threads:[~2025-02-18  1:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18  1:03 Jin Guojie [this message]
2025-02-18  1:37 ` Waiman Long

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250218010316.1950017-1-guojie.jin@gmail.com \
    --to=guojie.jin@gmail.com \
    --cc=cgroups@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mkoutny@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®