[PATCH 15/25] sched/vtime: Introduce vtime_accounting_enabled_cpu()

Frederic Weisbecker
2018-11-14T02:46:56Z

This allows us to check if a remote CPU runs vtime accounting
(ie: is nohz_full). We'll need that to reliably support "nice"
accounting on kcpustat.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Cc: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Rik van Riel <riel@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wanpeng Li <wanpengli@tencent.com>
Cc: Ingo Molnar <mingo@kernel.org>
---
include/linux/vtime.h | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/include/linux/vtime.h b/include/linux/vtime.h
index 82fed7a..a53f6ea 100644
--- a/include/linux/vtime.h
+++ b/include/linux/vtime.h
@@ -31,6 +31,16 @@ static inline bool vtime_accounting_enabled(void)
return context_tracking_enabled();
}

+static inline bool vtime_accounting_enabled_cpu(int cpu)
+{
+ if (vtime_accounting_enabled()) {
+ if (context_tracking_enabled_cpu(cpu))
+ return true;
+ }
+
+ return false;
+}
+
static inline bool vtime_accounting_enabled_this_cpu(void)
{
if (vtime_accounting_enabled()) {
@@ -51,6 +61,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) { }

--
2.7.4