sched/vtime: Introduce vtime_accounting_enabled_cpu()
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 <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Jacek Anaszewski <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Pavel Machek <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Rafael J . Wysocki <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Viresh Kumar <[email protected]>
Cc: Wanpeng Li <[email protected]>
Cc: Yauheni Kaliuta <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
diff --git a/include/linux/vtime.h b/include/linux/vtime.h
index eb2e7a1..e2733bf 100644
--- a/include/linux/vtime.h
+++ b/include/linux/vtime.h
@@ -31,14 +31,14 @@ static inline bool vtime_accounting_enabled(void)
return context_tracking_enabled();
}
+static inline bool vtime_accounting_enabled_cpu(int cpu)
+{
+ return (vtime_accounting_enabled() && context_tracking_enabled_cpu(cpu));
+}
+
static inline bool vtime_accounting_enabled_this_cpu(void)
{
- if (vtime_accounting_enabled()) {
- if (context_tracking_enabled_this_cpu())
- return true;
- }
-
- return false;
+ 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) { }