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 | |
| 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')
| -rw-r--r-- | kernel/exit.c | 2 | ||||
| -rw-r--r-- | kernel/fork.c | 2 | ||||
| -rw-r--r-- | kernel/timer.c | 9 |
3 files changed, 6 insertions, 7 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 7dee095b31bd..367854d246ef 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -41,7 +41,7 @@ static void __unhash_process(struct task_struct *p) detach_pid(p, PIDTYPE_PGID); detach_pid(p, PIDTYPE_SID); if (p->pid) - per_cpu(process_counts, smp_processor_id())--; + __get_cpu_var(process_counts)--; } REMOVE_LINKS(p); diff --git a/kernel/fork.c b/kernel/fork.c index 5ef2dca02354..2abbc9c2da23 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1006,7 +1006,7 @@ struct task_struct *copy_process(unsigned long clone_flags, attach_pid(p, PIDTYPE_PGID, p->pgrp); attach_pid(p, PIDTYPE_SID, p->session); if (p->pid) - per_cpu(process_counts, smp_processor_id())++; + __get_cpu_var(process_counts)++; } else link_pid(p, p->pids + PIDTYPE_TGID, &p->group_leader->pids[PIDTYPE_TGID].pid); 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); |
