Do per cpu variables need to be atomic?

Christoph Lameter cl at gentwo.org
Fri Jul 11 09:46:56 EDT 2014


On Thu, 10 Jul 2014, Pranith Kumar wrote:

> > Correct.
>
> I understand one of the advantage of using these per cpu variables is
> avoiding disabling interrupts. But what happens when this cpu is
> preempted? The new processor will be working on the other cpu
> variables, but without barriers will it see the latest values?

The this_cpu ops are atomic vs preemption. So you will always get the
value of the current processor. If preemption occurs then then instruction
will get the per cpu data from the new processor.

I cannot post to kernelnewbies at kernelnewbies.org. Some moderator approval
is required. Can you fix that?




More information about the Kernelnewbies mailing list