All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/cputime: Fix fold steal time into idle time accounting
@ 2016-08-11  5:36 Wanpeng Li
  2016-08-11 11:56 ` [tip:sched/urgent] sched/cputime: Fix steal " tip-bot for Wanpeng Li
  0 siblings, 1 reply; 5+ messages in thread
From: Wanpeng Li @ 2016-08-11  5:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wanpeng Li, Ingo Molnar, Peter Zijlstra (Intel),
	Rik van Riel, Thomas Gleixner, Frederic Weisbecker,
	Paolo Bonzini, Radim

From: Wanpeng Li <wanpeng.li@hotmail.com>

Commit: 

  57430218317 ("sched/cputime: Count actually elapsed irq & softirq time")

... didn't take steal time into consideration with passing the noirqtime 
kernel parameter.

As Paolo pointed out before:

| Why not? If idle=poll, for example, any time the guest is suspended (and
| thus cannot poll) does count as stolen time.

This patch fixes it by reducing steal time from idle time accounting when 
the noirqtime is true. The average idle time drops from 56.8% to 54.75% 
for nohz idle kvm guest(noirqtime, idle=poll, four vCPUs running on one 
pCPU).

Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim <rkrcmar@redhat.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
 kernel/sched/cputime.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 1934f65..8b9bcc5 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -508,13 +508,20 @@ void account_process_tick(struct task_struct *p, int user_tick)
  */
 void account_idle_ticks(unsigned long ticks)
 {
-
+	cputime_t cputime, steal;
 	if (sched_clock_irqtime) {
 		irqtime_account_idle_ticks(ticks);
 		return;
 	}
 
-	account_idle_time(jiffies_to_cputime(ticks));
+	cputime = cputime_one_jiffy;
+	steal = steal_account_process_time(cputime);
+
+	if (steal >= cputime)
+		return;
+
+	cputime -= steal;
+	account_idle_time(cputime);
 }
 
 /*
-- 
1.9.1

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

* [tip:sched/urgent] sched/cputime: Fix steal time accounting
  2016-08-11  5:36 [PATCH] sched/cputime: Fix fold steal time into idle time accounting Wanpeng Li
@ 2016-08-11 11:56 ` tip-bot for Wanpeng Li
  2016-08-11 12:58   ` [PATCH] cputime: Fix omitted ticks passed in parameter (was: Re: [tip:sched/urgent] sched/cputime: Fix steal time accounting) Frederic Weisbecker
  0 siblings, 1 reply; 5+ messages in thread
From: tip-bot for Wanpeng Li @ 2016-08-11 11:56 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: torvalds, riel, linux-kernel, wanpeng.li, mingo, peterz, hpa,
	fweisbec, rkrcmar, pbonzini, tglx

Commit-ID:  f9bcf1e0e0145323ba2cf72ecad5264ff3883eb1
Gitweb:     http://git.kernel.org/tip/f9bcf1e0e0145323ba2cf72ecad5264ff3883eb1
Author:     Wanpeng Li <wanpeng.li@hotmail.com>
AuthorDate: Thu, 11 Aug 2016 13:36:35 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 11 Aug 2016 11:02:14 +0200

sched/cputime: Fix steal time accounting

Commit:

  57430218317 ("sched/cputime: Count actually elapsed irq & softirq time")

... didn't take steal time into consideration with passing the noirqtime
kernel parameter.

As Paolo pointed out before:

| Why not? If idle=poll, for example, any time the guest is suspended (and
| thus cannot poll) does count as stolen time.

This patch fixes it by reducing steal time from idle time accounting when
the noirqtime parameter is true. The average idle time drops from 56.8%
to 54.75% for nohz idle kvm guest(noirqtime, idle=poll, four vCPUs running
on one pCPU).

Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Radim <rkrcmar@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1470893795-3527-1-git-send-email-wanpeng.li@hotmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/cputime.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 1934f65..8b9bcc5 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -508,13 +508,20 @@ void account_process_tick(struct task_struct *p, int user_tick)
  */
 void account_idle_ticks(unsigned long ticks)
 {
-
+	cputime_t cputime, steal;
 	if (sched_clock_irqtime) {
 		irqtime_account_idle_ticks(ticks);
 		return;
 	}
 
-	account_idle_time(jiffies_to_cputime(ticks));
+	cputime = cputime_one_jiffy;
+	steal = steal_account_process_time(cputime);
+
+	if (steal >= cputime)
+		return;
+
+	cputime -= steal;
+	account_idle_time(cputime);
 }
 
 /*

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

* [PATCH] cputime: Fix omitted ticks passed in parameter (was: Re: [tip:sched/urgent] sched/cputime: Fix steal time accounting)
  2016-08-11 11:56 ` [tip:sched/urgent] sched/cputime: Fix steal " tip-bot for Wanpeng Li
@ 2016-08-11 12:58   ` Frederic Weisbecker
  2016-08-11 13:06     ` Wanpeng Li
  2016-08-11 16:20     ` [tip:sched/urgent] sched/cputime: Fix omitted ticks passed in parameter tip-bot for Frederic Weisbecker
  0 siblings, 2 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2016-08-11 12:58 UTC (permalink / raw)
  To: wanpeng.li, mingo, peterz, hpa, torvalds, linux-kernel, riel,
	pbonzini, tglx, rkrcmar
  Cc: linux-tip-commits

Commit f9bcf1e0e0145323ba2cf72ecad5264ff3883eb1
("sched/cputime: Fix steal time accounting") fixes a leak on steal time
accounting but forgets to account the ticks passed in parameters,
assuming there is only one to take into account.

Let's consider that parameter back.

Cc: Wanpeng Li <wanpeng.li@hotmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Radim <rkrcmar@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 kernel/sched/cputime.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 8b9bcc5..9858266 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -509,12 +509,13 @@ void account_process_tick(struct task_struct *p, int user_tick)
 void account_idle_ticks(unsigned long ticks)
 {
 	cputime_t cputime, steal;
+
 	if (sched_clock_irqtime) {
 		irqtime_account_idle_ticks(ticks);
 		return;
 	}
 
-	cputime = cputime_one_jiffy;
+	cputime = jiffies_to_cputime(ticks);
 	steal = steal_account_process_time(cputime);
 
 	if (steal >= cputime)
-- 
2.7.0

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

* Re: [PATCH] cputime: Fix omitted ticks passed in parameter (was: Re: [tip:sched/urgent] sched/cputime: Fix steal time accounting)
  2016-08-11 12:58   ` [PATCH] cputime: Fix omitted ticks passed in parameter (was: Re: [tip:sched/urgent] sched/cputime: Fix steal time accounting) Frederic Weisbecker
@ 2016-08-11 13:06     ` Wanpeng Li
  2016-08-11 16:20     ` [tip:sched/urgent] sched/cputime: Fix omitted ticks passed in parameter tip-bot for Frederic Weisbecker
  1 sibling, 0 replies; 5+ messages in thread
From: Wanpeng Li @ 2016-08-11 13:06 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Wanpeng Li, Ingo Molnar, Peter Zijlstra, H. Peter Anvin,
	torvalds, linux-kernel, Rik van Riel, Paolo Bonzini,
	Thomas Gleixner, Radim Krcmar, linux-tip-commits

2016-08-11 20:58 GMT+08:00 Frederic Weisbecker <fweisbec@gmail.com>:
> Commit f9bcf1e0e0145323ba2cf72ecad5264ff3883eb1
> ("sched/cputime: Fix steal time accounting") fixes a leak on steal time
> accounting but forgets to account the ticks passed in parameters,
> assuming there is only one to take into account.
>
> Let's consider that parameter back.

You are right, thanks.

Regards,
Wanpeng Li

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

* [tip:sched/urgent] sched/cputime: Fix omitted ticks passed in parameter
  2016-08-11 12:58   ` [PATCH] cputime: Fix omitted ticks passed in parameter (was: Re: [tip:sched/urgent] sched/cputime: Fix steal time accounting) Frederic Weisbecker
  2016-08-11 13:06     ` Wanpeng Li
@ 2016-08-11 16:20     ` tip-bot for Frederic Weisbecker
  1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Frederic Weisbecker @ 2016-08-11 16:20 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: torvalds, pbonzini, mingo, kernellwp, hpa, riel, linux-kernel,
	peterz, rkrcmar, fweisbec, wanpeng.li, tglx

Commit-ID:  26f2c75cd2cf10a6120ef02ca9a94db77cc9c8e0
Gitweb:     http://git.kernel.org/tip/26f2c75cd2cf10a6120ef02ca9a94db77cc9c8e0
Author:     Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Thu, 11 Aug 2016 14:58:24 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 11 Aug 2016 16:34:37 +0200

sched/cputime: Fix omitted ticks passed in parameter

Commit:

  f9bcf1e0e014 ("sched/cputime: Fix steal time accounting")

... fixes a leak on steal time accounting but forgets to account
the ticks passed in parameters, assuming there is only one to
take into account.

Let's consider that parameter back.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Wanpeng Li <kernellwp@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Radim <rkrcmar@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Wanpeng Li <wanpeng.li@hotmail.com>
Cc: linux-tip-commits@vger.kernel.org
Link: http://lkml.kernel.org/r/20160811125822.GB4214@lerouge
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/cputime.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 8b9bcc5..9858266 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -509,12 +509,13 @@ void account_process_tick(struct task_struct *p, int user_tick)
 void account_idle_ticks(unsigned long ticks)
 {
 	cputime_t cputime, steal;
+
 	if (sched_clock_irqtime) {
 		irqtime_account_idle_ticks(ticks);
 		return;
 	}
 
-	cputime = cputime_one_jiffy;
+	cputime = jiffies_to_cputime(ticks);
 	steal = steal_account_process_time(cputime);
 
 	if (steal >= cputime)

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

end of thread, other threads:[~2016-08-11 16:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-11  5:36 [PATCH] sched/cputime: Fix fold steal time into idle time accounting Wanpeng Li
2016-08-11 11:56 ` [tip:sched/urgent] sched/cputime: Fix steal " tip-bot for Wanpeng Li
2016-08-11 12:58   ` [PATCH] cputime: Fix omitted ticks passed in parameter (was: Re: [tip:sched/urgent] sched/cputime: Fix steal time accounting) Frederic Weisbecker
2016-08-11 13:06     ` Wanpeng Li
2016-08-11 16:20     ` [tip:sched/urgent] sched/cputime: Fix omitted ticks passed in parameter tip-bot for Frederic Weisbecker

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.