From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932328AbcHKL6s (ORCPT ); Thu, 11 Aug 2016 07:58:48 -0400 Received: from terminus.zytor.com ([198.137.202.10]:53352 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752356AbcHKL6k (ORCPT ); Thu, 11 Aug 2016 07:58:40 -0400 Date: Thu, 11 Aug 2016 04:56:31 -0700 From: tip-bot for Wanpeng Li Message-ID: Cc: torvalds@linux-foundation.org, riel@redhat.com, linux-kernel@vger.kernel.org, wanpeng.li@hotmail.com, mingo@kernel.org, peterz@infradead.org, hpa@zytor.com, fweisbec@gmail.com, rkrcmar@redhat.com, pbonzini@redhat.com, tglx@linutronix.de Reply-To: wanpeng.li@hotmail.com, mingo@kernel.org, peterz@infradead.org, hpa@zytor.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, riel@redhat.com, pbonzini@redhat.com, tglx@linutronix.de, fweisbec@gmail.com, rkrcmar@redhat.com In-Reply-To: <1470893795-3527-1-git-send-email-wanpeng.li@hotmail.com> References: <1470893795-3527-1-git-send-email-wanpeng.li@hotmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/urgent] sched/cputime: Fix steal time accounting Git-Commit-ID: f9bcf1e0e0145323ba2cf72ecad5264ff3883eb1 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: f9bcf1e0e0145323ba2cf72ecad5264ff3883eb1 Gitweb: http://git.kernel.org/tip/f9bcf1e0e0145323ba2cf72ecad5264ff3883eb1 Author: Wanpeng Li AuthorDate: Thu, 11 Aug 2016 13:36:35 +0800 Committer: Ingo Molnar 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 Cc: Frederic Weisbecker Cc: Linus Torvalds Cc: Paolo Bonzini Cc: Peter Zijlstra (Intel) Cc: Peter Zijlstra Cc: Radim Cc: Rik van Riel Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1470893795-3527-1-git-send-email-wanpeng.li@hotmail.com Signed-off-by: Ingo Molnar --- 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); } /*