Messages in this thread | | | Date | Mon, 5 Nov 2012 15:23:06 +0000 | From | Christoph Lameter <> | Subject | Re: [PATCH v2 6/9] rcu: use __this_cpu_read helper instead of per_cpu_ptr(p, raw_smp_processor_id()) |
| |
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.
| |