Re: [PATCH]atomic_inc_return() for i386/x86_64 (Re: RCU issue with SELinux)

From: Andi Kleen
Date: Tue Aug 31 2004 - 03:57:10 EST


On Tue, Aug 31, 2004 at 05:19:34PM +0900, Kaigai Kohei wrote:
> Hi Andi, thanks for your comment.
> Sorry, I have not noticed your mail in the flood of Linux-Kernel ML.
>
> > > atomic_inc_return() is not defined for arm,arm26,i386,x86_64 and um archtectures.
> > > This attached patch adds atomic_inc_return() and atomic_dec_return() to arm,i386 and x86_64.
> > >
> > > It is implemented by 'xaddl' operation with LOCK prefix for i386 and x86_64.
> > > But this operation is permitted after i486 processor only.
> > > Another implementation may be necessary for i386SX/DX processor.
> > > But 'xaddl' operation is used in 'include/asm-i386/rwsem.h' unconditionally.
> > > I think it has agreed on using 'xaddl' operation in past days.
> >
> > We don't support SMP on 386 boxes. What you can do for 386 is to use
> > alternative() and just use an non SMP safe version for 386 and xadd
> > for 486+
>
> We can avoid the problem by the simple solution, since SMP
> on 386 boxes isn't supported. It is to disable interrupt
> while updating atomic_t variable.

The patch is wrong. A CONFIG_M386 kernel can run on non
386 SMP boxes. Your patch would be racy then. The only thing
that's not supported is a real 386 with multiple CPUs.

You either have to check boot_cpu_data.x86 == 3 at runtime or
use alternative() like I earlier suggested.

> By the way, do you know why 'xadd' operation is used
> unconditionally in 'include/asm-i386/rwsem.h'?

386 compatible kernels use a different rwsem implementation
that doesn't use this include.

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