percpu: remove per_cpu__ prefix.
Now that the return from alloc_percpu is compatible with the address
of per-cpu vars, it makes sense to hand around the address of per-cpu
variables. To make this sane, we remove the per_cpu__ prefix we used
created to stop people accidentally using these vars directly.
Now we have sparse, we can use that (next patch).
tj: * Updated to convert stuff which were missed by or added after the
original patch.
* Kill per_cpu_var() macro.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Christoph Lameter <cl@linux-foundation.org>
This commit is contained in:
@@ -50,11 +50,11 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
|
||||
* offset.
|
||||
*/
|
||||
#define per_cpu(var, cpu) \
|
||||
(*SHIFT_PERCPU_PTR(&per_cpu_var(var), per_cpu_offset(cpu)))
|
||||
(*SHIFT_PERCPU_PTR(&(var), per_cpu_offset(cpu)))
|
||||
#define __get_cpu_var(var) \
|
||||
(*SHIFT_PERCPU_PTR(&per_cpu_var(var), my_cpu_offset))
|
||||
(*SHIFT_PERCPU_PTR(&(var), my_cpu_offset))
|
||||
#define __raw_get_cpu_var(var) \
|
||||
(*SHIFT_PERCPU_PTR(&per_cpu_var(var), __my_cpu_offset))
|
||||
(*SHIFT_PERCPU_PTR(&(var), __my_cpu_offset))
|
||||
|
||||
#define this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, my_cpu_offset)
|
||||
#define __this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
|
||||
@@ -66,9 +66,9 @@ extern void setup_per_cpu_areas(void);
|
||||
|
||||
#else /* ! SMP */
|
||||
|
||||
#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu_var(var)))
|
||||
#define __get_cpu_var(var) per_cpu_var(var)
|
||||
#define __raw_get_cpu_var(var) per_cpu_var(var)
|
||||
#define per_cpu(var, cpu) (*((void)(cpu), &(var)))
|
||||
#define __get_cpu_var(var) (var)
|
||||
#define __raw_get_cpu_var(var) (var)
|
||||
#define this_cpu_ptr(ptr) per_cpu_ptr(ptr, 0)
|
||||
#define __this_cpu_ptr(ptr) this_cpu_ptr(ptr)
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
#ifndef _LINUX_PERCPU_DEFS_H
|
||||
#define _LINUX_PERCPU_DEFS_H
|
||||
|
||||
/*
|
||||
* Determine the real variable name from the name visible in the
|
||||
* kernel sources.
|
||||
*/
|
||||
#define per_cpu_var(var) per_cpu__##var
|
||||
|
||||
/*
|
||||
* Base implementations of per-CPU variable declarations and definitions, where
|
||||
* the section in which the variable is to be placed is provided by the
|
||||
@@ -56,24 +50,24 @@
|
||||
*/
|
||||
#define DECLARE_PER_CPU_SECTION(type, name, sec) \
|
||||
extern __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \
|
||||
extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name
|
||||
extern __PCPU_ATTRS(sec) __typeof__(type) name
|
||||
|
||||
#define DEFINE_PER_CPU_SECTION(type, name, sec) \
|
||||
__PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \
|
||||
extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
|
||||
__PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
|
||||
__PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \
|
||||
__typeof__(type) per_cpu__##name
|
||||
__typeof__(type) name
|
||||
#else
|
||||
/*
|
||||
* Normal declaration and definition macros.
|
||||
*/
|
||||
#define DECLARE_PER_CPU_SECTION(type, name, sec) \
|
||||
extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name
|
||||
extern __PCPU_ATTRS(sec) __typeof__(type) name
|
||||
|
||||
#define DEFINE_PER_CPU_SECTION(type, name, sec) \
|
||||
__PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES \
|
||||
__typeof__(type) per_cpu__##name
|
||||
__typeof__(type) name
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -137,8 +131,8 @@
|
||||
/*
|
||||
* Intermodule exports for per-CPU variables.
|
||||
*/
|
||||
#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
|
||||
#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
|
||||
#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(var)
|
||||
#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(var)
|
||||
|
||||
|
||||
#endif /* _LINUX_PERCPU_DEFS_H */
|
||||
|
||||
@@ -182,7 +182,7 @@ static inline void *pcpu_lpage_remapped(void *kaddr)
|
||||
#ifndef percpu_read
|
||||
# define percpu_read(var) \
|
||||
({ \
|
||||
typeof(per_cpu_var(var)) __tmp_var__; \
|
||||
typeof(var) __tmp_var__; \
|
||||
__tmp_var__ = get_cpu_var(var); \
|
||||
put_cpu_var(var); \
|
||||
__tmp_var__; \
|
||||
@@ -253,8 +253,7 @@ do { \
|
||||
|
||||
/*
|
||||
* Optimized manipulation for memory allocated through the per cpu
|
||||
* allocator or for addresses of per cpu variables (can be determined
|
||||
* using per_cpu_var(xx).
|
||||
* allocator or for addresses of per cpu variables.
|
||||
*
|
||||
* These operation guarantee exclusivity of access for other operations
|
||||
* on the *same* processor. The assumption is that per cpu data is only
|
||||
|
||||
@@ -76,22 +76,22 @@ DECLARE_PER_CPU(struct vm_event_state, vm_event_states);
|
||||
|
||||
static inline void __count_vm_event(enum vm_event_item item)
|
||||
{
|
||||
__this_cpu_inc(per_cpu_var(vm_event_states).event[item]);
|
||||
__this_cpu_inc(vm_event_states.event[item]);
|
||||
}
|
||||
|
||||
static inline void count_vm_event(enum vm_event_item item)
|
||||
{
|
||||
this_cpu_inc(per_cpu_var(vm_event_states).event[item]);
|
||||
this_cpu_inc(vm_event_states.event[item]);
|
||||
}
|
||||
|
||||
static inline void __count_vm_events(enum vm_event_item item, long delta)
|
||||
{
|
||||
__this_cpu_add(per_cpu_var(vm_event_states).event[item], delta);
|
||||
__this_cpu_add(vm_event_states.event[item], delta);
|
||||
}
|
||||
|
||||
static inline void count_vm_events(enum vm_event_item item, long delta)
|
||||
{
|
||||
this_cpu_add(per_cpu_var(vm_event_states).event[item], delta);
|
||||
this_cpu_add(vm_event_states.event[item], delta);
|
||||
}
|
||||
|
||||
extern void all_vm_events(unsigned long *);
|
||||
|
||||
Reference in New Issue
Block a user