diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2012-09-08 10:14:02 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2012-09-25 09:42:37 -0400 |
commit | a7e1a9e3af71b45ecae2dae35851f238117b317d (patch) | |
tree | 8b1d15d63779ba13d7884288c96a3510b7fde4b6 /arch/ia64/kernel | |
parent | bf9fae9f5e4ca8dce4708812f9ad6281e61df109 (diff) |
vtime: Consolidate system/idle context detection
Move the code that finds out to which context we account the
cputime into generic layer.
Archs that consider the whole time spent in the idle task as idle
time (ia64, powerpc) can rely on the generic vtime_account()
and implement vtime_account_system() and vtime_account_idle(),
letting the generic code to decide when to call which API.
Archs that have their own meaning of idle time, such as s390
that only considers the time spent in CPU low power mode as idle
time, can just override vtime_account().
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.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>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Diffstat (limited to 'arch/ia64/kernel')
-rw-r--r-- | arch/ia64/kernel/time.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c index 16bb6eda879d..01cd43e491cd 100644 --- a/arch/ia64/kernel/time.c +++ b/arch/ia64/kernel/time.c | |||
@@ -116,29 +116,32 @@ void vtime_task_switch(struct task_struct *prev) | |||
116 | * Account time for a transition between system, hard irq or soft irq state. | 116 | * Account time for a transition between system, hard irq or soft irq state. |
117 | * Note that this function is called with interrupts enabled. | 117 | * Note that this function is called with interrupts enabled. |
118 | */ | 118 | */ |
119 | void vtime_account(struct task_struct *tsk) | 119 | static cputime_t vtime_delta(struct task_struct *tsk) |
120 | { | 120 | { |
121 | struct thread_info *ti = task_thread_info(tsk); | 121 | struct thread_info *ti = task_thread_info(tsk); |
122 | unsigned long flags; | ||
123 | cputime_t delta_stime; | 122 | cputime_t delta_stime; |
124 | __u64 now; | 123 | __u64 now; |
125 | 124 | ||
126 | local_irq_save(flags); | ||
127 | |||
128 | now = ia64_get_itc(); | 125 | now = ia64_get_itc(); |
129 | 126 | ||
130 | delta_stime = cycle_to_cputime(ti->ac_stime + (now - ti->ac_stamp)); | 127 | delta_stime = cycle_to_cputime(ti->ac_stime + (now - ti->ac_stamp)); |
131 | if (irq_count() || idle_task(smp_processor_id()) != tsk) | ||
132 | account_system_time(tsk, 0, delta_stime, delta_stime); | ||
133 | else | ||
134 | account_idle_time(delta_stime); | ||
135 | ti->ac_stime = 0; | 128 | ti->ac_stime = 0; |
136 | |||
137 | ti->ac_stamp = now; | 129 | ti->ac_stamp = now; |
138 | 130 | ||
139 | local_irq_restore(flags); | 131 | return delta_stime; |
132 | } | ||
133 | |||
134 | void vtime_account_system(struct task_struct *tsk) | ||
135 | { | ||
136 | cputime_t delta = vtime_delta(tsk); | ||
137 | |||
138 | account_system_time(tsk, 0, delta, delta); | ||
139 | } | ||
140 | |||
141 | void vtime_account_idle(struct task_struct *tsk) | ||
142 | { | ||
143 | account_idle_time(vtime_delta(tsk)); | ||
140 | } | 144 | } |
141 | EXPORT_SYMBOL_GPL(vtime_account); | ||
142 | 145 | ||
143 | /* | 146 | /* |
144 | * Called from the timer interrupt handler to charge accumulated user time | 147 | * Called from the timer interrupt handler to charge accumulated user time |