Messages in this thread | | | Date | Wed, 15 Dec 2010 11:32:56 -0600 (CST) | From | Christoph Lameter <> | Subject | Re: [cpuops cmpxchg V2 3/5] irq_work: Use per cpu atomics instead of regular atomics |
| |
On Wed, 15 Dec 2010, Peter Zijlstra wrote:
> > A prefix is one byte which is less that multiple arithmetic operations to > > calculate an address. > > I thought you'd only need a single arithmetic op to calculate the > address, anyway at some point those 1 byte prefixes will add up to more > than the ops saved.
Yes if you have enough of those then it may no longer be worth it. But here you only have two. And the segment address calculation is efficiently implemented in the processors.
> Still, non of this is really fast-path code, so I really wonder why > we're optimizing this over keeping the code obvious.
I was looking for usecases that already exist for cmpxchg (because the patches introduce this_cpu_cmpxchg also for other uses) and found this one here and it looked like an easy way to use the prefixed operation. Its not that high of a priority but it seems that we are saving code and cycles.
The code is cleaner IMHO. this_cpu_xx documents that the actions here only have local effects and that there is no need of serialization with other processors.
| |