aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-15 01:48:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-15 01:48:18 -0400
commit0429fbc0bdc297d64188483ba029a23773ae07b0 (patch)
tree67de46978c90f37540dd6ded1db20eb53a569030 /include/linux
parent6929c358972facf2999f8768815c40dd88514fc2 (diff)
parent513d1a2884a49654f368b5fa25ef186e976bdada (diff)
Merge branch 'for-3.18-consistent-ops' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu
Pull percpu consistent-ops changes from Tejun Heo: "Way back, before the current percpu allocator was implemented, static and dynamic percpu memory areas were allocated and handled separately and had their own accessors. The distinction has been gone for many years now; however, the now duplicate two sets of accessors remained with the pointer based ones - this_cpu_*() - evolving various other operations over time. During the process, we also accumulated other inconsistent operations. This pull request contains Christoph's patches to clean up the duplicate accessor situation. __get_cpu_var() uses are replaced with with this_cpu_ptr() and __this_cpu_ptr() with raw_cpu_ptr(). Unfortunately, the former sometimes is tricky thanks to C being a bit messy with the distinction between lvalues and pointers, which led to a rather ugly solution for cpumask_var_t involving the introduction of this_cpu_cpumask_var_ptr(). This converts most of the uses but not all. Christoph will follow up with the remaining conversions in this merge window and hopefully remove the obsolete accessors" * 'for-3.18-consistent-ops' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu: (38 commits) irqchip: Properly fetch the per cpu offset percpu: Resolve ambiguities in __get_cpu_var/cpumask_var_t -fix ia64: sn_nodepda cannot be assigned to after this_cpu conversion. Use __this_cpu_write. percpu: Resolve ambiguities in __get_cpu_var/cpumask_var_t Revert "powerpc: Replace __get_cpu_var uses" percpu: Remove __this_cpu_ptr clocksource: Replace __this_cpu_ptr with raw_cpu_ptr sparc: Replace __get_cpu_var uses avr32: Replace __get_cpu_var with __this_cpu_write blackfin: Replace __get_cpu_var uses tile: Use this_cpu_ptr() for hardware counters tile: Replace __get_cpu_var uses powerpc: Replace __get_cpu_var uses alpha: Replace __get_cpu_var ia64: Replace __get_cpu_var uses s390: cio driver &__get_cpu_var replacements s390: Replace __get_cpu_var uses mips: Replace __get_cpu_var uses MIPS: Replace __get_cpu_var uses in FPU emulator. arm: Replace __this_cpu_ptr with raw_cpu_ptr ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/cpumask.h11
-rw-r--r--include/linux/kernel_stat.h4
-rw-r--r--include/linux/percpu-defs.h3
3 files changed, 13 insertions, 5 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 2997af6d2ccd..0a9a6da21e74 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -666,10 +666,19 @@ static inline size_t cpumask_size(void)
666 * 666 *
667 * This code makes NR_CPUS length memcopy and brings to a memory corruption. 667 * This code makes NR_CPUS length memcopy and brings to a memory corruption.
668 * cpumask_copy() provide safe copy functionality. 668 * cpumask_copy() provide safe copy functionality.
669 *
670 * Note that there is another evil here: If you define a cpumask_var_t
671 * as a percpu variable then the way to obtain the address of the cpumask
672 * structure differently influences what this_cpu_* operation needs to be
673 * used. Please use this_cpu_cpumask_var_t in those cases. The direct use
674 * of this_cpu_ptr() or this_cpu_read() will lead to failures when the
675 * other type of cpumask_var_t implementation is configured.
669 */ 676 */
670#ifdef CONFIG_CPUMASK_OFFSTACK 677#ifdef CONFIG_CPUMASK_OFFSTACK
671typedef struct cpumask *cpumask_var_t; 678typedef struct cpumask *cpumask_var_t;
672 679
680#define this_cpu_cpumask_var_ptr(x) this_cpu_read(x)
681
673bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node); 682bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node);
674bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags); 683bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags);
675bool zalloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node); 684bool zalloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node);
@@ -681,6 +690,8 @@ void free_bootmem_cpumask_var(cpumask_var_t mask);
681#else 690#else
682typedef struct cpumask cpumask_var_t[1]; 691typedef struct cpumask cpumask_var_t[1];
683 692
693#define this_cpu_cpumask_var_ptr(x) this_cpu_ptr(x)
694
684static inline bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags) 695static inline bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
685{ 696{
686 return true; 697 return true;
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index ecbc52f9ff77..8422b4ed6882 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -44,8 +44,8 @@ DECLARE_PER_CPU(struct kernel_stat, kstat);
44DECLARE_PER_CPU(struct kernel_cpustat, kernel_cpustat); 44DECLARE_PER_CPU(struct kernel_cpustat, kernel_cpustat);
45 45
46/* Must have preemption disabled for this to be meaningful. */ 46/* Must have preemption disabled for this to be meaningful. */
47#define kstat_this_cpu (&__get_cpu_var(kstat)) 47#define kstat_this_cpu this_cpu_ptr(&kstat)
48#define kcpustat_this_cpu (&__get_cpu_var(kernel_cpustat)) 48#define kcpustat_this_cpu this_cpu_ptr(&kernel_cpustat)
49#define kstat_cpu(cpu) per_cpu(kstat, cpu) 49#define kstat_cpu(cpu) per_cpu(kstat, cpu)
50#define kcpustat_cpu(cpu) per_cpu(kernel_cpustat, cpu) 50#define kcpustat_cpu(cpu) per_cpu(kernel_cpustat, cpu)
51 51
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
index cfd56046ecec..420032d41d27 100644
--- a/include/linux/percpu-defs.h
+++ b/include/linux/percpu-defs.h
@@ -257,9 +257,6 @@ do { \
257#define __raw_get_cpu_var(var) (*raw_cpu_ptr(&(var))) 257#define __raw_get_cpu_var(var) (*raw_cpu_ptr(&(var)))
258#define __get_cpu_var(var) (*this_cpu_ptr(&(var))) 258#define __get_cpu_var(var) (*this_cpu_ptr(&(var)))
259 259
260/* keep until we have removed all uses of __this_cpu_ptr */
261#define __this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
262
263/* 260/*
264 * Must be an lvalue. Since @var must be a simple identifier, 261 * Must be an lvalue. Since @var must be a simple identifier,
265 * we force a syntax error here if it isn't. 262 * we force a syntax error here if it isn't.