Re: [PATCH v2 6/9] rcu: use __this_cpu_read helper instead ofper_cpu_ptr(p, raw_smp_processor_id())

From: Christoph Lameter
Date: Mon Nov 05 2012 - 10:23:13 EST


On Sat, 3 Nov 2012, Paul E. McKenney wrote:

> OK, I do understand why it happens to work. My question is instead why
> it is considered a good idea. After all, it is the ->rda field that is
> marked __percpu, not the ->mynode field. So in the interest of
> mechanical checking and general readability, it seems to me that it
> would be way better to apply __this_cpu_read() to rsp->rda rather than
> to rsp->rda->mynode.

mynode is part of the structure reached via rda.

Use on rsp->rda does not work since the offset of mynode must be added to
rda before a fetch related to the current cpus per cpu address can be
done.

this_cpu_ptr relocates and address. this_cpu_read() relocates the address
and performs the fetch. If you want to operate on rda then you can only
use this_cpu_ptr. this_cpu_read() saves you more instructions since it can
do the relocation and the fetch in one instruction.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/