]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
vtime: Consolidate a bit the ctx switch code
authorFrederic Weisbecker <fweisbec@gmail.com>
Tue, 13 Nov 2012 23:24:25 +0000 (00:24 +0100)
committerFrederic Weisbecker <fweisbec@gmail.com>
Mon, 19 Nov 2012 15:41:32 +0000 (16:41 +0100)
On ia64 and powerpc, vtime context switch only consists
in flushing system and user pending time, plus a few
arch housekeeping.

Consolidate that into a generic implementation. s390 is
a special case because pending user and system time accounting
there is hard to dissociate. So it's keeping its own implementation.

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>
arch/ia64/include/asm/cputime.h
arch/ia64/kernel/time.c
arch/powerpc/include/asm/cputime.h
arch/powerpc/kernel/time.c
arch/s390/include/asm/cputime.h
kernel/sched/cputime.c

index 3deac956d325f3f3331d31a4256925dab758e365..7fcf7f08ab0623ef87d62fb7ef001023b2871ed7 100644 (file)
@@ -103,5 +103,7 @@ static inline void cputime_to_timeval(const cputime_t ct, struct timeval *val)
 #define cputime64_to_clock_t(__ct)     \
        cputime_to_clock_t((__force cputime_t)__ct)
 
+extern void arch_vtime_task_switch(struct task_struct *tsk);
+
 #endif /* CONFIG_VIRT_CPU_ACCOUNTING */
 #endif /* __IA64_CPUTIME_H */
index 834c78bd3b5f0e52ffc53dac88c248b82f0628c4..c9a7d2ebe0890fd9ea441bcc63f9f178a2565c10 100644 (file)
@@ -100,18 +100,11 @@ void vtime_account_user(struct task_struct *tsk)
  * accumulated times to the current process, and to prepare accounting on
  * the next process.
  */
-void vtime_task_switch(struct task_struct *prev)
+void arch_vtime_task_switch(struct task_struct *prev)
 {
        struct thread_info *pi = task_thread_info(prev);
        struct thread_info *ni = task_thread_info(current);
 
-       if (idle_task(smp_processor_id()) != prev)
-               vtime_account_system(prev);
-       else
-               vtime_account_idle(prev);
-
-       vtime_account_user(prev);
-
        pi->ac_stamp = ni->ac_stamp;
        ni->ac_stime = ni->ac_utime = 0;
 }
index 487d46ff68a12f6581e5c25ee211c3ed2731dcc9..483733bd06d4e9bda0689c4fba66849e2471b7c2 100644 (file)
@@ -228,6 +228,8 @@ static inline cputime_t clock_t_to_cputime(const unsigned long clk)
 
 #define cputime64_to_clock_t(ct)       cputime_to_clock_t((cputime_t)(ct))
 
+static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
+
 #endif /* __KERNEL__ */
 #endif /* CONFIG_VIRT_CPU_ACCOUNTING */
 #endif /* __POWERPC_CPUTIME_H */
index a667aaf85846b017708282226d315ad88957dfa0..3486cfad4a63fc08e974a4891ecf3397b473cd60 100644 (file)
@@ -375,12 +375,6 @@ void vtime_account_user(struct task_struct *tsk)
        account_user_time(tsk, utime, utimescaled);
 }
 
-void vtime_task_switch(struct task_struct *prev)
-{
-       vtime_account(prev);
-       vtime_account_user(prev);
-}
-
 #else /* ! CONFIG_VIRT_CPU_ACCOUNTING */
 #define calc_cputime_factors()
 #endif
index 023d5ae24482f188b984e269923471649c71502a..d2ff41370c0c53e7a4e7cf5e7801c3786be7a88f 100644 (file)
@@ -14,6 +14,7 @@
 
 
 #define __ARCH_HAS_VTIME_ACCOUNT
+#define __ARCH_HAS_VTIME_TASK_SWITCH
 
 /* We want to use full resolution of the CPU timer: 2**-12 micro-seconds. */
 
index c0aa1ba752ea997f8c82f094d70ddc1015911e94..2e8d34aac97e63000aa91339b4dd9fe9f041f2fe 100644 (file)
@@ -443,6 +443,19 @@ void vtime_account_system_irqsafe(struct task_struct *tsk)
 }
 EXPORT_SYMBOL_GPL(vtime_account_system_irqsafe);
 
+#ifndef __ARCH_HAS_VTIME_TASK_SWITCH
+void vtime_task_switch(struct task_struct *prev)
+{
+       if (is_idle_task(prev))
+               vtime_account_idle(prev);
+       else
+               vtime_account_system(prev);
+
+       vtime_account_user(prev);
+       arch_vtime_task_switch(prev);
+}
+#endif
+
 /*
  * Archs that account the whole time spent in the idle task
  * (outside irq) as idle time can rely on this and just implement