summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/vtime.h13
-rw-r--r--kernel/sched/cputime.c6
2 files changed, 15 insertions, 4 deletions
diff --git a/include/linux/vtime.h b/include/linux/vtime.h
index ca23e8348f70..fa2196990f84 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 572721756359..9989c3f61723 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)