summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2015-11-19 10:47:33 -0500
committerIngo Molnar <mingo@kernel.org>2015-12-04 04:34:45 -0500
commite592539466380279a9e6e6fdfe4545aa54f22593 (patch)
treede661ef2867d8a78877534cde15fcbacc7262586
parent55dbdcfa05533f44c9416070b8a9f6432b22314a (diff)
sched/cputime: Introduce vtime accounting check for readers
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>
-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; }
17#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */ 17#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
18 18
19#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN 19#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
20/*
21 * Checks if vtime is enabled on some CPU. Cputime readers want to be careful
22 * in that case and compute the tickless cputime.
23 * For now vtime state is tied to context tracking. We might want to decouple
24 * those later if necessary.
25 */
26static inline bool vtime_accounting_enabled(void)
27{
28 return context_tracking_is_enabled();
29}
30
20static inline bool vtime_accounting_cpu_enabled(void) 31static inline bool vtime_accounting_cpu_enabled(void)
21{ 32{
22 if (context_tracking_is_enabled()) { 33 if (vtime_accounting_enabled()) {
23 if (context_tracking_cpu_is_enabled()) 34 if (context_tracking_cpu_is_enabled())
24 return true; 35 return true;
25 } 36 }
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)
788 unsigned int seq; 788 unsigned int seq;
789 cputime_t gtime; 789 cputime_t gtime;
790 790
791 if (!context_tracking_is_enabled()) 791 if (!vtime_accounting_enabled())
792 return t->gtime; 792 return t->gtime;
793 793
794 do { 794 do {
@@ -853,7 +853,7 @@ void task_cputime(struct task_struct *t, cputime_t *utime, cputime_t *stime)
853{ 853{
854 cputime_t udelta, sdelta; 854 cputime_t udelta, sdelta;
855 855
856 if (!context_tracking_is_enabled()) { 856 if (!vtime_accounting_enabled()) {
857 if (utime) 857 if (utime)
858 *utime = t->utime; 858 *utime = t->utime;
859 if (stime) 859 if (stime)
@@ -874,7 +874,7 @@ void task_cputime_scaled(struct task_struct *t,
874{ 874{
875 cputime_t udelta, sdelta; 875 cputime_t udelta, sdelta;
876 876
877 if (!context_tracking_is_enabled()) { 877 if (!vtime_accounting_enabled()) {
878 if (utimescaled) 878 if (utimescaled)
879 *utimescaled = t->utimescaled; 879 *utimescaled = t->utimescaled;
880 if (stimescaled) 880 if (stimescaled)