diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2012-09-08 12:00:02 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2012-09-25 09:42:57 -0400 |
commit | 5bf412cd769eb5830fb3716d4b2b222b6a5515ff (patch) | |
tree | a3b8ed1f602be50a3d47e5cede7fb107c0575fc4 /arch/ia64 | |
parent | a7e1a9e3af71b45ecae2dae35851f238117b317d (diff) |
ia64: Consolidate user vtime accounting
Factorize the code that accounts user time into a
single function to avoid code duplication.
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')
-rw-r--r-- | arch/ia64/kernel/time.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c index 01cd43e491cd..351df5850309 100644 --- a/arch/ia64/kernel/time.c +++ b/arch/ia64/kernel/time.c | |||
@@ -83,6 +83,18 @@ 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) | ||
87 | { | ||
88 | cputime_t delta_utime; | ||
89 | struct thread_info *ti = task_thread_info(tsk); | ||
90 | |||
91 | if (ti->ac_utime) { | ||
92 | delta_utime = cycle_to_cputime(ti->ac_utime); | ||
93 | account_user_time(tsk, delta_utime, delta_utime); | ||
94 | ti->ac_utime = 0; | ||
95 | } | ||
96 | } | ||
97 | |||
86 | /* | 98 | /* |
87 | * Called from the context switch with interrupts disabled, to charge all | 99 | * Called from the context switch with interrupts disabled, to charge all |
88 | * accumulated times to the current process, and to prepare accounting on | 100 | * accumulated times to the current process, and to prepare accounting on |
@@ -92,7 +104,7 @@ void vtime_task_switch(struct task_struct *prev) | |||
92 | { | 104 | { |
93 | struct thread_info *pi = task_thread_info(prev); | 105 | struct thread_info *pi = task_thread_info(prev); |
94 | struct thread_info *ni = task_thread_info(current); | 106 | struct thread_info *ni = task_thread_info(current); |
95 | cputime_t delta_stime, delta_utime; | 107 | cputime_t delta_stime; |
96 | __u64 now; | 108 | __u64 now; |
97 | 109 | ||
98 | now = ia64_get_itc(); | 110 | now = ia64_get_itc(); |
@@ -103,10 +115,7 @@ void vtime_task_switch(struct task_struct *prev) | |||
103 | else | 115 | else |
104 | account_idle_time(delta_stime); | 116 | account_idle_time(delta_stime); |
105 | 117 | ||
106 | if (pi->ac_utime) { | 118 | vtime_account_user(prev); |
107 | delta_utime = cycle_to_cputime(pi->ac_utime); | ||
108 | account_user_time(prev, delta_utime, delta_utime); | ||
109 | } | ||
110 | 119 | ||
111 | pi->ac_stamp = ni->ac_stamp = now; | 120 | pi->ac_stamp = ni->ac_stamp = now; |
112 | ni->ac_stime = ni->ac_utime = 0; | 121 | ni->ac_stime = ni->ac_utime = 0; |
@@ -149,14 +158,7 @@ void vtime_account_idle(struct task_struct *tsk) | |||
149 | */ | 158 | */ |
150 | void account_process_tick(struct task_struct *p, int user_tick) | 159 | void account_process_tick(struct task_struct *p, int user_tick) |
151 | { | 160 | { |
152 | struct thread_info *ti = task_thread_info(p); | 161 | vtime_account_user(p); |
153 | cputime_t delta_utime; | ||
154 | |||
155 | if (ti->ac_utime) { | ||
156 | delta_utime = cycle_to_cputime(ti->ac_utime); | ||
157 | account_user_time(p, delta_utime, delta_utime); | ||
158 | ti->ac_utime = 0; | ||
159 | } | ||
160 | } | 162 | } |
161 | 163 | ||
162 | #endif /* CONFIG_VIRT_CPU_ACCOUNTING */ | 164 | #endif /* CONFIG_VIRT_CPU_ACCOUNTING */ |