diff options
-rw-r--r-- | Documentation/local_ops.txt | 13 |
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 | |||
8 | properly. It also stresses on the precautions that must be taken when reading | 8 | properly. It also stresses on the precautions that must be taken when reading |
9 | those local variables across CPUs when the order of memory writes matters. | 9 | those local variables across CPUs when the order of memory writes matters. |
10 | 10 | ||
11 | Note that local_t based operations are not recommended for general kernel use. | ||
12 | Please use the this_cpu operations instead unless there is really a special purpose. | ||
13 | Most uses of local_t in the kernel have been replaced by this_cpu operations. | ||
14 | this_cpu operations combine the relocation with the local_t like semantics in | ||
15 | a single instruction and yield more compact and faster executing code. | ||
11 | 16 | ||
12 | 17 | ||
13 | * Purpose of local atomic operations | 18 | * Purpose of local atomic operations |
@@ -87,10 +92,10 @@ the per cpu variable. For instance : | |||
87 | local_inc(&get_cpu_var(counters)); | 92 | local_inc(&get_cpu_var(counters)); |
88 | put_cpu_var(counters); | 93 | put_cpu_var(counters); |
89 | 94 | ||
90 | If you are already in a preemption-safe context, you can directly use | 95 | If you are already in a preemption-safe context, you can use |
91 | __get_cpu_var() instead. | 96 | this_cpu_ptr() instead. |
92 | 97 | ||
93 | local_inc(&__get_cpu_var(counters)); | 98 | local_inc(this_cpu_ptr(&counters)); |
94 | 99 | ||
95 | 100 | ||
96 | 101 | ||
@@ -134,7 +139,7 @@ static void test_each(void *info) | |||
134 | { | 139 | { |
135 | /* Increment the counter from a non preemptible context */ | 140 | /* Increment the counter from a non preemptible context */ |
136 | printk("Increment on cpu %d\n", smp_processor_id()); | 141 | printk("Increment on cpu %d\n", smp_processor_id()); |
137 | local_inc(&__get_cpu_var(counters)); | 142 | local_inc(this_cpu_ptr(&counters)); |
138 | 143 | ||
139 | /* This is what incrementing the variable would look like within a | 144 | /* This is what incrementing the variable would look like within a |
140 | * preemptible context (it disables preemption) : | 145 | * preemptible context (it disables preemption) : |