Commit 3171a0305d62e6627a24bff35af4f997e4988a80
Committed by
Linus Torvalds
1 parent
27d91e07f9
[PATCH] simplify update_times (avoid jiffies/jiffies_64 aliasing problem)
Pass ticks to do_timer() and update_times(), and adjust x86_64 and s390 timer interrupt handler with this change. Currently update_times() calculates ticks by "jiffies - wall_jiffies", but callers of do_timer() should know how many ticks to update. Passing ticks get rid of this redundant calculation. Also there are another redundancy pointed out by Martin Schwidefsky. This cleanup make a barrier added by 5aee405c662ca644980c184774277fc6d0769a84 needless. So this patch removes it. As a bonus, this cleanup make wall_jiffies can be removed easily, since now wall_jiffies is always synced with jiffies. (This patch does not really remove wall_jiffies. It would be another cleanup patch) Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@elte.hu> Cc: john stultz <johnstul@us.ibm.com> Cc: Andi Kleen <ak@muc.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Acked-by: Russell King <rmk@arm.linux.org.uk> Cc: Ian Molton <spyro@f2s.com> Cc: Mikael Starvik <starvik@axis.com> Acked-by: David Howells <dhowells@redhat.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Cc: Hirokazu Takata <takata.hirokazu@renesas.com> Acked-by: Ralf Baechle <ralf@linux-mips.org> Cc: Kyle McMartin <kyle@mcmartin.ca> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Paul Mundt <lethal@linux-sh.org> Cc: Kazumoto Kojima <kkojima@rr.iij4u.or.jp> Cc: Richard Curnow <rc@rc0.org.uk> Cc: William Lee Irwin III <wli@holomorphy.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Cc: Miles Bader <uclinux-v850@lsi.nec.co.jp> Cc: Chris Zankel <chris@zankel.net> Acked-by: "Luck, Tony" <tony.luck@intel.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 38 changed files with 52 additions and 60 deletions Side-by-side Diff
- arch/alpha/kernel/time.c
- arch/arm/kernel/time.c
- arch/arm26/kernel/time.c
- arch/avr32/kernel/time.c
- arch/cris/arch-v10/kernel/time.c
- arch/cris/arch-v32/kernel/time.c
- arch/frv/kernel/time.c
- arch/h8300/kernel/time.c
- arch/ia64/kernel/time.c
- arch/m32r/kernel/time.c
- arch/m68k/kernel/time.c
- arch/m68k/sun3/sun3ints.c
- arch/m68knommu/kernel/time.c
- arch/mips/au1000/common/time.c
- arch/mips/gt64120/common/time.c
- arch/mips/kernel/time.c
- arch/mips/momentum/ocelot_g/gt-irq.c
- arch/mips/sgi-ip27/ip27-timer.c
- arch/parisc/kernel/time.c
- arch/powerpc/kernel/time.c
- arch/ppc/kernel/time.c
- arch/s390/kernel/time.c
- arch/sh/kernel/time.c
- arch/sh64/kernel/time.c
- arch/sparc/kernel/pcic.c
- arch/sparc/kernel/time.c
- arch/sparc64/kernel/time.c
- arch/um/kernel/time.c
- arch/v850/kernel/time.c
- arch/x86_64/kernel/time.c
- arch/xtensa/kernel/time.c
- include/asm-arm/arch-clps711x/time.h
- include/asm-arm/arch-l7200/time.h
- include/asm-i386/mach-default/do_timer.h
- include/asm-i386/mach-visws/do_timer.h
- include/asm-i386/mach-voyager/do_timer.h
- include/linux/sched.h
- kernel/timer.c
arch/alpha/kernel/time.c
arch/arm/kernel/time.c
arch/arm26/kernel/time.c
arch/avr32/kernel/time.c
arch/cris/arch-v10/kernel/time.c
arch/cris/arch-v32/kernel/time.c
arch/frv/kernel/time.c
arch/h8300/kernel/time.c
arch/ia64/kernel/time.c
arch/m32r/kernel/time.c
arch/m68k/kernel/time.c
arch/m68k/sun3/sun3ints.c
arch/m68knommu/kernel/time.c
arch/mips/au1000/common/time.c
... | ... | @@ -96,7 +96,7 @@ |
96 | 96 | timerlo = count; |
97 | 97 | |
98 | 98 | kstat_this_cpu.irqs[irq]++; |
99 | - do_timer(regs); | |
99 | + do_timer(1); | |
100 | 100 | #ifndef CONFIG_SMP |
101 | 101 | update_process_times(user_mode(regs)); |
102 | 102 | #endif |
... | ... | @@ -137,7 +137,7 @@ |
137 | 137 | } |
138 | 138 | |
139 | 139 | while (time_elapsed > 0) { |
140 | - do_timer(regs); | |
140 | + do_timer(1); | |
141 | 141 | #ifndef CONFIG_SMP |
142 | 142 | update_process_times(user_mode(regs)); |
143 | 143 | #endif |
... | ... | @@ -156,7 +156,7 @@ |
156 | 156 | |
157 | 157 | if (jiffie_drift >= 999) { |
158 | 158 | jiffie_drift -= 999; |
159 | - do_timer(regs); /* increment jiffies by one */ | |
159 | + do_timer(1); /* increment jiffies by one */ | |
160 | 160 | #ifndef CONFIG_SMP |
161 | 161 | update_process_times(user_mode(regs)); |
162 | 162 | #endif |
arch/mips/gt64120/common/time.c
arch/mips/kernel/time.c
arch/mips/momentum/ocelot_g/gt-irq.c
arch/mips/sgi-ip27/ip27-timer.c
arch/parisc/kernel/time.c
arch/powerpc/kernel/time.c
... | ... | @@ -693,7 +693,7 @@ |
693 | 693 | tb_next_jiffy = tb_last_jiffy + tb_ticks_per_jiffy; |
694 | 694 | if (per_cpu(last_jiffy, cpu) >= tb_next_jiffy) { |
695 | 695 | tb_last_jiffy = tb_next_jiffy; |
696 | - do_timer(regs); | |
696 | + do_timer(1); | |
697 | 697 | timer_recalc_offset(tb_last_jiffy); |
698 | 698 | timer_check_rtc(); |
699 | 699 | } |
arch/ppc/kernel/time.c
arch/s390/kernel/time.c
... | ... | @@ -166,7 +166,7 @@ |
166 | 166 | void account_ticks(struct pt_regs *regs) |
167 | 167 | { |
168 | 168 | __u64 tmp; |
169 | - __u32 ticks, xticks; | |
169 | + __u32 ticks; | |
170 | 170 | |
171 | 171 | /* Calculate how many ticks have passed. */ |
172 | 172 | if (S390_lowcore.int_clock < S390_lowcore.jiffy_timer) { |
... | ... | @@ -204,6 +204,7 @@ |
204 | 204 | */ |
205 | 205 | write_seqlock(&xtime_lock); |
206 | 206 | if (S390_lowcore.jiffy_timer > xtime_cc) { |
207 | + __u32 xticks; | |
207 | 208 | tmp = S390_lowcore.jiffy_timer - xtime_cc; |
208 | 209 | if (tmp >= 2*CLK_TICKS_PER_JIFFY) { |
209 | 210 | xticks = __div(tmp, CLK_TICKS_PER_JIFFY); |
210 | 211 | |
... | ... | @@ -212,13 +213,11 @@ |
212 | 213 | xticks = 1; |
213 | 214 | xtime_cc += CLK_TICKS_PER_JIFFY; |
214 | 215 | } |
215 | - while (xticks--) | |
216 | - do_timer(regs); | |
216 | + do_timer(xticks); | |
217 | 217 | } |
218 | 218 | write_sequnlock(&xtime_lock); |
219 | 219 | #else |
220 | - for (xticks = ticks; xticks > 0; xticks--) | |
221 | - do_timer(regs); | |
220 | + do_timer(ticks); | |
222 | 221 | #endif |
223 | 222 | |
224 | 223 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING |
arch/sh/kernel/time.c
arch/sh64/kernel/time.c
arch/sparc/kernel/pcic.c
arch/sparc/kernel/time.c
arch/sparc64/kernel/time.c
... | ... | @@ -465,7 +465,7 @@ |
465 | 465 | profile_tick(CPU_PROFILING, regs); |
466 | 466 | update_process_times(user_mode(regs)); |
467 | 467 | #endif |
468 | - do_timer(regs); | |
468 | + do_timer(1); | |
469 | 469 | |
470 | 470 | /* Guarantee that the following sequences execute |
471 | 471 | * uninterrupted. |
... | ... | @@ -496,7 +496,7 @@ |
496 | 496 | { |
497 | 497 | write_seqlock(&xtime_lock); |
498 | 498 | |
499 | - do_timer(regs); | |
499 | + do_timer(1); | |
500 | 500 | |
501 | 501 | timer_check_rtc(); |
502 | 502 |
arch/um/kernel/time.c
arch/v850/kernel/time.c
arch/x86_64/kernel/time.c
... | ... | @@ -415,16 +415,16 @@ |
415 | 415 | (((long) offset << US_SCALE) / vxtime.tsc_quot) - 1; |
416 | 416 | } |
417 | 417 | |
418 | - if (lost > 0) { | |
418 | + if (lost > 0) | |
419 | 419 | handle_lost_ticks(lost, regs); |
420 | - jiffies += lost; | |
421 | - } | |
420 | + else | |
421 | + lost = 0; | |
422 | 422 | |
423 | 423 | /* |
424 | 424 | * Do the timer stuff. |
425 | 425 | */ |
426 | 426 | |
427 | - do_timer(regs); | |
427 | + do_timer(lost + 1); | |
428 | 428 | #ifndef CONFIG_SMP |
429 | 429 | update_process_times(user_mode(regs)); |
430 | 430 | #endif |
arch/xtensa/kernel/time.c
... | ... | @@ -175,7 +175,7 @@ |
175 | 175 | |
176 | 176 | last_ccount_stamp = next; |
177 | 177 | next += CCOUNT_PER_JIFFY; |
178 | - do_timer (regs); /* Linux handler in kernel/timer.c */ | |
178 | + do_timer (1); /* Linux handler in kernel/timer.c */ | |
179 | 179 | |
180 | 180 | if (ntp_synced() && |
181 | 181 | xtime.tv_sec - last_rtc_update >= 659 && |
include/asm-arm/arch-clps711x/time.h
include/asm-arm/arch-l7200/time.h
include/asm-i386/mach-default/do_timer.h
include/asm-i386/mach-visws/do_timer.h
include/asm-i386/mach-voyager/do_timer.h
include/linux/sched.h
... | ... | @@ -1206,7 +1206,7 @@ |
1206 | 1206 | |
1207 | 1207 | #include <asm/current.h> |
1208 | 1208 | |
1209 | -extern void do_timer(struct pt_regs *); | |
1209 | +extern void do_timer(unsigned long ticks); | |
1210 | 1210 | |
1211 | 1211 | extern int FASTCALL(wake_up_state(struct task_struct * tsk, unsigned int state)); |
1212 | 1212 | extern int FASTCALL(wake_up_process(struct task_struct * tsk)); |
kernel/timer.c
... | ... | @@ -1222,10 +1222,8 @@ |
1222 | 1222 | unsigned long active_tasks; /* fixed-point */ |
1223 | 1223 | static int count = LOAD_FREQ; |
1224 | 1224 | |
1225 | - count -= ticks; | |
1226 | - if (count < 0) { | |
1227 | - count += LOAD_FREQ; | |
1228 | - active_tasks = count_active_tasks(); | |
1225 | + active_tasks = count_active_tasks(); | |
1226 | + for (count -= ticks; count < 0; count += LOAD_FREQ) { | |
1229 | 1227 | CALC_LOAD(avenrun[0], EXP_1, active_tasks); |
1230 | 1228 | CALC_LOAD(avenrun[1], EXP_5, active_tasks); |
1231 | 1229 | CALC_LOAD(avenrun[2], EXP_15, active_tasks); |
1232 | 1230 | |
... | ... | @@ -1270,11 +1268,8 @@ |
1270 | 1268 | * Called by the timer interrupt. xtime_lock must already be taken |
1271 | 1269 | * by the timer IRQ! |
1272 | 1270 | */ |
1273 | -static inline void update_times(void) | |
1271 | +static inline void update_times(unsigned long ticks) | |
1274 | 1272 | { |
1275 | - unsigned long ticks; | |
1276 | - | |
1277 | - ticks = jiffies - wall_jiffies; | |
1278 | 1273 | wall_jiffies += ticks; |
1279 | 1274 | update_wall_time(); |
1280 | 1275 | calc_load(ticks); |
1281 | 1276 | |
... | ... | @@ -1286,12 +1281,10 @@ |
1286 | 1281 | * jiffies is defined in the linker script... |
1287 | 1282 | */ |
1288 | 1283 | |
1289 | -void do_timer(struct pt_regs *regs) | |
1284 | +void do_timer(unsigned long ticks) | |
1290 | 1285 | { |
1291 | - jiffies_64++; | |
1292 | - /* prevent loading jiffies before storing new jiffies_64 value. */ | |
1293 | - barrier(); | |
1294 | - update_times(); | |
1286 | + jiffies_64 += ticks; | |
1287 | + update_times(ticks); | |
1295 | 1288 | } |
1296 | 1289 | |
1297 | 1290 | #ifdef __ARCH_WANT_SYS_ALARM |