diff options
author | Milton Miller <miltonm@bga.com> | 2007-12-13 23:52:15 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-12-20 00:15:41 -0500 |
commit | 6e6b44e8223a01d35fceec3631be356fbdbcf004 (patch) | |
tree | dab1e44a25802a2119e3ab1bdb855598640a1eda /arch | |
parent | 8b5621f183f7e56958b0a0aae689af5af2efeda7 (diff) |
[POWERPC] Timer interrupt: use a struct for two per_cpu varables
timer_interrupt() was calculating per_cpu_offset several times, having to
start from the toc because of potential aliasing issues.
Placing both decrementer per_cpu varables in a struct and calculating
the address once with __get_cpu_var results in better code on both 32
and 64 bit.
Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/kernel/time.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 888c65726ebd..5cf394080590 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
@@ -116,8 +116,12 @@ static struct clock_event_device decrementer_clockevent = { | |||
116 | .features = CLOCK_EVT_FEAT_ONESHOT, | 116 | .features = CLOCK_EVT_FEAT_ONESHOT, |
117 | }; | 117 | }; |
118 | 118 | ||
119 | static DEFINE_PER_CPU(struct clock_event_device, decrementers); | 119 | struct decrementer_clock { |
120 | static DEFINE_PER_CPU(u64, decrementer_next_tb); | 120 | struct clock_event_device event; |
121 | u64 next_tb; | ||
122 | }; | ||
123 | |||
124 | static DEFINE_PER_CPU(struct decrementer_clock, decrementers); | ||
121 | 125 | ||
122 | #ifdef CONFIG_PPC_ISERIES | 126 | #ifdef CONFIG_PPC_ISERIES |
123 | static unsigned long __initdata iSeries_recal_titan; | 127 | static unsigned long __initdata iSeries_recal_titan; |
@@ -555,8 +559,8 @@ void __init iSeries_time_init_early(void) | |||
555 | void timer_interrupt(struct pt_regs * regs) | 559 | void timer_interrupt(struct pt_regs * regs) |
556 | { | 560 | { |
557 | struct pt_regs *old_regs; | 561 | struct pt_regs *old_regs; |
558 | int cpu = smp_processor_id(); | 562 | struct decrementer_clock *decrementer = &__get_cpu_var(decrementers); |
559 | struct clock_event_device *evt = &per_cpu(decrementers, cpu); | 563 | struct clock_event_device *evt = &decrementer->event; |
560 | u64 now; | 564 | u64 now; |
561 | 565 | ||
562 | /* Ensure a positive value is written to the decrementer, or else | 566 | /* Ensure a positive value is written to the decrementer, or else |
@@ -569,9 +573,9 @@ void timer_interrupt(struct pt_regs * regs) | |||
569 | #endif | 573 | #endif |
570 | 574 | ||
571 | now = get_tb_or_rtc(); | 575 | now = get_tb_or_rtc(); |
572 | if (now < per_cpu(decrementer_next_tb, cpu)) { | 576 | if (now < decrementer->next_tb) { |
573 | /* not time for this event yet */ | 577 | /* not time for this event yet */ |
574 | now = per_cpu(decrementer_next_tb, cpu) - now; | 578 | now = decrementer->next_tb - now; |
575 | if (now <= DECREMENTER_MAX) | 579 | if (now <= DECREMENTER_MAX) |
576 | set_dec((int)now); | 580 | set_dec((int)now); |
577 | return; | 581 | return; |
@@ -810,7 +814,7 @@ void __init clocksource_init(void) | |||
810 | static int decrementer_set_next_event(unsigned long evt, | 814 | static int decrementer_set_next_event(unsigned long evt, |
811 | struct clock_event_device *dev) | 815 | struct clock_event_device *dev) |
812 | { | 816 | { |
813 | __get_cpu_var(decrementer_next_tb) = get_tb_or_rtc() + evt; | 817 | __get_cpu_var(decrementers).next_tb = get_tb_or_rtc() + evt; |
814 | set_dec(evt); | 818 | set_dec(evt); |
815 | return 0; | 819 | return 0; |
816 | } | 820 | } |
@@ -824,7 +828,7 @@ static void decrementer_set_mode(enum clock_event_mode mode, | |||
824 | 828 | ||
825 | static void register_decrementer_clockevent(int cpu) | 829 | static void register_decrementer_clockevent(int cpu) |
826 | { | 830 | { |
827 | struct clock_event_device *dec = &per_cpu(decrementers, cpu); | 831 | struct clock_event_device *dec = &per_cpu(decrementers, cpu).event; |
828 | 832 | ||
829 | *dec = decrementer_clockevent; | 833 | *dec = decrementer_clockevent; |
830 | dec->cpumask = cpumask_of_cpu(cpu); | 834 | dec->cpumask = cpumask_of_cpu(cpu); |