diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2012-11-13 18:24:25 -0500 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2012-11-19 10:41:32 -0500 |
commit | e3942ba04052364d3c6454103362cafd87456010 (patch) | |
tree | 31e5cd4013fd140cb3e50ad6147382798bc88631 | |
parent | bcebdf846522056a84ba0b0cba5f5413868c9394 (diff) |
vtime: Consolidate a bit the ctx switch code
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>
-rw-r--r-- | arch/ia64/include/asm/cputime.h | 2 | ||||
-rw-r--r-- | arch/ia64/kernel/time.c | 9 | ||||
-rw-r--r-- | arch/powerpc/include/asm/cputime.h | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/time.c | 6 | ||||
-rw-r--r-- | arch/s390/include/asm/cputime.h | 1 | ||||
-rw-r--r-- | kernel/sched/cputime.c | 13 |
6 files changed, 19 insertions, 14 deletions
diff --git a/arch/ia64/include/asm/cputime.h b/arch/ia64/include/asm/cputime.h index 3deac956d325..7fcf7f08ab06 100644 --- a/arch/ia64/include/asm/cputime.h +++ b/arch/ia64/include/asm/cputime.h | |||
@@ -103,5 +103,7 @@ static inline void cputime_to_timeval(const cputime_t ct, struct timeval *val) | |||
103 | #define cputime64_to_clock_t(__ct) \ | 103 | #define cputime64_to_clock_t(__ct) \ |
104 | cputime_to_clock_t((__force cputime_t)__ct) | 104 | cputime_to_clock_t((__force cputime_t)__ct) |
105 | 105 | ||
106 | extern void arch_vtime_task_switch(struct task_struct *tsk); | ||
107 | |||
106 | #endif /* CONFIG_VIRT_CPU_ACCOUNTING */ | 108 | #endif /* CONFIG_VIRT_CPU_ACCOUNTING */ |
107 | #endif /* __IA64_CPUTIME_H */ | 109 | #endif /* __IA64_CPUTIME_H */ |
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c index 834c78bd3b5f..c9a7d2ebe089 100644 --- a/arch/ia64/kernel/time.c +++ b/arch/ia64/kernel/time.c | |||
@@ -100,18 +100,11 @@ void vtime_account_user(struct task_struct *tsk) | |||
100 | * accumulated times to the current process, and to prepare accounting on | 100 | * accumulated times to the current process, and to prepare accounting on |
101 | * the next process. | 101 | * the next process. |
102 | */ | 102 | */ |
103 | void vtime_task_switch(struct task_struct *prev) | 103 | void arch_vtime_task_switch(struct task_struct *prev) |
104 | { | 104 | { |
105 | struct thread_info *pi = task_thread_info(prev); | 105 | struct thread_info *pi = task_thread_info(prev); |
106 | struct thread_info *ni = task_thread_info(current); | 106 | struct thread_info *ni = task_thread_info(current); |
107 | 107 | ||
108 | if (idle_task(smp_processor_id()) != prev) | ||
109 | vtime_account_system(prev); | ||
110 | else | ||
111 | vtime_account_idle(prev); | ||
112 | |||
113 | vtime_account_user(prev); | ||
114 | |||
115 | pi->ac_stamp = ni->ac_stamp; | 108 | pi->ac_stamp = ni->ac_stamp; |
116 | ni->ac_stime = ni->ac_utime = 0; | 109 | ni->ac_stime = ni->ac_utime = 0; |
117 | } | 110 | } |
diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h index 487d46ff68a1..483733bd06d4 100644 --- a/arch/powerpc/include/asm/cputime.h +++ b/arch/powerpc/include/asm/cputime.h | |||
@@ -228,6 +228,8 @@ static inline cputime_t clock_t_to_cputime(const unsigned long clk) | |||
228 | 228 | ||
229 | #define cputime64_to_clock_t(ct) cputime_to_clock_t((cputime_t)(ct)) | 229 | #define cputime64_to_clock_t(ct) cputime_to_clock_t((cputime_t)(ct)) |
230 | 230 | ||
231 | static inline void arch_vtime_task_switch(struct task_struct *tsk) { } | ||
232 | |||
231 | #endif /* __KERNEL__ */ | 233 | #endif /* __KERNEL__ */ |
232 | #endif /* CONFIG_VIRT_CPU_ACCOUNTING */ | 234 | #endif /* CONFIG_VIRT_CPU_ACCOUNTING */ |
233 | #endif /* __POWERPC_CPUTIME_H */ | 235 | #endif /* __POWERPC_CPUTIME_H */ |
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index a667aaf85846..3486cfad4a63 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
@@ -375,12 +375,6 @@ void vtime_account_user(struct task_struct *tsk) | |||
375 | account_user_time(tsk, utime, utimescaled); | 375 | account_user_time(tsk, utime, utimescaled); |
376 | } | 376 | } |
377 | 377 | ||
378 | void vtime_task_switch(struct task_struct *prev) | ||
379 | { | ||
380 | vtime_account(prev); | ||
381 | vtime_account_user(prev); | ||
382 | } | ||
383 | |||
384 | #else /* ! CONFIG_VIRT_CPU_ACCOUNTING */ | 378 | #else /* ! CONFIG_VIRT_CPU_ACCOUNTING */ |
385 | #define calc_cputime_factors() | 379 | #define calc_cputime_factors() |
386 | #endif | 380 | #endif |
diff --git a/arch/s390/include/asm/cputime.h b/arch/s390/include/asm/cputime.h index 023d5ae24482..d2ff41370c0c 100644 --- a/arch/s390/include/asm/cputime.h +++ b/arch/s390/include/asm/cputime.h | |||
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | 15 | ||
16 | #define __ARCH_HAS_VTIME_ACCOUNT | 16 | #define __ARCH_HAS_VTIME_ACCOUNT |
17 | #define __ARCH_HAS_VTIME_TASK_SWITCH | ||
17 | 18 | ||
18 | /* We want to use full resolution of the CPU timer: 2**-12 micro-seconds. */ | 19 | /* We want to use full resolution of the CPU timer: 2**-12 micro-seconds. */ |
19 | 20 | ||
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index c0aa1ba752ea..2e8d34aac97e 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c | |||
@@ -443,6 +443,19 @@ void vtime_account_system_irqsafe(struct task_struct *tsk) | |||
443 | } | 443 | } |
444 | EXPORT_SYMBOL_GPL(vtime_account_system_irqsafe); | 444 | EXPORT_SYMBOL_GPL(vtime_account_system_irqsafe); |
445 | 445 | ||
446 | #ifndef __ARCH_HAS_VTIME_TASK_SWITCH | ||
447 | void vtime_task_switch(struct task_struct *prev) | ||
448 | { | ||
449 | if (is_idle_task(prev)) | ||
450 | vtime_account_idle(prev); | ||
451 | else | ||
452 | vtime_account_system(prev); | ||
453 | |||
454 | vtime_account_user(prev); | ||
455 | arch_vtime_task_switch(prev); | ||
456 | } | ||
457 | #endif | ||
458 | |||
446 | /* | 459 | /* |
447 | * Archs that account the whole time spent in the idle task | 460 | * Archs that account the whole time spent in the idle task |
448 | * (outside irq) as idle time can rely on this and just implement | 461 | * (outside irq) as idle time can rely on this and just implement |