Do per cpu variables need to be atomic?

Pranith Kumar pranith at gatech.edu
Thu Jul 10 16:11:13 EDT 2014


Hello,

Let us say we have a per-cpu data structure as follows:

struct data {
        atomic_t val;
};

Since this is a per-cpu data structure, do I need to have 'val' as
atomic? Or can I just use a normal 'int' for val?

Also are the following the same? If yes, which is preferable?

DEFINE_PER_CPU(struct data, datap);

struct data __percpu *p = &datap;

struct data *p = this_cpu_ptr(&datap);

Thanks,
-- 
Pranith



More information about the Kernelnewbies mailing list