xfs-masters
[Top] [All Lists]

[xfs-masters] Re: [interesting] smattering of possible memory ordering b

To: benh@xxxxxxxxxxxxxxxxxxx
Subject: [xfs-masters] Re: [interesting] smattering of possible memory ordering bugs
From: Nick Piggin <nickpiggin@xxxxxxxxxxxx>
Date: Fri, 26 Oct 2007 13:47:35 +1000
Cc: Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, paulus@xxxxxxxxx, shaggy@xxxxxxxxxxxxxx, adaplas@xxxxxxxxx, "Morton, Andrew" <akpm@xxxxxxxxxxxxxxxxxxxx>, xfs-masters@xxxxxxxxxxx
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.au; h=Received:X-YMail-OSG:From:To:Subject:Date:User-Agent:Cc:References:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-Disposition:Message-Id; b=eNhTkER685fOd/XQ85jLdKUezA1J3VjA+WqEBD9/b2tYg5YMbnA/xSWpplxDCNLeZlLTpzXMLCrEbMpmwKJdS5Sn7EQRmK41rxO4GFuD0w5WynymGPPwR9KE/3wki9h3Q3WbTK8AZ7jE0BtL+G2kmG5q3FLgRfYbWj9X/GbdjrE= ;
In-reply-to: <1193369717.7018.56.camel@pasglop>
References: <200710261209.58519.nickpiggin@yahoo.com.au> <1193369717.7018.56.camel@pasglop>
Reply-to: xfs-masters@xxxxxxxxxxx
Sender: xfs-masters-bounce@xxxxxxxxxxx
User-agent: KMail/1.9.5
On Friday 26 October 2007 13:35, Benjamin Herrenschmidt wrote:

[acks]

Thanks for those...

> > Index: linux-2.6/include/asm-powerpc/mmu_context.h
> > ===================================================================
> > --- linux-2.6.orig/include/asm-powerpc/mmu_context.h
> > +++ linux-2.6/include/asm-powerpc/mmu_context.h
> > @@ -129,7 +129,7 @@ static inline void get_mmu_context(struc
> >                 steal_context();
> >  #endif
> >         ctx = next_mmu_context;
> > -       while (test_and_set_bit(ctx, context_map)) {
> > +       while (test_and_set_bit_lock(ctx, context_map)) {
> >                 ctx = find_next_zero_bit(context_map, LAST_CONTEXT+1,
> > ctx); if (ctx > LAST_CONTEXT)
> >                         ctx = 0;
> > @@ -158,7 +158,7 @@ static inline void destroy_context(struc
> >  {
> >         preempt_disable();
> >         if (mm->context.id != NO_CONTEXT) {
> > -               clear_bit(mm->context.id, context_map);
> > +               clear_bit_unlock(mm->context.id, context_map);
> >                 mm->context.id = NO_CONTEXT;
> >  #ifdef FEW_CONTEXTS
> >                 atomic_inc(&nr_free_contexts);
>
> I don't think the previous code was wrong... it's not a locked section
> and we don't care about ordering previous stores. It's an allocation, it
> should be fine. In general, bitmap allocators should be allright.

Well if it is just allocating an arbitrary _number_ out of a bitmap
and nothing else (eg. like the pid allocator), then you don't need
barriers.


> Ignore the FEW_CONTEXTS stuff for now :-) At this point, it's UP only
> and will be replaced sooner or later.

OK. Then I agree, provided you're doing the correct synchronisation
or flushing etc. when destroying a context (which presumably you are).

I'll drop those bits then.

Thanks,
Nick


<Prev in Thread] Current Thread [Next in Thread>