Skip to contentSkip to conversation

percpu: Consistent per cpu operations: The final edition

PATCH New Christoph Lameter 1 participant 5 messages Dec 2, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover percpu: Consistent per cpu operations: The final edition

This patchset removes the last leftovers of __get_cpu_var in the kernel. It updates the documentation and then removes the macros.

#1 lore raw

PATCH 1/4 Remove __get_cpu_var and __raw_get_cpu_var macros

No user is left in the kernel source tree. Therefore we can drop the definitions.

This is the final merge of the transition away from __get_cpu_var. After this patch the kernel will not build if anyone uses __get_cpu_var.

---
 include/asm-generic/percpu.h | 5 -----
 1 file changed, 5 deletions(-)
include/linux/percpu-defs.h +0 -2
Index: linux/include/linux/percpu-defs.h
===================================================================
@@ -254,8 +254,6 @@ do {									\
 #endif	/* CONFIG_SMP */
 
 #define per_cpu(var, cpu)	(*per_cpu_ptr(&(var), cpu))
-#define __raw_get_cpu_var(var)	(*raw_cpu_ptr(&(var)))
-#define __get_cpu_var(var)	(*this_cpu_ptr(&(var)))
 
 /*
  * Must be an lvalue. Since @var must be a simple identifier,
#4 lore raw

PATCH 4/4 parisc: Update comments refereing to __get_cpu_var

In reply to Christoph Lameter

__get_cpu_var was removed. Update comments to refer to this_cpu_ptr() instead.

Cc "James E.J. Bottomley" <[email protected]>
arch/parisc/lib/fixup.S +2 -2
Index: linux/arch/parisc/lib/fixup.S
===================================================================
@@ -38,14 +38,14 @@
 	LDREGX \t2(\t1),\t2 
 	addil LT%exception_data,%r27
 	LDREG RT%exception_data(%r1),\t1
-	/* t1 = &__get_cpu_var(exception_data) */
+	/* t1 = this_cpu_ptr(&exception_data) */
 	add,l \t1,\t2,\t1
 	/* t1 = t1->fault_ip */
 	LDREG EXCDATA_IP(\t1), \t1
 	.endm
 #else
 	.macro  get_fault_ip t1 t2
-	/* t1 = &__get_cpu_var(exception_data) */
+	/* t1 = this_cpu_ptr(&exception_data) */
 	addil LT%exception_data,%r27
 	LDREG RT%exception_data(%r1),\t2
 	/* t1 = t2->fault_ip */
#3 lore raw

PATCH 3/4 ia64: Update comment that references __get_cpu_var

In reply to Christoph Lameter

__get_cpu_var was removed. Update the comments.

arch/ia64/include/asm/percpu.h +2 -2
Index: linux/arch/ia64/include/asm/percpu.h
===================================================================
@@ -35,8 +35,8 @@ extern void *per_cpu_init(void);
 
 /*
  * Be extremely careful when taking the address of this variable!  Due to virtual
- * remapping, it is different from the canonical address returned by __get_cpu_var(var)!
- * On the positive side, using __ia64_per_cpu_var() instead of __get_cpu_var() is slightly
+ * remapping, it is different from the canonical address returned by this_cpu_ptr(&var)!
+ * On the positive side, using __ia64_per_cpu_var() instead of this_cpu_ptr() is slightly
  * more efficient.
  */
 #define __ia64_per_cpu_var(var) (*({					\
#2 lore raw

PATCH 2/4 Update local_ops.txt to reflect this_cpu operations

In reply to Christoph Lameter

Update the documentation to reflect changes due to the availability of this_cpu operations.

---
 include/asm-generic/percpu.h | 5 -----
 1 file changed, 5 deletions(-)
Documentation/local_ops.txt +9 -4
Index: linux/Documentation/local_ops.txt
===================================================================
@@ -8,6 +8,11 @@ to implement them for any given architec
 properly. It also stresses on the precautions that must be taken when reading
 those local variables across CPUs when the order of memory writes matters.
 
+Note that local_t based operations are not recommended for general kernel use.
+Please use the this_cpu operations instead unless there is really a special purpose.
+Most uses of local_t in the kernel have been replaced by this_cpu operations.
+this_cpu operations combine the relocation with the local_t like semantics in
+a single instruction and yield more compact and faster executing code.
 
 
 * Purpose of local atomic operations
@@ -87,10 +92,10 @@ the per cpu variable. For instance :
 	local_inc(&get_cpu_var(counters));
 	put_cpu_var(counters);
 
-If you are already in a preemption-safe context, you can directly use
-__get_cpu_var() instead.
+If you are already in a preemption-safe context, you can use
+this_cpu_ptr() instead.
 
-	local_inc(&__get_cpu_var(counters));
+	local_inc(this_cpu_ptr(&counters));
 
 
 
@@ -134,7 +139,7 @@ static void test_each(void *info)
 {
 	/* Increment the counter from a non preemptible context */
 	printk("Increment on cpu %d\n", smp_processor_id());
-	local_inc(&__get_cpu_var(counters));
+	local_inc(this_cpu_ptr(&counters));
 
 	/* This is what incrementing the variable would look like within a
 	 * preemptible context (it disables preemption) :