All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cgroup: Fix rootcg cpu.stat guest double counting
@ 2021-10-28 22:15 ` Dan Schatzberg
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Schatzberg @ 2021-10-28 22:15 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Zefan Li, Johannes Weiner, Boris Burkov,
	open list:CONTROL GROUP (CGROUP),
	open list

In account_guest_time in kernel/sched/cputime.c guest time is
attributed to both CPUTIME_NICE and CPUTIME_USER in addition to
CPUTIME_GUEST_NICE and CPUTIME_GUEST respectively. Therefore, adding
both to calculate usage results in double counting any guest time at
the rootcg.

Fixes: 936f2a70f207 ("cgroup: add cpu.stat file to root cgroup")
Signed-off-by: Dan Schatzberg <schatzberg.dan@gmail.com>
---
 kernel/cgroup/rstat.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index b264ab5652ba..1486768f2318 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -433,8 +433,6 @@ static void root_cgroup_cputime(struct task_cputime *cputime)
 		cputime->sum_exec_runtime += user;
 		cputime->sum_exec_runtime += sys;
 		cputime->sum_exec_runtime += cpustat[CPUTIME_STEAL];
-		cputime->sum_exec_runtime += cpustat[CPUTIME_GUEST];
-		cputime->sum_exec_runtime += cpustat[CPUTIME_GUEST_NICE];
 	}
 }
 
-- 
2.30.2


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

* [PATCH] cgroup: Fix rootcg cpu.stat guest double counting
@ 2021-10-28 22:15 ` Dan Schatzberg
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Schatzberg @ 2021-10-28 22:15 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Zefan Li, Johannes Weiner, Boris Burkov,
	open list:CONTROL GROUP CGROUP, open list

In account_guest_time in kernel/sched/cputime.c guest time is
attributed to both CPUTIME_NICE and CPUTIME_USER in addition to
CPUTIME_GUEST_NICE and CPUTIME_GUEST respectively. Therefore, adding
both to calculate usage results in double counting any guest time at
the rootcg.

Fixes: 936f2a70f207 ("cgroup: add cpu.stat file to root cgroup")
Signed-off-by: Dan Schatzberg <schatzberg.dan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 kernel/cgroup/rstat.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index b264ab5652ba..1486768f2318 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -433,8 +433,6 @@ static void root_cgroup_cputime(struct task_cputime *cputime)
 		cputime->sum_exec_runtime += user;
 		cputime->sum_exec_runtime += sys;
 		cputime->sum_exec_runtime += cpustat[CPUTIME_STEAL];
-		cputime->sum_exec_runtime += cpustat[CPUTIME_GUEST];
-		cputime->sum_exec_runtime += cpustat[CPUTIME_GUEST_NICE];
 	}
 }
 
-- 
2.30.2


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

* Re: [PATCH] cgroup: Fix rootcg cpu.stat guest double counting
@ 2021-10-29 17:21   ` Daniel Jordan
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Jordan @ 2021-10-29 17:21 UTC (permalink / raw)
  To: Dan Schatzberg
  Cc: Tejun Heo, Zefan Li, Johannes Weiner, Boris Burkov,
	open list:CONTROL GROUP (CGROUP),
	open list, Ingo Molnar, Peter Zijlstra, Andrey Ryabinin

On Thu, Oct 28, 2021 at 03:15:27PM -0700, Dan Schatzberg wrote:
> In account_guest_time in kernel/sched/cputime.c guest time is
> attributed to both CPUTIME_NICE and CPUTIME_USER in addition to
> CPUTIME_GUEST_NICE and CPUTIME_GUEST respectively. Therefore, adding
> both to calculate usage results in double counting any guest time at
> the rootcg.

Yes, definitely a bug.  The same fix was posted a couple months ago as
part of a series but never picked up:

  https://x-lore.kernel.org/all/20210820094005.20596-3-arbn@yandex-team.com/

The series also touched cputime, so we might be waiting for scheduler
folks?   +Ingo +Peter +Andrey

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

* Re: [PATCH] cgroup: Fix rootcg cpu.stat guest double counting
@ 2021-10-29 17:21   ` Daniel Jordan
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Jordan @ 2021-10-29 17:21 UTC (permalink / raw)
  To: Dan Schatzberg
  Cc: Tejun Heo, Zefan Li, Johannes Weiner, Boris Burkov,
	open list:CONTROL GROUP (CGROUP),
	open list, Ingo Molnar, Peter Zijlstra, Andrey Ryabinin

On Thu, Oct 28, 2021 at 03:15:27PM -0700, Dan Schatzberg wrote:
> In account_guest_time in kernel/sched/cputime.c guest time is
> attributed to both CPUTIME_NICE and CPUTIME_USER in addition to
> CPUTIME_GUEST_NICE and CPUTIME_GUEST respectively. Therefore, adding
> both to calculate usage results in double counting any guest time at
> the rootcg.

Yes, definitely a bug.  The same fix was posted a couple months ago as
part of a series but never picked up:

  https://x-lore.kernel.org/all/20210820094005.20596-3-arbn-XoJtRXgx1JtgGdypvdXH1w@public.gmane.org/

The series also touched cputime, so we might be waiting for scheduler
folks?   +Ingo +Peter +Andrey

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

* Re: [PATCH] cgroup: Fix rootcg cpu.stat guest double counting
@ 2021-11-01 16:48   ` Tejun Heo
  0 siblings, 0 replies; 7+ messages in thread
From: Tejun Heo @ 2021-11-01 16:48 UTC (permalink / raw)
  To: Dan Schatzberg
  Cc: Zefan Li, Johannes Weiner, Boris Burkov,
	open list:CONTROL GROUP (CGROUP),
	open list

On Thu, Oct 28, 2021 at 03:15:27PM -0700, Dan Schatzberg wrote:
> In account_guest_time in kernel/sched/cputime.c guest time is
> attributed to both CPUTIME_NICE and CPUTIME_USER in addition to
> CPUTIME_GUEST_NICE and CPUTIME_GUEST respectively. Therefore, adding
> both to calculate usage results in double counting any guest time at
> the rootcg.
> 
> Fixes: 936f2a70f207 ("cgroup: add cpu.stat file to root cgroup")
> Signed-off-by: Dan Schatzberg <schatzberg.dan@gmail.com>

Applying to cgroup/for-5.16.

Thanks.

-- 
tejun

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

* Re: [PATCH] cgroup: Fix rootcg cpu.stat guest double counting
@ 2021-11-01 16:48   ` Tejun Heo
  0 siblings, 0 replies; 7+ messages in thread
From: Tejun Heo @ 2021-11-01 16:48 UTC (permalink / raw)
  To: Dan Schatzberg
  Cc: Zefan Li, Johannes Weiner, Boris Burkov,
	open list:CONTROL GROUP (CGROUP),
	open list

On Thu, Oct 28, 2021 at 03:15:27PM -0700, Dan Schatzberg wrote:
> In account_guest_time in kernel/sched/cputime.c guest time is
> attributed to both CPUTIME_NICE and CPUTIME_USER in addition to
> CPUTIME_GUEST_NICE and CPUTIME_GUEST respectively. Therefore, adding
> both to calculate usage results in double counting any guest time at
> the rootcg.
> 
> Fixes: 936f2a70f207 ("cgroup: add cpu.stat file to root cgroup")
> Signed-off-by: Dan Schatzberg <schatzberg.dan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Applying to cgroup/for-5.16.

Thanks.

-- 
tejun

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

* Re: [PATCH] cgroup: Fix rootcg cpu.stat guest double counting
  2021-10-29 17:21   ` Daniel Jordan
  (?)
@ 2021-11-15 16:41   ` Andrey Ryabinin
  -1 siblings, 0 replies; 7+ messages in thread
From: Andrey Ryabinin @ 2021-11-15 16:41 UTC (permalink / raw)
  To: Daniel Jordan, Dan Schatzberg
  Cc: Tejun Heo, Zefan Li, Johannes Weiner, Boris Burkov,
	open list:CONTROL GROUP (CGROUP),
	open list, Ingo Molnar, Peter Zijlstra



On 10/29/21 8:21 PM, Daniel Jordan wrote:
> On Thu, Oct 28, 2021 at 03:15:27PM -0700, Dan Schatzberg wrote:
>> In account_guest_time in kernel/sched/cputime.c guest time is
>> attributed to both CPUTIME_NICE and CPUTIME_USER in addition to
>> CPUTIME_GUEST_NICE and CPUTIME_GUEST respectively. Therefore, adding
>> both to calculate usage results in double counting any guest time at
>> the rootcg.
> 
> Yes, definitely a bug.  The same fix was posted a couple months ago as
> part of a series but never picked up:
> 
>   https://x-lore.kernel.org/all/20210820094005.20596-3-arbn@yandex-team.com/
> 
> The series also touched cputime, so we might be waiting for scheduler
> folks?   +Ingo +Peter +Andrey
> 

Yeah, I'll do rebase and send v3

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

end of thread, other threads:[~2021-11-15 16:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28 22:15 [PATCH] cgroup: Fix rootcg cpu.stat guest double counting Dan Schatzberg
2021-10-28 22:15 ` Dan Schatzberg
2021-10-29 17:21 ` Daniel Jordan
2021-10-29 17:21   ` Daniel Jordan
2021-11-15 16:41   ` Andrey Ryabinin
2021-11-01 16:48 ` Tejun Heo
2021-11-01 16:48   ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.