aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2006-01-14 16:21:03 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-14 21:27:09 -0500
commit1f1c12afe5c3e0ef901eec12dee09df4947462ee (patch)
tree157f01441ef5ddc0810d0bfebca4667c21254529
parentbcc132651d384ad115a275868effb49c64b348ce (diff)
[PATCH] s390: cputime misaccounting
finish_arch_switch needs to update the user cpu time as well, not just the system cpu time. Otherwise the partial user cpu time of a process that is stored in the lowcore will be (mis-)accounted to the next process. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--arch/s390/kernel/time.c2
-rw-r--r--arch/s390/kernel/vtime.c27
-rw-r--r--include/asm-s390/system.h5
-rw-r--r--include/linux/hardirq.h4
4 files changed, 30 insertions, 8 deletions
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index b0d8ca8e5eeb..7c0fe152a111 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -214,7 +214,7 @@ void account_ticks(struct pt_regs *regs)
214#endif 214#endif
215 215
216#ifdef CONFIG_VIRT_CPU_ACCOUNTING 216#ifdef CONFIG_VIRT_CPU_ACCOUNTING
217 account_user_vtime(current); 217 account_tick_vtime(current);
218#else 218#else
219 while (ticks--) 219 while (ticks--)
220 update_process_times(user_mode(regs)); 220 update_process_times(user_mode(regs));
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index 22a895ecb7a4..dfe6f0856617 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -32,7 +32,7 @@ DEFINE_PER_CPU(struct vtimer_queue, virt_cpu_timer);
32 * Update process times based on virtual cpu times stored by entry.S 32 * Update process times based on virtual cpu times stored by entry.S
33 * to the lowcore fields user_timer, system_timer & steal_clock. 33 * to the lowcore fields user_timer, system_timer & steal_clock.
34 */ 34 */
35void account_user_vtime(struct task_struct *tsk) 35void account_tick_vtime(struct task_struct *tsk)
36{ 36{
37 cputime_t cputime; 37 cputime_t cputime;
38 __u64 timer, clock; 38 __u64 timer, clock;
@@ -76,6 +76,31 @@ void account_user_vtime(struct task_struct *tsk)
76 * Update process times based on virtual cpu times stored by entry.S 76 * Update process times based on virtual cpu times stored by entry.S
77 * to the lowcore fields user_timer, system_timer & steal_clock. 77 * to the lowcore fields user_timer, system_timer & steal_clock.
78 */ 78 */
79void account_vtime(struct task_struct *tsk)
80{
81 cputime_t cputime;
82 __u64 timer;
83
84 timer = S390_lowcore.last_update_timer;
85 asm volatile (" STPT %0" /* Store current cpu timer value */
86 : "=m" (S390_lowcore.last_update_timer) );
87 S390_lowcore.system_timer += timer - S390_lowcore.last_update_timer;
88
89 cputime = S390_lowcore.user_timer >> 12;
90 S390_lowcore.user_timer -= cputime << 12;
91 S390_lowcore.steal_clock -= cputime << 12;
92 account_user_time(tsk, cputime);
93
94 cputime = S390_lowcore.system_timer >> 12;
95 S390_lowcore.system_timer -= cputime << 12;
96 S390_lowcore.steal_clock -= cputime << 12;
97 account_system_time(tsk, 0, cputime);
98}
99
100/*
101 * Update process times based on virtual cpu times stored by entry.S
102 * to the lowcore fields user_timer, system_timer & steal_clock.
103 */
79void account_system_vtime(struct task_struct *tsk) 104void account_system_vtime(struct task_struct *tsk)
80{ 105{
81 cputime_t cputime; 106 cputime_t cputime;
diff --git a/include/asm-s390/system.h b/include/asm-s390/system.h
index c7c3a9ad593f..b2e65e8bf812 100644
--- a/include/asm-s390/system.h
+++ b/include/asm-s390/system.h
@@ -115,13 +115,14 @@ static inline void sched_cacheflush(void)
115} 115}
116 116
117#ifdef CONFIG_VIRT_CPU_ACCOUNTING 117#ifdef CONFIG_VIRT_CPU_ACCOUNTING
118extern void account_user_vtime(struct task_struct *); 118extern void account_vtime(struct task_struct *);
119extern void account_tick_vtime(struct task_struct *);
119extern void account_system_vtime(struct task_struct *); 120extern void account_system_vtime(struct task_struct *);
120#endif 121#endif
121 122
122#define finish_arch_switch(prev) do { \ 123#define finish_arch_switch(prev) do { \
123 set_fs(current->thread.mm_segment); \ 124 set_fs(current->thread.mm_segment); \
124 account_system_vtime(prev); \ 125 account_vtime(prev); \
125} while (0) 126} while (0)
126 127
127#define nop() __asm__ __volatile__ ("nop") 128#define nop() __asm__ __volatile__ ("nop")
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index 71d2b8a723b9..eab537091f2a 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -93,10 +93,6 @@ extern void synchronize_irq(unsigned int irq);
93struct task_struct; 93struct task_struct;
94 94
95#ifndef CONFIG_VIRT_CPU_ACCOUNTING 95#ifndef CONFIG_VIRT_CPU_ACCOUNTING
96static inline void account_user_vtime(struct task_struct *tsk)
97{
98}
99
100static inline void account_system_vtime(struct task_struct *tsk) 96static inline void account_system_vtime(struct task_struct *tsk)
101{ 97{
102} 98}