Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1460190 > unrolled thread

[PATCH] sched/cputime: Fix fold steal time into idle time accounting

Started byWanpeng Li <kernellwp@gmail.com>
First post2016-08-11 07:50 +0200
Last post2016-08-11 18:30 +0200
Articles 5 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] sched/cputime: Fix fold steal time into idle time accounting Wanpeng Li <kernellwp@gmail.com> - 2016-08-11 07:50 +0200
    [tip:sched/urgent] sched/cputime: Fix steal time accounting tip-bot for Wanpeng Li <tipbot@zytor.com> - 2016-08-11 14:00 +0200
      [PATCH] cputime: Fix omitted ticks passed in parameter (was: Re:  [tip:sched/urgent] sched/cputime: Fix steal time accounting) Frederic Weisbecker <fweisbec@gmail.com> - 2016-08-11 15:00 +0200
        Re: [PATCH] cputime: Fix omitted ticks passed in parameter (was: Re:  [tip:sched/urgent] sched/cputime: Fix steal time accounting) Wanpeng Li <kernellwp@gmail.com> - 2016-08-11 15:10 +0200
        [tip:sched/urgent] sched/cputime: Fix omitted ticks passed in  parameter tip-bot for Frederic Weisbecker <tipbot@zytor.com> - 2016-08-11 18:30 +0200

#1460190 — [PATCH] sched/cputime: Fix fold steal time into idle time accounting

FromWanpeng Li <kernellwp@gmail.com>
Date2016-08-11 07:50 +0200
Subject[PATCH] sched/cputime: Fix fold steal time into idle time accounting
Message-ID<s4R2p-7bt-15@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1460429 — [tip:sched/urgent] sched/cputime: Fix steal time accounting

Fromtip-bot for Wanpeng Li <tipbot@zytor.com>
Date2016-08-11 14:00 +0200
Subject[tip:sched/urgent] sched/cputime: Fix steal time accounting
Message-ID<s4WOt-3kP-21@gated-at.bofh.it>
In reply to#1460190
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);
 }
 
 /*

[toc] | [prev] | [next] | [standalone]


#1460495 — [PATCH] cputime: Fix omitted ticks passed in parameter (was: Re: [tip:sched/urgent] sched/cputime: Fix steal time accounting)

FromFrederic Weisbecker <fweisbec@gmail.com>
Date2016-08-11 15:00 +0200
Subject[PATCH] cputime: Fix omitted ticks passed in parameter (was: Re: [tip:sched/urgent] sched/cputime: Fix steal time accounting)
Message-ID<s4XKx-3Wr-11@gated-at.bofh.it>
In reply to#1460429
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

[toc] | [prev] | [next] | [standalone]


#1460501 — Re: [PATCH] cputime: Fix omitted ticks passed in parameter (was: Re: [tip:sched/urgent] sched/cputime: Fix steal time accounting)

FromWanpeng Li <kernellwp@gmail.com>
Date2016-08-11 15:10 +0200
SubjectRe: [PATCH] cputime: Fix omitted ticks passed in parameter (was: Re: [tip:sched/urgent] sched/cputime: Fix steal time accounting)
Message-ID<s4XUd-4eY-15@gated-at.bofh.it>
In reply to#1460495
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

[toc] | [prev] | [next] | [standalone]


#1460651 — [tip:sched/urgent] sched/cputime: Fix omitted ticks passed in parameter

Fromtip-bot for Frederic Weisbecker <tipbot@zytor.com>
Date2016-08-11 18:30 +0200
Subject[tip:sched/urgent] sched/cputime: Fix omitted ticks passed in parameter
Message-ID<s511L-6al-9@gated-at.bofh.it>
In reply to#1460495
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)

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web