Commit bcebdf846522056a84ba0b0cba5f5413868c9394

Authored by Frederic Weisbecker
1 parent fd25b4c2f2

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>

Showing 5 changed files with 23 additions and 18 deletions Side-by-side Diff

arch/ia64/kernel/time.c
... ... @@ -83,7 +83,7 @@
83 83  
84 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 88 cputime_t delta_utime;
89 89 struct thread_info *ti = task_thread_info(tsk);
... ... @@ -145,15 +145,6 @@
145 145 void vtime_account_idle(struct task_struct *tsk)
146 146 {
147 147 account_idle_time(vtime_delta(tsk));
148   -}
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 148 }
158 149  
159 150 #endif /* CONFIG_VIRT_CPU_ACCOUNTING */
arch/powerpc/kernel/time.c
... ... @@ -355,15 +355,15 @@
355 355 }
356 356  
357 357 /*
358   - * Transfer the user and system times accumulated in the paca
359   - * by the exception entry and exit code to the generic process
360   - * user and system time records.
  358 + * Transfer the user time accumulated in the paca
  359 + * by the exception entry and exit code to the generic
  360 + * process user time records.
361 361 * Must be called with interrupts disabled.
362   - * Assumes that vtime_account() has been called recently
363   - * (i.e. since the last entry from usermode) so that
  362 + * Assumes that vtime_account_system/idle() has been called
  363 + * recently (i.e. since the last entry from usermode) so that
364 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 368 cputime_t utime, utimescaled;
369 369  
... ... @@ -378,7 +378,7 @@
378 378 void vtime_task_switch(struct task_struct *prev)
379 379 {
380 380 vtime_account(prev);
381   - account_process_tick(prev, 0);
  381 + vtime_account_user(prev);
382 382 }
383 383  
384 384 #else /* ! CONFIG_VIRT_CPU_ACCOUNTING */
arch/s390/kernel/vtime.c
... ... @@ -112,7 +112,12 @@
112 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 122 if (do_account_vtime(tsk, HARDIRQ_OFFSET))
118 123 virt_timer_expire();
include/linux/kernel_stat.h
... ... @@ -127,7 +127,15 @@
127 127 extern void account_steal_time(cputime_t);
128 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 136 extern void account_process_tick(struct task_struct *, int user);
  137 +#endif
  138 +
131 139 extern void account_steal_ticks(unsigned long ticks);
132 140 extern void account_idle_ticks(unsigned long ticks);
133 141  
include/linux/vtime.h
... ... @@ -8,6 +8,7 @@
8 8 extern void vtime_account_system(struct task_struct *tsk);
9 9 extern void vtime_account_system_irqsafe(struct task_struct *tsk);
10 10 extern void vtime_account_idle(struct task_struct *tsk);
  11 +extern void vtime_account_user(struct task_struct *tsk);
11 12 extern void vtime_account(struct task_struct *tsk);
12 13 #else
13 14 static inline void vtime_task_switch(struct task_struct *prev) { }