Skip to content

Commit

Permalink
sched/cputime: Introduce vtime accounting check for readers
Browse files Browse the repository at this point in the history
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 <fweisbec@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul E . McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1447948054-28668-7-git-send-email-fweisbec@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Dec 4, 2015
1 parent 55dbdcf commit e592539
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 12 additions & 1 deletion include/linux/vtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions kernel/sched/cputime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit e592539

Please sign in to comment.