From: Nick Piggin <nickpiggin@yahoo.com.au>
To: benh@kernel.crashing.org
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
paulus@samba.org, shaggy@austin.ibm.com, adaplas@gmail.com,
"Morton, Andrew" <akpm@linux-foundation.org>,
xfs-masters@oss.sgi.com
Subject: Re: [interesting] smattering of possible memory ordering bugs
Date: Fri, 26 Oct 2007 13:47:35 +1000 [thread overview]
Message-ID: <200710261347.35545.nickpiggin@yahoo.com.au> (raw)
In-Reply-To: <1193369717.7018.56.camel@pasglop>
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
next prev parent reply other threads:[~2007-10-26 3:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-26 2:09 [interesting] smattering of possible memory ordering bugs Nick Piggin
2007-10-26 3:35 ` Benjamin Herrenschmidt
2007-10-26 3:47 ` Nick Piggin [this message]
2007-10-26 4:32 ` Benjamin Herrenschmidt
2007-10-26 13:45 ` Dave Kleikamp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200710261347.35545.nickpiggin@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=adaplas@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@samba.org \
--cc=shaggy@austin.ibm.com \
--cc=xfs-masters@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.