mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] cgroup/cpuset: fmeter_getrate() returns 0 when memory_pressure disabled
@ 2025-02-17  7:15 Jin Guojie
  2025-02-17 12:51 ` Michal Koutný
  2025-02-17 21:28 ` Waiman Long
  0 siblings, 2 replies; 3+ messages in thread
From: Jin Guojie @ 2025-02-17  7:15 UTC (permalink / raw)
  To: cgroups, linux-kernel; +Cc: Jin Guojie, Michal Koutný, Waiman Long

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

In the current kernel, the variable cpuset_memory_pressure_enabled is
not actually used。

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>
Suggested-by: Michal Koutný <mkoutny@suse.com>
Suggested-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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] cgroup/cpuset: fmeter_getrate() returns 0 when memory_pressure disabled
  2025-02-17  7:15 [PATCH v3] cgroup/cpuset: fmeter_getrate() returns 0 when memory_pressure disabled Jin Guojie
@ 2025-02-17 12:51 ` Michal Koutný
  2025-02-17 21:28 ` Waiman Long
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Koutný @ 2025-02-17 12:51 UTC (permalink / raw)
  To: Jin Guojie; +Cc: cgroups, linux-kernel, Waiman Long

[-- Attachment #1: Type: text/plain, Size: 739 bytes --]

On Mon, Feb 17, 2025 at 07:15:00AM +0000, Jin Guojie <guojie.jin@gmail.com> wrote:
> In the current kernel, the variable cpuset_memory_pressure_enabled is
> not actually used。

This statement is weird, it's generally not true and not false without
further context.

> 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>
> Suggested-by: Michal Koutný <mkoutny@suse.com>

I'm not sure I'd still suggest this :-) but
Acked-by: Michal Koutný <mkoutny@suse.com>

> Suggested-by: Waiman Long <longman@redhat.com>
> ---
>  kernel/cgroup/cpuset-v1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] cgroup/cpuset: fmeter_getrate() returns 0 when memory_pressure disabled
  2025-02-17  7:15 [PATCH v3] cgroup/cpuset: fmeter_getrate() returns 0 when memory_pressure disabled Jin Guojie
  2025-02-17 12:51 ` Michal Koutný
@ 2025-02-17 21:28 ` Waiman Long
  1 sibling, 0 replies; 3+ messages in thread
From: Waiman Long @ 2025-02-17 21:28 UTC (permalink / raw)
  To: Jin Guojie, cgroups, linux-kernel; +Cc: Michal Koutný

On 2/17/25 2:15 AM, Jin Guojie wrote:
> 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
>
> In the current kernel, the variable cpuset_memory_pressure_enabled is
> not actually used。

That statement is not true. cpuset_memory_pressure_enabled is used to 
determine if __cpuset_memory_pressure_bump() should be called in 
cpuset_memory_pressure_bump().

>
> 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>
> Suggested-by: Michal Koutný <mkoutny@suse.com>

What Michal suggested is the approach you used in v2, but it has problem 
as I mentioned previously.

Other than that,

Acked-by: Waiman Long <longman@redhat.com>

> Suggested-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;
>   }
>   
>   /*


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-17 21:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-17  7:15 [PATCH v3] cgroup/cpuset: fmeter_getrate() returns 0 when memory_pressure disabled Jin Guojie
2025-02-17 12:51 ` Michal Koutný
2025-02-17 21:28 ` Waiman Long

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®