sched/vtime: Introduce vtime_accounting_enabled_cpu()
authorFrederic Weisbecker <frederic@kernel.org>
Wed, 16 Oct 2019 02:56:55 +0000 (04:56 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 29 Oct 2019 09:01:15 +0000 (10:01 +0100)
This allows us to check if a remote CPU runs vtime accounting
(ie: is nohz_full). We'll need that to reliably support reading kcpustat
on nohz_full CPUs.

Also simplify a bit the condition in the local flavoured function while
at it.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J . Wysocki <rjw@rjwysocki.net>
Cc: Rik van Riel <riel@surriel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Wanpeng Li <wanpengli@tencent.com>
Cc: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Link: https://lkml.kernel.org/r/20191016025700.31277-10-frederic@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
include/linux/vtime.h

index eb2e7a19054b43ddd7cdb6b180afc947ca826f9f..e2733bf3354143fc48b6499cf621b3ab32614bed 100644 (file)
@@ -31,14 +31,14 @@ static inline bool vtime_accounting_enabled(void)
        return context_tracking_enabled();
 }
 
-static inline bool vtime_accounting_enabled_this_cpu(void)
+static inline bool vtime_accounting_enabled_cpu(int cpu)
 {
-       if (vtime_accounting_enabled()) {
-               if (context_tracking_enabled_this_cpu())
-                       return true;
-       }
+       return (vtime_accounting_enabled() && context_tracking_enabled_cpu(cpu));
+}
 
-       return false;
+static inline bool vtime_accounting_enabled_this_cpu(void)
+{
+       return (vtime_accounting_enabled() && context_tracking_enabled_this_cpu());
 }
 
 extern void vtime_task_switch_generic(struct task_struct *prev);
@@ -51,6 +51,7 @@ static inline void vtime_task_switch(struct task_struct *prev)
 
 #else /* !CONFIG_VIRT_CPU_ACCOUNTING */
 
+static inline bool vtime_accounting_enabled_cpu(int cpu) {return false; }
 static inline bool vtime_accounting_enabled_this_cpu(void) { return false; }
 static inline void vtime_task_switch(struct task_struct *prev) { }