Re: [patch 04/41] cpu ops: Core piece for generic atomic per cpu operations

Rusty Russell
2008-05-30T07:10:15Z

On Friday 30 May 2008 16:12:59 Christoph Lameter wrote:
> On Thu, 29 May 2008, Andrew Morton wrote:
> > > area. It requies disabling of interrupts etc.
> >
> > No it doesn't. Look:
> >
> > static inline void local_inc(local_t *l)
> > {
> > asm volatile(_ASM_INC "%0"
> >
> > : "+m" (l->a.counter));
> >
> > }
> >
> > > Its not atomic (wrt
> > > interrupts) because of that.
> >
> > Yes it is.
>
> No its not! In order to increment a per cpu value you need to calculate
> the per cpu pointer address in the current per cpu segment.

Christoph, you just missed it, that's all. Look at cpu_local_read et al in
include/asm-i386/local.h (ie. before the x86 mergers chose the lowest common
denominator one).

Cheers,
Rusty.