summaryrefslogtreecommitdiff
path: root/Documentation/local_ops.txt
diff options
context:
space:
mode:
authorChristoph Lameter <cl@linux.com>2014-12-13 03:58:45 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-13 23:42:53 +0300
commit7d94a82e45157318568d839902f46b2085de9e90 (patch)
tree80e8d6490f2bb702cdc1cb296a874afa33ccf73e /Documentation/local_ops.txt
parent6c51ec4d18d24b2ffa69de5d60bebaeb4f8e2398 (diff)
downloadlinux-7d94a82e45157318568d839902f46b2085de9e90.tar.xz
percpu: update local_ops.txt to reflect this_cpu operations
Update the documentation to reflect changes due to the availability of this_cpu operations. Signed-off-by: Christoph Lameter <cl@linux.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation/local_ops.txt')
-rw-r--r--Documentation/local_ops.txt13
1 files changed, 9 insertions, 4 deletions
diff --git a/Documentation/local_ops.txt b/Documentation/local_ops.txt
index 300da4bdfdbd..407576a23317 100644
--- a/Documentation/local_ops.txt
+++ b/Documentation/local_ops.txt
@@ -8,6 +8,11 @@ to implement them for any given architecture and shows how they can be used
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) :