Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756097AbbLDL5X (ORCPT ); Fri, 4 Dec 2015 06:57:23 -0500 Received: from terminus.zytor.com ([198.137.202.10]:60224 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752282AbbLDL5V (ORCPT ); Fri, 4 Dec 2015 06:57:21 -0500 Date: Fri, 4 Dec 2015 03:56:26 -0800 From: tip-bot for Frederic Weisbecker Message-ID: Cc: h-shimamoto@ct.jp.nec.com, lcapitulino@redhat.com, fweisbec@gmail.com, efault@gmx.de, cl@linux.com, torvalds@linux-foundation.org, hpa@zytor.com, mingo@kernel.org, cmetcalf@ezchip.com, peterz@infradead.org, tglx@linutronix.de, riel@redhat.com, paulmck@linux.vnet.ibm.com, linux-kernel@vger.kernel.org Reply-To: efault@gmx.de, fweisbec@gmail.com, lcapitulino@redhat.com, h-shimamoto@ct.jp.nec.com, cl@linux.com, mingo@kernel.org, hpa@zytor.com, torvalds@linux-foundation.org, cmetcalf@ezchip.com, peterz@infradead.org, riel@redhat.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com In-Reply-To: <1447948054-28668-7-git-send-email-fweisbec@gmail.com> References: <1447948054-28668-7-git-send-email-fweisbec@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/cputime: Introduce vtime accounting check for readers Git-Commit-ID: e592539466380279a9e6e6fdfe4545aa54f22593 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 Content-Length: 3643 Lines: 100 Commit-ID: e592539466380279a9e6e6fdfe4545aa54f22593 Gitweb: http://git.kernel.org/tip/e592539466380279a9e6e6fdfe4545aa54f22593 Author: Frederic Weisbecker AuthorDate: Thu, 19 Nov 2015 16:47:33 +0100 Committer: Ingo Molnar CommitDate: Fri, 4 Dec 2015 10:34:45 +0100 sched/cputime: Introduce vtime accounting check for readers Readers need to know if vtime runs at all on some CPU somewhere, this is a fast-path check to determine if we need to check further the need to add up any tickless cputime delta. This fast path check uses context tracking state because vtime is tied to context tracking as of now. This check appears to be confusing though so lets use a vtime function that deals with context tracking details in vtime implementation instead. Signed-off-by: Frederic Weisbecker Signed-off-by: Peter Zijlstra (Intel) Cc: Chris Metcalf Cc: Christoph Lameter Cc: Hiroshi Shimamoto Cc: Linus Torvalds Cc: Luiz Capitulino Cc: Mike Galbraith Cc: Paul E . McKenney Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Rik van Riel Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1447948054-28668-7-git-send-email-fweisbec@gmail.com Signed-off-by: Ingo Molnar --- include/linux/vtime.h | 13 ++++++++++++- kernel/sched/cputime.c | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/linux/vtime.h b/include/linux/vtime.h index ca23e83..fa21969 100644 --- a/include/linux/vtime.h +++ b/include/linux/vtime.h @@ -17,9 +17,20 @@ static inline bool vtime_accounting_cpu_enabled(void) { return true; } #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */ #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN +/* + * Checks if vtime is enabled on some CPU. Cputime readers want to be careful + * in that case and compute the tickless cputime. + * For now vtime state is tied to context tracking. We might want to decouple + * those later if necessary. + */ +static inline bool vtime_accounting_enabled(void) +{ + return context_tracking_is_enabled(); +} + static inline bool vtime_accounting_cpu_enabled(void) { - if (context_tracking_is_enabled()) { + if (vtime_accounting_enabled()) { if (context_tracking_cpu_is_enabled()) return true; } diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 5727217..9989c3f 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -788,7 +788,7 @@ cputime_t task_gtime(struct task_struct *t) unsigned int seq; cputime_t gtime; - if (!context_tracking_is_enabled()) + if (!vtime_accounting_enabled()) return t->gtime; do { @@ -853,7 +853,7 @@ void task_cputime(struct task_struct *t, cputime_t *utime, cputime_t *stime) { cputime_t udelta, sdelta; - if (!context_tracking_is_enabled()) { + if (!vtime_accounting_enabled()) { if (utime) *utime = t->utime; if (stime) @@ -874,7 +874,7 @@ void task_cputime_scaled(struct task_struct *t, { cputime_t udelta, sdelta; - if (!context_tracking_is_enabled()) { + if (!vtime_accounting_enabled()) { if (utimescaled) *utimescaled = t->utimescaled; if (stimescaled) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/