diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2008-12-31 09:11:37 -0500 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2008-12-31 09:11:46 -0500 |
commit | 457533a7d3402d1d91fbc125c8bd1bd16dcd3cd4 (patch) | |
tree | cbe69310a66176dea2a9e7bd201db95efe4a2890 /arch | |
parent | 6a94cb73064c952255336cc57731904174b2c58f (diff) |
[PATCH] fix scaled & unscaled cputime accounting
The utimescaled / stimescaled fields in the task structure and the
global cpustat should be set on all architectures. On s390 the calls
to account_user_time_scaled and account_system_time_scaled never have
been added. In addition system time that is accounted as guest time
to the user time of a process is accounted to the scaled system time
instead of the scaled user time.
To fix the bugs and to prevent future forgetfulness this patch merges
account_system_time_scaled into account_system_time and
account_user_time_scaled into account_user_time.
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: Michael Neuling <mikey@neuling.org>
Acked-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/ia64/kernel/time.c | 12 | ||||
-rw-r--r-- | arch/powerpc/kernel/time.c | 7 | ||||
-rw-r--r-- | arch/s390/kernel/vtime.c | 10 |
3 files changed, 11 insertions, 18 deletions
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c index 65c10a42c88f..4ee367817049 100644 --- a/arch/ia64/kernel/time.c +++ b/arch/ia64/kernel/time.c | |||
@@ -93,13 +93,11 @@ void ia64_account_on_switch(struct task_struct *prev, struct task_struct *next) | |||
93 | now = ia64_get_itc(); | 93 | now = ia64_get_itc(); |
94 | 94 | ||
95 | delta_stime = cycle_to_cputime(pi->ac_stime + (now - pi->ac_stamp)); | 95 | delta_stime = cycle_to_cputime(pi->ac_stime + (now - pi->ac_stamp)); |
96 | account_system_time(prev, 0, delta_stime); | 96 | account_system_time(prev, 0, delta_stime, delta_stime); |
97 | account_system_time_scaled(prev, delta_stime); | ||
98 | 97 | ||
99 | if (pi->ac_utime) { | 98 | if (pi->ac_utime) { |
100 | delta_utime = cycle_to_cputime(pi->ac_utime); | 99 | delta_utime = cycle_to_cputime(pi->ac_utime); |
101 | account_user_time(prev, delta_utime); | 100 | account_user_time(prev, delta_utime, delta_utime); |
102 | account_user_time_scaled(prev, delta_utime); | ||
103 | } | 101 | } |
104 | 102 | ||
105 | pi->ac_stamp = ni->ac_stamp = now; | 103 | pi->ac_stamp = ni->ac_stamp = now; |
@@ -122,8 +120,7 @@ void account_system_vtime(struct task_struct *tsk) | |||
122 | now = ia64_get_itc(); | 120 | now = ia64_get_itc(); |
123 | 121 | ||
124 | delta_stime = cycle_to_cputime(ti->ac_stime + (now - ti->ac_stamp)); | 122 | delta_stime = cycle_to_cputime(ti->ac_stime + (now - ti->ac_stamp)); |
125 | account_system_time(tsk, 0, delta_stime); | 123 | account_system_time(tsk, 0, delta_stime, delta_stime); |
126 | account_system_time_scaled(tsk, delta_stime); | ||
127 | ti->ac_stime = 0; | 124 | ti->ac_stime = 0; |
128 | 125 | ||
129 | ti->ac_stamp = now; | 126 | ti->ac_stamp = now; |
@@ -143,8 +140,7 @@ void account_process_tick(struct task_struct *p, int user_tick) | |||
143 | 140 | ||
144 | if (ti->ac_utime) { | 141 | if (ti->ac_utime) { |
145 | delta_utime = cycle_to_cputime(ti->ac_utime); | 142 | delta_utime = cycle_to_cputime(ti->ac_utime); |
146 | account_user_time(p, delta_utime); | 143 | account_user_time(p, delta_utime, delta_utime); |
147 | account_user_time_scaled(p, delta_utime); | ||
148 | ti->ac_utime = 0; | 144 | ti->ac_utime = 0; |
149 | } | 145 | } |
150 | } | 146 | } |
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index e1f3a5140429..92650ccad2e1 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
@@ -256,8 +256,7 @@ void account_system_vtime(struct task_struct *tsk) | |||
256 | delta += sys_time; | 256 | delta += sys_time; |
257 | get_paca()->system_time = 0; | 257 | get_paca()->system_time = 0; |
258 | } | 258 | } |
259 | account_system_time(tsk, 0, delta); | 259 | account_system_time(tsk, 0, delta, deltascaled); |
260 | account_system_time_scaled(tsk, deltascaled); | ||
261 | per_cpu(cputime_last_delta, smp_processor_id()) = delta; | 260 | per_cpu(cputime_last_delta, smp_processor_id()) = delta; |
262 | per_cpu(cputime_scaled_last_delta, smp_processor_id()) = deltascaled; | 261 | per_cpu(cputime_scaled_last_delta, smp_processor_id()) = deltascaled; |
263 | local_irq_restore(flags); | 262 | local_irq_restore(flags); |
@@ -275,10 +274,8 @@ void account_process_tick(struct task_struct *tsk, int user_tick) | |||
275 | 274 | ||
276 | utime = get_paca()->user_time; | 275 | utime = get_paca()->user_time; |
277 | get_paca()->user_time = 0; | 276 | get_paca()->user_time = 0; |
278 | account_user_time(tsk, utime); | ||
279 | |||
280 | utimescaled = cputime_to_scaled(utime); | 277 | utimescaled = cputime_to_scaled(utime); |
281 | account_user_time_scaled(tsk, utimescaled); | 278 | account_user_time(tsk, utime, utimescaled); |
282 | } | 279 | } |
283 | 280 | ||
284 | /* | 281 | /* |
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c index 75a6e62ea973..07283aea2e56 100644 --- a/arch/s390/kernel/vtime.c +++ b/arch/s390/kernel/vtime.c | |||
@@ -50,12 +50,12 @@ void account_process_tick(struct task_struct *tsk, int user_tick) | |||
50 | rcu_user_flag = cputime != 0; | 50 | rcu_user_flag = cputime != 0; |
51 | S390_lowcore.user_timer -= cputime << 12; | 51 | S390_lowcore.user_timer -= cputime << 12; |
52 | S390_lowcore.steal_clock -= cputime << 12; | 52 | S390_lowcore.steal_clock -= cputime << 12; |
53 | account_user_time(tsk, cputime); | 53 | account_user_time(tsk, cputime, cputime); |
54 | 54 | ||
55 | cputime = S390_lowcore.system_timer >> 12; | 55 | cputime = S390_lowcore.system_timer >> 12; |
56 | S390_lowcore.system_timer -= cputime << 12; | 56 | S390_lowcore.system_timer -= cputime << 12; |
57 | S390_lowcore.steal_clock -= cputime << 12; | 57 | S390_lowcore.steal_clock -= cputime << 12; |
58 | account_system_time(tsk, HARDIRQ_OFFSET, cputime); | 58 | account_system_time(tsk, HARDIRQ_OFFSET, cputime, cputime); |
59 | 59 | ||
60 | cputime = S390_lowcore.steal_clock; | 60 | cputime = S390_lowcore.steal_clock; |
61 | if ((__s64) cputime > 0) { | 61 | if ((__s64) cputime > 0) { |
@@ -82,12 +82,12 @@ void account_vtime(struct task_struct *tsk) | |||
82 | cputime = S390_lowcore.user_timer >> 12; | 82 | cputime = S390_lowcore.user_timer >> 12; |
83 | S390_lowcore.user_timer -= cputime << 12; | 83 | S390_lowcore.user_timer -= cputime << 12; |
84 | S390_lowcore.steal_clock -= cputime << 12; | 84 | S390_lowcore.steal_clock -= cputime << 12; |
85 | account_user_time(tsk, cputime); | 85 | account_user_time(tsk, cputime, cputime); |
86 | 86 | ||
87 | cputime = S390_lowcore.system_timer >> 12; | 87 | cputime = S390_lowcore.system_timer >> 12; |
88 | S390_lowcore.system_timer -= cputime << 12; | 88 | S390_lowcore.system_timer -= cputime << 12; |
89 | S390_lowcore.steal_clock -= cputime << 12; | 89 | S390_lowcore.steal_clock -= cputime << 12; |
90 | account_system_time(tsk, 0, cputime); | 90 | account_system_time(tsk, 0, cputime, cputime); |
91 | } | 91 | } |
92 | 92 | ||
93 | /* | 93 | /* |
@@ -107,7 +107,7 @@ void account_system_vtime(struct task_struct *tsk) | |||
107 | cputime = S390_lowcore.system_timer >> 12; | 107 | cputime = S390_lowcore.system_timer >> 12; |
108 | S390_lowcore.system_timer -= cputime << 12; | 108 | S390_lowcore.system_timer -= cputime << 12; |
109 | S390_lowcore.steal_clock -= cputime << 12; | 109 | S390_lowcore.steal_clock -= cputime << 12; |
110 | account_system_time(tsk, 0, cputime); | 110 | account_system_time(tsk, 0, cputime, cputime); |
111 | } | 111 | } |
112 | EXPORT_SYMBOL_GPL(account_system_vtime); | 112 | EXPORT_SYMBOL_GPL(account_system_vtime); |
113 | 113 | ||