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

From: Rusty Russell
Date: Fri May 30 2008 - 03:10:16 EST


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.
--
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/