Skip to content

Commit 3171a03

Browse files
atsushi-nemotoLinus Torvalds
authored and
Linus Torvalds
committed
[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 5aee405 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 <[email protected]> Cc: Martin Schwidefsky <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: john stultz <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Richard Henderson <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Acked-by: Russell King <[email protected]> Cc: Ian Molton <[email protected]> Cc: Mikael Starvik <[email protected]> Acked-by: David Howells <[email protected]> Cc: Yoshinori Sato <[email protected]> Cc: Hirokazu Takata <[email protected]> Acked-by: Ralf Baechle <[email protected]> Cc: Kyle McMartin <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Martin Schwidefsky <[email protected]> Cc: Paul Mundt <[email protected]> Cc: Kazumoto Kojima <[email protected]> Cc: Richard Curnow <[email protected]> Cc: William Lee Irwin III <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Jeff Dike <[email protected]> Cc: Paolo 'Blaisorblade' Giarrusso <[email protected]> Cc: Miles Bader <[email protected]> Cc: Chris Zankel <[email protected]> Acked-by: "Luck, Tony" <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Roman Zippel <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 27d91e0 commit 3171a03

File tree

38 files changed

+52
-60
lines changed

38 files changed

+52
-60
lines changed

arch/alpha/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ irqreturn_t timer_interrupt(int irq, void *dev, struct pt_regs * regs)
132132
nticks = delta >> FIX_SHIFT;
133133

134134
while (nticks > 0) {
135-
do_timer(regs);
135+
do_timer(1);
136136
#ifndef CONFIG_SMP
137137
update_process_times(user_mode(regs));
138138
#endif

arch/arm/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ void timer_tick(struct pt_regs *regs)
337337
profile_tick(CPU_PROFILING, regs);
338338
do_leds();
339339
do_set_rtc();
340-
do_timer(regs);
340+
do_timer(1);
341341
#ifndef CONFIG_SMP
342342
update_process_times(user_mode(regs));
343343
#endif

arch/arm26/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ EXPORT_SYMBOL(do_settimeofday);
194194

195195
static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
196196
{
197-
do_timer(regs);
197+
do_timer(1);
198198
#ifndef CONFIG_SMP
199199
update_process_times(user_mode(regs));
200200
#endif

arch/avr32/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
148148
* Call the generic timer interrupt handler
149149
*/
150150
write_seqlock(&xtime_lock);
151-
do_timer(regs);
151+
do_timer(1);
152152
write_sequnlock(&xtime_lock);
153153

154154
/*

arch/cris/arch-v10/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
227227

228228
/* call the real timer interrupt handler */
229229

230-
do_timer(regs);
230+
do_timer(1);
231231

232232
cris_do_profile(regs); /* Save profiling information */
233233

arch/cris/arch-v32/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
219219
return IRQ_HANDLED;
220220

221221
/* call the real timer interrupt handler */
222-
do_timer(regs);
222+
do_timer(1);
223223

224224
/*
225225
* If we have an externally synchronized Linux clock, then update

arch/frv/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static irqreturn_t timer_interrupt(int irq, void *dummy, struct pt_regs * regs)
7070
*/
7171
write_seqlock(&xtime_lock);
7272

73-
do_timer(regs);
73+
do_timer(1);
7474
update_process_times(user_mode(regs));
7575
profile_tick(CPU_PROFILING, regs);
7676

arch/h8300/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static void timer_interrupt(int irq, void *dummy, struct pt_regs * regs)
4141
/* may need to kick the hardware timer */
4242
platform_timer_eoi();
4343

44-
do_timer(regs);
44+
do_timer(1);
4545
#ifndef CONFIG_SMP
4646
update_process_times(user_mode(regs));
4747
#endif

arch/ia64/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ timer_interrupt (int irq, void *dev_id, struct pt_regs *regs)
7878
* xtime_lock.
7979
*/
8080
write_seqlock(&xtime_lock);
81-
do_timer(regs);
81+
do_timer(1);
8282
local_cpu_data->itm_next = new_itm;
8383
write_sequnlock(&xtime_lock);
8484
} else

arch/m32r/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
202202
#ifndef CONFIG_SMP
203203
profile_tick(CPU_PROFILING, regs);
204204
#endif
205-
do_timer(regs);
205+
do_timer(1);
206206

207207
#ifndef CONFIG_SMP
208208
update_process_times(user_mode(regs));

arch/m68k/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static inline int set_rtc_mmss(unsigned long nowtime)
4040
*/
4141
static irqreturn_t timer_interrupt(int irq, void *dummy, struct pt_regs * regs)
4242
{
43-
do_timer(regs);
43+
do_timer(1);
4444
#ifndef CONFIG_SMP
4545
update_process_times(user_mode(regs));
4646
#endif

arch/m68k/sun3/sun3ints.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static irqreturn_t sun3_int5(int irq, void *dev_id, struct pt_regs *fp)
6565
#ifdef CONFIG_SUN3
6666
intersil_clear();
6767
#endif
68-
do_timer(fp);
68+
do_timer(1);
6969
#ifndef CONFIG_SMP
7070
update_process_times(user_mode(fp));
7171
#endif

arch/m68knommu/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static irqreturn_t timer_interrupt(int irq, void *dummy, struct pt_regs * regs)
5151

5252
write_seqlock(&xtime_lock);
5353

54-
do_timer(regs);
54+
do_timer(1);
5555
#ifndef CONFIG_SMP
5656
update_process_times(user_mode(regs));
5757
#endif

arch/mips/au1000/common/time.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void mips_timer_interrupt(struct pt_regs *regs)
9696
timerlo = count;
9797

9898
kstat_this_cpu.irqs[irq]++;
99-
do_timer(regs);
99+
do_timer(1);
100100
#ifndef CONFIG_SMP
101101
update_process_times(user_mode(regs));
102102
#endif
@@ -137,7 +137,7 @@ irqreturn_t counter0_irq(int irq, void *dev_id, struct pt_regs *regs)
137137
}
138138

139139
while (time_elapsed > 0) {
140-
do_timer(regs);
140+
do_timer(1);
141141
#ifndef CONFIG_SMP
142142
update_process_times(user_mode(regs));
143143
#endif
@@ -156,7 +156,7 @@ irqreturn_t counter0_irq(int irq, void *dev_id, struct pt_regs *regs)
156156

157157
if (jiffie_drift >= 999) {
158158
jiffie_drift -= 999;
159-
do_timer(regs); /* increment jiffies by one */
159+
do_timer(1); /* increment jiffies by one */
160160
#ifndef CONFIG_SMP
161161
update_process_times(user_mode(regs));
162162
#endif

arch/mips/gt64120/common/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static void gt64120_irq(int irq, void *dev_id, struct pt_regs *regs)
3434
if (irq_src & 0x00000800) { /* Check for timer interrupt */
3535
handled = 1;
3636
irq_src &= ~0x00000800;
37-
do_timer(regs);
37+
do_timer(1);
3838
#ifndef CONFIG_SMP
3939
update_process_times(user_mode(regs));
4040
#endif

arch/mips/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
434434
/*
435435
* call the generic timer interrupt handling
436436
*/
437-
do_timer(regs);
437+
do_timer(1);
438438

439439
/*
440440
* If we have an externally synchronized Linux clock, then update

arch/mips/momentum/ocelot_g/gt-irq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static irqreturn_t gt64240_p0int_irq(int irq, void *dev, struct pt_regs *regs)
133133
MV_WRITE(TIMER_COUNTER_0_3_INTERRUPT_CAUSE, 0x0);
134134

135135
/* handle the timer call */
136-
do_timer(regs);
136+
do_timer(1);
137137
#ifndef CONFIG_SMP
138138
update_process_times(user_mode(regs));
139139
#endif

arch/mips/sgi-ip27/ip27-timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void ip27_rt_timer_interrupt(struct pt_regs *regs)
111111
kstat_this_cpu.irqs[irq]++; /* kstat only for bootcpu? */
112112

113113
if (cpu == 0)
114-
do_timer(regs);
114+
do_timer(1);
115115

116116
update_process_times(user_mode(regs));
117117

arch/parisc/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
7979
#endif
8080
if (cpu == 0) {
8181
write_seqlock(&xtime_lock);
82-
do_timer(regs);
82+
do_timer(1);
8383
write_sequnlock(&xtime_lock);
8484
}
8585
}

arch/powerpc/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ void timer_interrupt(struct pt_regs * regs)
693693
tb_next_jiffy = tb_last_jiffy + tb_ticks_per_jiffy;
694694
if (per_cpu(last_jiffy, cpu) >= tb_next_jiffy) {
695695
tb_last_jiffy = tb_next_jiffy;
696-
do_timer(regs);
696+
do_timer(1);
697697
timer_recalc_offset(tb_last_jiffy);
698698
timer_check_rtc();
699699
}

arch/ppc/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void timer_interrupt(struct pt_regs * regs)
153153
/* We are in an interrupt, no need to save/restore flags */
154154
write_seqlock(&xtime_lock);
155155
tb_last_stamp = jiffy_stamp;
156-
do_timer(regs);
156+
do_timer(1);
157157

158158
/*
159159
* update the rtc when needed, this should be performed on the

arch/s390/kernel/time.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ EXPORT_SYMBOL(do_settimeofday);
166166
void account_ticks(struct pt_regs *regs)
167167
{
168168
__u64 tmp;
169-
__u32 ticks, xticks;
169+
__u32 ticks;
170170

171171
/* Calculate how many ticks have passed. */
172172
if (S390_lowcore.int_clock < S390_lowcore.jiffy_timer) {
@@ -204,6 +204,7 @@ void account_ticks(struct pt_regs *regs)
204204
*/
205205
write_seqlock(&xtime_lock);
206206
if (S390_lowcore.jiffy_timer > xtime_cc) {
207+
__u32 xticks;
207208
tmp = S390_lowcore.jiffy_timer - xtime_cc;
208209
if (tmp >= 2*CLK_TICKS_PER_JIFFY) {
209210
xticks = __div(tmp, CLK_TICKS_PER_JIFFY);
@@ -212,13 +213,11 @@ void account_ticks(struct pt_regs *regs)
212213
xticks = 1;
213214
xtime_cc += CLK_TICKS_PER_JIFFY;
214215
}
215-
while (xticks--)
216-
do_timer(regs);
216+
do_timer(xticks);
217217
}
218218
write_sequnlock(&xtime_lock);
219219
#else
220-
for (xticks = ticks; xticks > 0; xticks--)
221-
do_timer(regs);
220+
do_timer(ticks);
222221
#endif
223222

224223
#ifdef CONFIG_VIRT_CPU_ACCOUNTING

arch/sh/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static long last_rtc_update;
117117
*/
118118
void handle_timer_tick(struct pt_regs *regs)
119119
{
120-
do_timer(regs);
120+
do_timer(1);
121121
#ifndef CONFIG_SMP
122122
update_process_times(user_mode(regs));
123123
#endif

arch/sh64/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static inline void do_timer_interrupt(int irq, struct pt_regs *regs)
298298
asm ("getcon cr62, %0" : "=r" (current_ctc));
299299
ctc_last_interrupt = (unsigned long) current_ctc;
300300

301-
do_timer(regs);
301+
do_timer(1);
302302
#ifndef CONFIG_SMP
303303
update_process_times(user_mode(regs));
304304
#endif

arch/sparc/kernel/pcic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ static irqreturn_t pcic_timer_handler (int irq, void *h, struct pt_regs *regs)
712712
{
713713
write_seqlock(&xtime_lock); /* Dummy, to show that we remember */
714714
pcic_clear_clock_irq();
715-
do_timer(regs);
715+
do_timer(1);
716716
#ifndef CONFIG_SMP
717717
update_process_times(user_mode(regs));
718718
#endif

arch/sparc/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
128128
#endif
129129
clear_clock_irq();
130130

131-
do_timer(regs);
131+
do_timer(1);
132132
#ifndef CONFIG_SMP
133133
update_process_times(user_mode(regs));
134134
#endif

arch/sparc64/kernel/time.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs * regs)
465465
profile_tick(CPU_PROFILING, regs);
466466
update_process_times(user_mode(regs));
467467
#endif
468-
do_timer(regs);
468+
do_timer(1);
469469

470470
/* Guarantee that the following sequences execute
471471
* uninterrupted.
@@ -496,7 +496,7 @@ void timer_tick_interrupt(struct pt_regs *regs)
496496
{
497497
write_seqlock(&xtime_lock);
498498

499-
do_timer(regs);
499+
do_timer(1);
500500

501501
timer_check_rtc();
502502

arch/um/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ irqreturn_t um_timer(int irq, void *dev, struct pt_regs *regs)
9393

9494
write_seqlock_irqsave(&xtime_lock, flags);
9595

96-
do_timer(regs);
96+
do_timer(1);
9797

9898
nsecs = get_time();
9999
xtime.tv_sec = nsecs / NSEC_PER_SEC;

arch/v850/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static irqreturn_t timer_interrupt (int irq, void *dummy, struct pt_regs *regs)
5151
if (mach_tick)
5252
mach_tick ();
5353

54-
do_timer (regs);
54+
do_timer (1);
5555
#ifndef CONFIG_SMP
5656
update_process_times(user_mode(regs));
5757
#endif

arch/x86_64/kernel/time.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,16 +415,16 @@ void main_timer_handler(struct pt_regs *regs)
415415
(((long) offset << US_SCALE) / vxtime.tsc_quot) - 1;
416416
}
417417

418-
if (lost > 0) {
418+
if (lost > 0)
419419
handle_lost_ticks(lost, regs);
420-
jiffies += lost;
421-
}
420+
else
421+
lost = 0;
422422

423423
/*
424424
* Do the timer stuff.
425425
*/
426426

427-
do_timer(regs);
427+
do_timer(lost + 1);
428428
#ifndef CONFIG_SMP
429429
update_process_times(user_mode(regs));
430430
#endif

arch/xtensa/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ irqreturn_t timer_interrupt (int irq, void *dev_id, struct pt_regs *regs)
175175

176176
last_ccount_stamp = next;
177177
next += CCOUNT_PER_JIFFY;
178-
do_timer (regs); /* Linux handler in kernel/timer.c */
178+
do_timer (1); /* Linux handler in kernel/timer.c */
179179

180180
if (ntp_synced() &&
181181
xtime.tv_sec - last_rtc_update >= 659 &&

include/asm-arm/arch-clps711x/time.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static irqreturn_t
2929
p720t_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
3030
{
3131
do_leds();
32-
do_timer(regs);
32+
do_timer(1);
3333
#ifndef CONFIG_SMP
3434
update_process_times(user_mode(regs));
3535
#endif

include/asm-arm/arch-l7200/time.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
static irqreturn_t
4646
timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
4747
{
48-
do_timer(regs);
48+
do_timer(1);
4949
#ifndef CONFIG_SMP
5050
update_process_times(user_mode(regs));
5151
#endif

include/asm-i386/mach-default/do_timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
static inline void do_timer_interrupt_hook(struct pt_regs *regs)
1818
{
19-
do_timer(regs);
19+
do_timer(1);
2020
#ifndef CONFIG_SMP
2121
update_process_times(user_mode_vm(regs));
2222
#endif

include/asm-i386/mach-visws/do_timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ static inline void do_timer_interrupt_hook(struct pt_regs *regs)
99
/* Clear the interrupt */
1010
co_cpu_write(CO_CPU_STAT,co_cpu_read(CO_CPU_STAT) & ~CO_STAT_TIMEINTR);
1111

12-
do_timer(regs);
12+
do_timer(1);
1313
#ifndef CONFIG_SMP
1414
update_process_times(user_mode_vm(regs));
1515
#endif

include/asm-i386/mach-voyager/do_timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
static inline void do_timer_interrupt_hook(struct pt_regs *regs)
55
{
6-
do_timer(regs);
6+
do_timer(1);
77
#ifndef CONFIG_SMP
88
update_process_times(user_mode_vm(regs));
99
#endif

include/linux/sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ extern void switch_uid(struct user_struct *);
12061206

12071207
#include <asm/current.h>
12081208

1209-
extern void do_timer(struct pt_regs *);
1209+
extern void do_timer(unsigned long ticks);
12101210

12111211
extern int FASTCALL(wake_up_state(struct task_struct * tsk, unsigned int state));
12121212
extern int FASTCALL(wake_up_process(struct task_struct * tsk));

0 commit comments

Comments
 (0)