Lines Matching +full:cpu +full:- +full:read

29 Local atomic operations are meant to provide fast and highly reentrant per CPU
34 Having fast per CPU atomic counters is interesting in many cases: it does not
40 CPU which owns the data. Therefore, care must taken to make sure that only one
41 CPU writes to the ``local_t`` data. This is done by using per cpu data and
43 however permitted to read ``local_t`` data from any CPU: it will then appear to
44 be written out of order wrt other memory writes by the owner CPU.
54 ``asm-generic/local.h`` in your architecture's ``local.h`` is sufficient.
66 * Variables touched by local ops must be per cpu variables.
67 * *Only* the CPU owner of these variables must write to them.
68 * This CPU can use local ops from any context (process, irq, softirq, nmi, ...)
72 different CPU between getting the per-cpu variable and doing the
75 taken on a mainline kernel, since they will run on the local CPU with
78 -rt kernels.
79 * Reading the local cpu variable will provide the current copy of the
81 * Reads of these variables can be done from any CPU, because updates to
83 synchronization is done by the writer CPU, an outdated copy of the
84 variable can be read when reading some *other* cpu's variables.
105 access to the per cpu variable. For instance::
110 If you are already in a preemption-safe context, you can use
120 Those local counters can be read from foreign CPUs to sum the count. Note that
122 relatively to other memory writes happening on the CPU that owns the data::
125 for_each_online_cpu(cpu)
126 sum += local_read(&per_cpu(counters, cpu));
133 ``smp_rmb()`` between the counter read and the buffer read.
136 Here is a sample module which implements a basic per cpu counter using
139 /* test-local.c
153 /* IPI called on each CPU. */
157 printk("Increment on cpu %d\n", smp_processor_id());
170 int cpu;
174 /* Read all the counters */
175 printk("Counters read from CPU %d\n", smp_processor_id());
176 for_each_online_cpu(cpu) {
177 printk("Read : CPU %d, count %ld\n", cpu,
178 local_read(&per_cpu(counters, cpu)));