diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2012-11-13 17:51:06 -0500 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2012-11-19 10:41:21 -0500 |
commit | bcebdf846522056a84ba0b0cba5f5413868c9394 (patch) | |
tree | 76e007a63351abe84a9713e3b182463c230d1053 | |
parent | fd25b4c2f226de818e1d2b71e3e681d28bcaf5ba (diff) |
vtime: Explicitly account pending user time on process tick
All vtime implementations just flush the user time on process
tick. Consolidate that in generic code by calling a user time
accounting helper. This avoids an indirect call in ia64 and
prepare to also consolidate vtime context switch code.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
-rw-r--r-- | arch/ia64/kernel/time.c | 11 | ||||
-rw-r--r-- | arch/powerpc/kernel/time.c | 14 | ||||
-rw-r--r-- | arch/s390/kernel/vtime.c | 7 | ||||
-rw-r--r-- | include/linux/kernel_stat.h | 8 | ||||
-rw-r--r-- | include/linux/vtime.h | 1 |
5 files changed, 23 insertions, 18 deletions
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c index f6388216080d..834c78bd3b5f 100644 --- a/arch/ia64/kernel/time.c +++ b/arch/ia64/kernel/time.c | |||
@@ -83,7 +83,7 @@ static struct clocksource *itc_clocksource; | |||
83 | 83 | ||
84 | extern cputime_t cycle_to_cputime(u64 cyc); | 84 | extern cputime_t cycle_to_cputime(u64 cyc); |
85 | 85 | ||
86 | static void vtime_account_user(struct task_struct *tsk) | 86 | void vtime_account_user(struct task_struct *tsk) |
87 | { | 87 | { |
88 | cputime_t delta_utime; | 88 | cputime_t delta_utime; |
89 | struct thread_info *ti = task_thread_info(tsk); | 89 | struct thread_info *ti = task_thread_info(tsk); |
@@ -147,15 +147,6 @@ void vtime_account_idle(struct task_struct *tsk) | |||
147 | account_idle_time(vtime_delta(tsk)); | 147 | account_idle_time(vtime_delta(tsk)); |
148 | } | 148 | } |
149 | 149 | ||
150 | /* | ||
151 | * Called from the timer interrupt handler to charge accumulated user time | ||
152 | * to the current process. Must be called with interrupts disabled. | ||
153 | */ | ||
154 | void account_process_tick(struct task_struct *p, int user_tick) | ||
155 | { | ||
156 | vtime_account_user(p); | ||
157 | } | ||
158 | |||
159 | #endif /* CONFIG_VIRT_CPU_ACCOUNTING */ | 150 | #endif /* CONFIG_VIRT_CPU_ACCOUNTING */ |
160 | 151 | ||
161 | static irqreturn_t | 152 | static irqreturn_t |
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index ce4cb772dc78..a667aaf85846 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
@@ -355,15 +355,15 @@ void vtime_account_idle(struct task_struct *tsk) | |||
355 | } | 355 | } |
356 | 356 | ||
357 | /* | 357 | /* |
358 | * Transfer the user and system times accumulated in the paca | 358 | * Transfer the user time accumulated in the paca |
359 | * by the exception entry and exit code to the generic process | 359 | * by the exception entry and exit code to the generic |
360 | * user and system time records. | 360 | * process user time records. |
361 | * Must be called with interrupts disabled. | 361 | * Must be called with interrupts disabled. |
362 | * Assumes that vtime_account() has been called recently | 362 | * Assumes that vtime_account_system/idle() has been called |
363 | * (i.e. since the last entry from usermode) so that | 363 | * recently (i.e. since the last entry from usermode) so that |
364 | * get_paca()->user_time_scaled is up to date. | 364 | * get_paca()->user_time_scaled is up to date. |
365 | */ | 365 | */ |
366 | void account_process_tick(struct task_struct *tsk, int user_tick) | 366 | void vtime_account_user(struct task_struct *tsk) |
367 | { | 367 | { |
368 | cputime_t utime, utimescaled; | 368 | cputime_t utime, utimescaled; |
369 | 369 | ||
@@ -378,7 +378,7 @@ void account_process_tick(struct task_struct *tsk, int user_tick) | |||
378 | void vtime_task_switch(struct task_struct *prev) | 378 | void vtime_task_switch(struct task_struct *prev) |
379 | { | 379 | { |
380 | vtime_account(prev); | 380 | vtime_account(prev); |
381 | account_process_tick(prev, 0); | 381 | vtime_account_user(prev); |
382 | } | 382 | } |
383 | 383 | ||
384 | #else /* ! CONFIG_VIRT_CPU_ACCOUNTING */ | 384 | #else /* ! CONFIG_VIRT_CPU_ACCOUNTING */ |
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c index 80d1dbc5d42e..7c6d861a1a40 100644 --- a/arch/s390/kernel/vtime.c +++ b/arch/s390/kernel/vtime.c | |||
@@ -112,7 +112,12 @@ void vtime_task_switch(struct task_struct *prev) | |||
112 | S390_lowcore.system_timer = ti->system_timer; | 112 | S390_lowcore.system_timer = ti->system_timer; |
113 | } | 113 | } |
114 | 114 | ||
115 | void account_process_tick(struct task_struct *tsk, int user_tick) | 115 | /* |
116 | * In s390, accounting pending user time also implies | ||
117 | * accounting system time in order to correctly compute | ||
118 | * the stolen time accounting. | ||
119 | */ | ||
120 | void vtime_account_user(struct task_struct *tsk) | ||
116 | { | 121 | { |
117 | if (do_account_vtime(tsk, HARDIRQ_OFFSET)) | 122 | if (do_account_vtime(tsk, HARDIRQ_OFFSET)) |
118 | virt_timer_expire(); | 123 | virt_timer_expire(); |
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h index 1865b1f29770..66b70780e910 100644 --- a/include/linux/kernel_stat.h +++ b/include/linux/kernel_stat.h | |||
@@ -127,7 +127,15 @@ extern void account_system_time(struct task_struct *, int, cputime_t, cputime_t) | |||
127 | extern void account_steal_time(cputime_t); | 127 | extern void account_steal_time(cputime_t); |
128 | extern void account_idle_time(cputime_t); | 128 | extern void account_idle_time(cputime_t); |
129 | 129 | ||
130 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING | ||
131 | static inline void account_process_tick(struct task_struct *tsk, int user) | ||
132 | { | ||
133 | vtime_account_user(tsk); | ||
134 | } | ||
135 | #else | ||
130 | extern void account_process_tick(struct task_struct *, int user); | 136 | extern void account_process_tick(struct task_struct *, int user); |
137 | #endif | ||
138 | |||
131 | extern void account_steal_ticks(unsigned long ticks); | 139 | extern void account_steal_ticks(unsigned long ticks); |
132 | extern void account_idle_ticks(unsigned long ticks); | 140 | extern void account_idle_ticks(unsigned long ticks); |
133 | 141 | ||
diff --git a/include/linux/vtime.h b/include/linux/vtime.h index 5ad13c325deb..ae30ab58431a 100644 --- a/include/linux/vtime.h +++ b/include/linux/vtime.h | |||
@@ -8,6 +8,7 @@ extern void vtime_task_switch(struct task_struct *prev); | |||
8 | extern void vtime_account_system(struct task_struct *tsk); | 8 | extern void vtime_account_system(struct task_struct *tsk); |
9 | extern void vtime_account_system_irqsafe(struct task_struct *tsk); | 9 | extern void vtime_account_system_irqsafe(struct task_struct *tsk); |
10 | extern void vtime_account_idle(struct task_struct *tsk); | 10 | extern void vtime_account_idle(struct task_struct *tsk); |
11 | extern void vtime_account_user(struct task_struct *tsk); | ||
11 | extern void vtime_account(struct task_struct *tsk); | 12 | extern void vtime_account(struct task_struct *tsk); |
12 | #else | 13 | #else |
13 | static inline void vtime_task_switch(struct task_struct *prev) { } | 14 | static inline void vtime_task_switch(struct task_struct *prev) { } |