Commit 466e44bb authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[PATCH] get_cpu_var patch

This makes introduces get_cpu_var()/put_cpu_var() which gets a
per-cpu variable and disables preemption, and renames the (unsafe
under preemption) "this_cpu()" macro to __get_cpu_var().  It also
deletes the redundant definitions in linux/smp.h.
parent b7b75b49
...@@ -1764,7 +1764,7 @@ pfm_stop(struct task_struct *task, pfm_context_t *ctx, void *arg, int count, ...@@ -1764,7 +1764,7 @@ pfm_stop(struct task_struct *task, pfm_context_t *ctx, void *arg, int count,
ia64_srlz_i(); ia64_srlz_i();
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
this_cpu(pfm_dcr_pp) = 0; __get_cpu_var(pfm_dcr_pp) = 0;
#else #else
pfm_tasklist_toggle_pp(0); pfm_tasklist_toggle_pp(0);
#endif #endif
...@@ -2172,7 +2172,7 @@ pfm_start(struct task_struct *task, pfm_context_t *ctx, void *arg, int count, ...@@ -2172,7 +2172,7 @@ pfm_start(struct task_struct *task, pfm_context_t *ctx, void *arg, int count,
if (ctx->ctx_fl_system) { if (ctx->ctx_fl_system) {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
this_cpu(pfm_dcr_pp) = 1; __get_cpu_var(pfm_dcr_pp) = 1;
#else #else
pfm_tasklist_toggle_pp(1); pfm_tasklist_toggle_pp(1);
#endif #endif
...@@ -2227,8 +2227,8 @@ pfm_enable(struct task_struct *task, pfm_context_t *ctx, void *arg, int count, ...@@ -2227,8 +2227,8 @@ pfm_enable(struct task_struct *task, pfm_context_t *ctx, void *arg, int count,
ia64_srlz_i(); ia64_srlz_i();
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
this_cpu(pfm_syst_wide) = 1; __get_cpu_var(pfm_syst_wide) = 1;
this_cpu(pfm_dcr_pp) = 0; __get_cpu_var(pfm_dcr_pp) = 0;
#endif #endif
} else { } else {
/* /*
...@@ -2980,9 +2980,9 @@ perfmon_proc_info(char *page) ...@@ -2980,9 +2980,9 @@ perfmon_proc_info(char *page)
p += sprintf(p, "CPU%d syst_wide : %d\n" p += sprintf(p, "CPU%d syst_wide : %d\n"
"CPU%d dcr_pp : %d\n", "CPU%d dcr_pp : %d\n",
smp_processor_id(), smp_processor_id(),
this_cpu(pfm_syst_wide), __get_cpu_var(pfm_syst_wide),
smp_processor_id(), smp_processor_id(),
this_cpu(pfm_dcr_pp)); __get_cpu_var(pfm_dcr_pp));
#endif #endif
LOCK_PFS(); LOCK_PFS();
...@@ -3052,7 +3052,7 @@ pfm_syst_wide_update_task(struct task_struct *task, int mode) ...@@ -3052,7 +3052,7 @@ pfm_syst_wide_update_task(struct task_struct *task, int mode)
/* /*
* propagate the value of the dcr_pp bit to the psr * propagate the value of the dcr_pp bit to the psr
*/ */
ia64_psr(regs)->pp = mode ? this_cpu(pfm_dcr_pp) : 0; ia64_psr(regs)->pp = mode ? __get_cpu_var(pfm_dcr_pp) : 0;
} }
#endif #endif
...@@ -3546,8 +3546,8 @@ pfm_flush_regs (struct task_struct *task) ...@@ -3546,8 +3546,8 @@ pfm_flush_regs (struct task_struct *task)
ia64_srlz_i(); ia64_srlz_i();
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
this_cpu(pfm_syst_wide) = 0; __get_cpu_var(pfm_syst_wide) = 0;
this_cpu(pfm_dcr_pp) = 0; __get_cpu_var(pfm_dcr_pp) = 0;
#else #else
pfm_tasklist_toggle_pp(0); pfm_tasklist_toggle_pp(0);
#endif #endif
......
...@@ -194,7 +194,7 @@ ia64_save_extra (struct task_struct *task) ...@@ -194,7 +194,7 @@ ia64_save_extra (struct task_struct *task)
pfm_save_regs(task); pfm_save_regs(task);
# ifdef CONFIG_SMP # ifdef CONFIG_SMP
if (this_cpu(pfm_syst_wide)) if (__get_cpu_var(pfm_syst_wide))
pfm_syst_wide_update_task(task, 0); pfm_syst_wide_update_task(task, 0);
# endif # endif
#endif #endif
...@@ -216,7 +216,7 @@ ia64_load_extra (struct task_struct *task) ...@@ -216,7 +216,7 @@ ia64_load_extra (struct task_struct *task)
pfm_load_regs(task); pfm_load_regs(task);
# ifdef CONFIG_SMP # ifdef CONFIG_SMP
if (this_cpu(pfm_syst_wide)) pfm_syst_wide_update_task(task, 1); if (__get_cpu_var(pfm_syst_wide)) pfm_syst_wide_update_task(task, 1);
# endif # endif
#endif #endif
......
...@@ -99,7 +99,7 @@ void ...@@ -99,7 +99,7 @@ void
handle_IPI (int irq, void *dev_id, struct pt_regs *regs) handle_IPI (int irq, void *dev_id, struct pt_regs *regs)
{ {
int this_cpu = smp_processor_id(); int this_cpu = smp_processor_id();
unsigned long *pending_ipis = &this_cpu(ipi_operation); unsigned long *pending_ipis = &__get_cpu_var(ipi_operation);
unsigned long ops; unsigned long ops;
/* Count this now; we may make a call that never returns. */ /* Count this now; we may make a call that never returns. */
......
...@@ -8,6 +8,6 @@ extern unsigned long __per_cpu_offset[NR_CPUS]; ...@@ -8,6 +8,6 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
/* var is in discarded region: offset to particular copy we want */ /* var is in discarded region: offset to particular copy we want */
#define per_cpu(var, cpu) (*RELOC_HIDE(&var, __per_cpu_offset[cpu])) #define per_cpu(var, cpu) (*RELOC_HIDE(&var, __per_cpu_offset[cpu]))
#define this_cpu(var) per_cpu(var, smp_processor_id()) #define __get_cpu_var(var) per_cpu(var, smp_processor_id())
#endif /* _ASM_GENERIC_PERCPU_H_ */ #endif /* _ASM_GENERIC_PERCPU_H_ */
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
extern unsigned long __per_cpu_offset[NR_CPUS]; extern unsigned long __per_cpu_offset[NR_CPUS];
#define per_cpu(var, cpu) (*(__typeof__(&(var))) ((void *) &(var) + __per_cpu_offset[cpu])) #define per_cpu(var, cpu) (*(__typeof__(&(var))) ((void *) &(var) + __per_cpu_offset[cpu]))
#define this_cpu(var) (var) #define __get_cpu_var(var) (var)
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */
......
...@@ -181,7 +181,7 @@ extern struct cpuinfo_ia64 { ...@@ -181,7 +181,7 @@ extern struct cpuinfo_ia64 {
* The "local" data pointer. It points to the per-CPU data of the currently executing * The "local" data pointer. It points to the per-CPU data of the currently executing
* CPU, much like "current" points to the per-task data of the currently executing task. * CPU, much like "current" points to the per-task data of the currently executing task.
*/ */
#define local_cpu_data (&this_cpu(cpu_info)) #define local_cpu_data (&__get_cpu_var(cpu_info))
#define cpu_data(cpu) (&per_cpu(cpu_info, cpu)) #define cpu_data(cpu) (&per_cpu(cpu_info, cpu))
extern void identify_cpu (struct cpuinfo_ia64 *); extern void identify_cpu (struct cpuinfo_ia64 *);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <asm/pda.h> #include <asm/pda.h>
/* var is in discarded region: offset to particular copy we want */ /* var is in discarded region: offset to particular copy we want */
#define this_cpu(var) (*RELOC_HIDE(&var, read_pda(cpudata_offset))) #define __get_cpu_var(var) (*RELOC_HIDE(&var, read_pda(cpudata_offset)))
#define per_cpu(var, cpu) (*RELOC_HIDE(&var, per_cpu_pda[cpu])) #define per_cpu(var, cpu) (*RELOC_HIDE(&var, per_cpu_pda[cpu]))
void setup_per_cpu_areas(void); void setup_per_cpu_areas(void);
......
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
#else #else
#define __per_cpu_data #define __per_cpu_data
#define per_cpu(var, cpu) var #define per_cpu(var, cpu) var
#define this_cpu(var) var #define __get_cpu_var(var) var
#endif #endif
#define get_cpu_var(var) ({ preempt_disable(); __get_cpu_var(var); })
#define put_cpu_var(var) preempt_enable()
#endif /* __LINUX_PERCPU_H */ #endif /* __LINUX_PERCPU_H */
...@@ -96,9 +96,6 @@ static inline void smp_send_reschedule_all(void) { } ...@@ -96,9 +96,6 @@ static inline void smp_send_reschedule_all(void) { }
#define cpu_online_map 1 #define cpu_online_map 1
#define cpu_online(cpu) ({ cpu; 1; }) #define cpu_online(cpu) ({ cpu; 1; })
#define num_online_cpus() 1 #define num_online_cpus() 1
#define __per_cpu_data
#define per_cpu(var, cpu) var
#define this_cpu(var) var
struct notifier_block; struct notifier_block;
......
...@@ -159,8 +159,8 @@ void __tasklet_schedule(struct tasklet_struct *t) ...@@ -159,8 +159,8 @@ void __tasklet_schedule(struct tasklet_struct *t)
unsigned long flags; unsigned long flags;
local_irq_save(flags); local_irq_save(flags);
t->next = this_cpu(tasklet_vec).list; t->next = __get_cpu_var(tasklet_vec).list;
this_cpu(tasklet_vec).list = t; __get_cpu_var(tasklet_vec).list = t;
cpu_raise_softirq(smp_processor_id(), TASKLET_SOFTIRQ); cpu_raise_softirq(smp_processor_id(), TASKLET_SOFTIRQ);
local_irq_restore(flags); local_irq_restore(flags);
} }
...@@ -170,8 +170,8 @@ void __tasklet_hi_schedule(struct tasklet_struct *t) ...@@ -170,8 +170,8 @@ void __tasklet_hi_schedule(struct tasklet_struct *t)
unsigned long flags; unsigned long flags;
local_irq_save(flags); local_irq_save(flags);
t->next = this_cpu(tasklet_hi_vec).list; t->next = __get_cpu_var(tasklet_hi_vec).list;
this_cpu(tasklet_hi_vec).list = t; __get_cpu_var(tasklet_hi_vec).list = t;
cpu_raise_softirq(smp_processor_id(), HI_SOFTIRQ); cpu_raise_softirq(smp_processor_id(), HI_SOFTIRQ);
local_irq_restore(flags); local_irq_restore(flags);
} }
...@@ -181,8 +181,8 @@ static void tasklet_action(struct softirq_action *a) ...@@ -181,8 +181,8 @@ static void tasklet_action(struct softirq_action *a)
struct tasklet_struct *list; struct tasklet_struct *list;
local_irq_disable(); local_irq_disable();
list = this_cpu(tasklet_vec).list; list = __get_cpu_var(tasklet_vec).list;
this_cpu(tasklet_vec).list = NULL; __get_cpu_var(tasklet_vec).list = NULL;
local_irq_enable(); local_irq_enable();
while (list) { while (list) {
...@@ -202,8 +202,8 @@ static void tasklet_action(struct softirq_action *a) ...@@ -202,8 +202,8 @@ static void tasklet_action(struct softirq_action *a)
} }
local_irq_disable(); local_irq_disable();
t->next = this_cpu(tasklet_vec).list; t->next = __get_cpu_var(tasklet_vec).list;
this_cpu(tasklet_vec).list = t; __get_cpu_var(tasklet_vec).list = t;
__cpu_raise_softirq(smp_processor_id(), TASKLET_SOFTIRQ); __cpu_raise_softirq(smp_processor_id(), TASKLET_SOFTIRQ);
local_irq_enable(); local_irq_enable();
} }
...@@ -214,8 +214,8 @@ static void tasklet_hi_action(struct softirq_action *a) ...@@ -214,8 +214,8 @@ static void tasklet_hi_action(struct softirq_action *a)
struct tasklet_struct *list; struct tasklet_struct *list;
local_irq_disable(); local_irq_disable();
list = this_cpu(tasklet_hi_vec).list; list = __get_cpu_var(tasklet_hi_vec).list;
this_cpu(tasklet_hi_vec).list = NULL; __get_cpu_var(tasklet_hi_vec).list = NULL;
local_irq_enable(); local_irq_enable();
while (list) { while (list) {
...@@ -235,8 +235,8 @@ static void tasklet_hi_action(struct softirq_action *a) ...@@ -235,8 +235,8 @@ static void tasklet_hi_action(struct softirq_action *a)
} }
local_irq_disable(); local_irq_disable();
t->next = this_cpu(tasklet_hi_vec).list; t->next = __get_cpu_var(tasklet_hi_vec).list;
this_cpu(tasklet_hi_vec).list = t; __get_cpu_var(tasklet_hi_vec).list = t;
__cpu_raise_softirq(smp_processor_id(), HI_SOFTIRQ); __cpu_raise_softirq(smp_processor_id(), HI_SOFTIRQ);
local_irq_enable(); local_irq_enable();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment