diff options
| author | Rusty Russell <rusty@rustcorp.com.au> | 2003-06-26 19:43:55 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.osdl.org> | 2003-06-26 19:43:55 -0700 |
| commit | 6d338bb299e65cc7a5d86fce60daa03a81ffb41d (patch) | |
| tree | 0a55c58ed879bafbfb7d970af40011c226b7108d /kernel/timer.c | |
| parent | 5e49d31efe65aa18e9643c0174353a3aacc234fa (diff) | |
[PATCH] Use Local Percpu Macros for Local Percpu Variables
In general, it is more better to use get_cpu_var() and __get_cpu_var()
to access per-cpu variables on this CPU than to use smp_processor_id()
and per_cpu(). In the current default implemention they are equivalent,
but on IA64 the former is already faster, and other archs will follow.
Diffstat (limited to 'kernel/timer.c')
| -rw-r--r-- | kernel/timer.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/timer.c b/kernel/timer.c index ad3758c663d4..7bce7a7cb2c2 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -156,8 +156,7 @@ static void internal_add_timer(tvec_base_t *base, struct timer_list *timer) */ void add_timer(struct timer_list *timer) { - int cpu = get_cpu(); - tvec_base_t *base = &per_cpu(tvec_bases, cpu); + tvec_base_t *base = &get_cpu_var(tvec_bases); unsigned long flags; BUG_ON(timer_pending(timer) || !timer->function); @@ -168,7 +167,7 @@ void add_timer(struct timer_list *timer) internal_add_timer(base, timer); timer->base = base; spin_unlock_irqrestore(&base->lock, flags); - put_cpu(); + put_cpu_var(tvec_bases); } /*** @@ -231,7 +230,7 @@ int mod_timer(struct timer_list *timer, unsigned long expires) return 1; spin_lock_irqsave(&timer->lock, flags); - new_base = &per_cpu(tvec_bases, smp_processor_id()); + new_base = &__get_cpu_var(tvec_bases); repeat: old_base = timer->base; @@ -789,7 +788,7 @@ seqlock_t xtime_lock __cacheline_aligned_in_smp = SEQLOCK_UNLOCKED; */ static void run_timer_softirq(struct softirq_action *h) { - tvec_base_t *base = &per_cpu(tvec_bases, smp_processor_id()); + tvec_base_t *base = &__get_cpu_var(tvec_bases); if (time_after_eq(jiffies, base->timer_jiffies)) __run_timers(base); |
