sched/cputime: Fix fold steal time into idle time accounting
PATCH 1/1 sched/cputime: Fix fold steal time into idle time accounting
From: Wanpeng Li <[email protected]>
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).
--- kernel/sched/cputime.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/sched/cputime.c +9 -2
@@ -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); }/*
Signature · 1 line
1.9.1
tip-bot for Wanpeng Li
merge bot[tip:sched/urgent] sched/cputime: Fix steal time accounting
sched/cputime: Fix steal time accounting
Commit-ID: f9bcf1e0e0145323ba2cf72ecad5264ff3883eb1 Gitweb: http://git.kernel.org/tip/f9bcf1e0e0145323ba2cf72ecad5264ff3883eb1 Author: Wanpeng Li <[email protected]> AuthorDate: Thu, 11 Aug 2016 13:36:35 +0800 Committer: Ingo Molnar <[email protected]> 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).
--- kernel/sched/cputime.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/sched/cputime.c +9 -2
@@ -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); }/*
PATCH 1/1 cputime: Fix omitted ticks passed in parameter (was: Re: [tip:sched/urgent] sched/cputime: Fix steal time accounting)
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.
--- kernel/sched/cputime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/cputime.c +2 -1
@@ -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)
Signature · 1 line
2.7.0
Re: [PATCH] cputime: Fix omitted ticks passed in parameter (was: Re: [tip:sched/urgent] sched/cputime: Fix steal time accounting)
2016-08-11 20:58 GMT+08:00 Frederic Weisbecker <[email protected]>:
Quoted 6 lines
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
tip-bot for Frederic Weisbecker
merge bot[tip:sched/urgent] sched/cputime: Fix omitted ticks passed in parameter
In reply to Frederic Weisbeckersched/cputime: Fix omitted ticks passed in parameter
Commit-ID: 26f2c75cd2cf10a6120ef02ca9a94db77cc9c8e0 Gitweb: http://git.kernel.org/tip/26f2c75cd2cf10a6120ef02ca9a94db77cc9c8e0 Author: Frederic Weisbecker <[email protected]> AuthorDate: Thu, 11 Aug 2016 14:58:24 +0200 Committer: Ingo Molnar <[email protected]> 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.
--- kernel/sched/cputime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/cputime.c +2 -1
@@ -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)