per-cpu patch 3/3
Subsystems (2)
PATCH 1/1 per-cpu patch 3/3
David gets bitten most by this, being the most enthusiastic per_cpu_data user, but Richard wanted to use __thread for Alpha.
Does everyone like this? (Also see two previous patches this depends on). If so I'll send to Linus.
Name: DECLARE_PER_CPU/DEFINE_PER_CPU patch
Author: Rusty Russell
Status: Cleanup
Depends: Misc/get-percpu.patch.gz Misc/percpu-export.patch.gz
D: This old __per_cpu_data define wasn't enough if an arch wants to
D: use the gcc __thread prefix (thread local storage), which needs to
D: go *before* the type in the definition. So we have to go for a
D: DECLARE macro, and while we're there, separate DECLARE and DEFINE,
D: as definitions of per-cpu data cannot live in modules. This also
D: means that accidental direct references to per-cpu variables will
D: be caught at compile time.
arch/ia64/kernel/perfmon.c +2 -2
@@ -369,8 +369,8 @@ static pmu_config_t pmu_conf; /* PMU costatic pfm_session_t pfm_sessions;/* global sessions information */ static struct proc_dir_entry *perfmon_dir;/* for debug only */ static pfm_stats_t pfm_stats; -int __per_cpu_data pfm_syst_wide; -static int __per_cpu_data pfm_dcr_pp; +DEFINE_PER_CPU(int pfm_syst_wide); +static DEFINE_PER_CPU(int pfm_dcr_pp);/* sysctl() controls */ static pfm_sysctl_t pfm_sysctl;
arch/ia64/kernel/setup.c +1 -1
@@ -58,7 +58,7 @@ extern char _end;unsigned long __per_cpu_offset[NR_CPUS ];#endif -struct cpuinfo_ia64 cpu_info __per_cpu_data; +DECLARE_PER_CPU(struct cpuinfo_ia64 cpu_info);unsigned long ia64_phys_stacked_size_p8;unsigned long ia64_cycles_per_usec;
arch/ia64/kernel/smp.c +1 -1
@@ -80,7 +80,7 @@ static volatile struct call_data_struct#define IPI_CPU_STOP 1/* This needs to be cacheline aligned because it is written to by *other* CPUs. */ -static __u64 ipi_operation __per_cpu_data ____cacheline_aligned; +static DECLARE_PER_CPU(__u64 ipi_operation) ____cacheline_aligned;static void stop_this_cpu (void )
arch/ppc/Makefile +8 -8
@@ -127,13 +127,13 @@ else NEW_AS := 0 endif -ifneq ($(NEW_AS),0) -checkbin: - @echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build' - @echo 'correctly with old versions of binutils.' - @echo '*** Please upgrade your binutils to ${GOODVER} or newer' - @false -else +# ifneq ($(NEW_AS),0) +# checkbin: +# @echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build' +# @echo 'correctly with old versions of binutils.' +# @echo '*** Please upgrade your binutils to ${GOODVER} or newer' +# @false +# else checkbin: @true -endif +# endif
arch/ppc/kernel/asm-offsets.h +69 -0
69 lines not on this page · raw message
include/asm-generic/percpu.h +20 -2
@@ -1,13 +1,31 @@#ifndef _ASM_GENERIC_PERCPU_H_#define _ASM_GENERIC_PERCPU_H_ +#include <linux/compiler.h> #define __GENERIC_PER_CPU -#include <linux/compiler.h> +#ifdef CONFIG_SMP extern unsigned long __per_cpu_offset[NR_CPUS ]; +#ifndef MODULE +#define DEFINE_PER_CPU (var) var##__percpu __attribute__((section(".data.percpu"))) +#endif +#define DECLARE_PER_CPU (var) extern var##__percpu +/* 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##__percpu, __per_cpu_offset[cpu]))#define __get_cpu_var (var) per_cpu(var, smp_processor_id()) + +#else /* ! SMP */ + +/* Can't define per-cpu variables in modules. Sorry --RR */ +#ifndef MODULE +#define DEFINE_PER_CPU (var) var##__percpu +#endif +#define DECLARE_PER_CPU (var) extern var##__percpu + +#define per_cpu (var, cpu) var##__percpu +#define __get_cpu_var (var) var##__percpu +#endif #endif /* _ASM_GENERIC_PERCPU_H_ */
include/asm-ia64/percpu.h +7 -2
@@ -16,8 +16,13 @@extern unsigned long __per_cpu_offset[NR_CPUS ]; -#define per_cpu (var, cpu) (*(__typeof__(&(var))) ((void *) &(var) + __per_cpu_offset[cpu])) -#define __get_cpu_var (var) (var) +#ifndef MODULE +#define DEFINE_PER_CPU (var) var##__percpu __attribute__((section(".data.percpu"))) +#endif +#define DECLARE_PER_CPU (var) extern var##__percpu + +#define per_cpu (var, cpu) (*RELOC_HIDE(&var##__percpu, __per_cpu_offset[cpu])) +#define __get_cpu_var (var) (var##__percpu)#endif /* !__ASSEMBLY__ */
include/asm-ia64/processor.h +2 -2
@@ -134,7 +134,7 @@ struct ia64_psr {* CPU type, hardware bug flags, and per-CPU state. Frequently used * state comes earlier: */ -extern struct cpuinfo_ia64 { +DECLARE_PER_CPU(struct cpuinfo_ia64 { /* irq_stat must be 64-bit aligned */ union { struct {
@@ -175,7 +175,7 @@ extern struct cpuinfo_ia64 {__u64 prof_counter;__u64 prof_multiplier;#endif -}cpu_info __per_cpu_data; +} cpu_info);/* * The "local" data pointer. It points to the per-CPU data of the currently executing
include/linux/percpu.h +2 -9
@@ -1,16 +1,9 @@#ifndef __LINUX_PERCPU_H#define __LINUX_PERCPU_H -#include <linux/config.h> - -#ifdef CONFIG_SMP -#define __per_cpu_data __attribute__((section(".data.percpu"))) +#include <linux/spinlock.h> /* For preempt_disable() */ #include <asm/percpu.h> -#else -#define __per_cpu_data -#define per_cpu (var, cpu) var -#define __get_cpu_var (var) var -#endif #define get_cpu_var (var) ({ preempt_disable(); __get_cpu_var(var); })#define put_cpu_var (var) preempt_enable() +#endif /* __LINUX_PERCPU_H */
kernel/softirq.c +2 -2
@@ -154,8 +154,8 @@ struct tasklet_head/* Some compilers disobey section attribute on statics when not initialized -- RR */ -static struct tasklet_head tasklet_vec __per_cpu_data = { NULL }; -static struct tasklet_head tasklet_hi_vec __per_cpu_data = { NULL }; +static DEFINE_PER_CPU(struct tasklet_head tasklet_vec) = { NULL }; +static DEFINE_PER_CPU(struct tasklet_head tasklet_hi_vec) = { NULL };void __tasklet_schedule (struct tasklet_struct *t) {
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.