From: jamie@shareable.org (Jamie Lokier)
To: linux-arm-kernel@lists.infradead.org
Subject: LDREX/STREX and pre-emption on *non*-SMP hardware
Date: Sun, 13 Sep 2009 20:49:38 +0100 [thread overview]
Message-ID: <20090913194938.GA30195@shareable.org> (raw)
Catalin Marinas wrote:
> Yes, but the exclusives are not affected (see below).
>
> > Meanwhile, if we could assume that interrupt handlers are always using
> > the LDREX/CLREX in pairs, then the same thing could be assumed for any
> > other contexts in the system, kernel/user threads. Therefore, I do not
> > think that we can make that assumption.
>
> In user space you can get (T1, T2 are threads):
>
> T1 T2
> LDREX
> LDREX
> STREX (succeeds)
> STREX (fails)
>
> So the STREX in T1 shouldn't really succeed because there was a context
> switch and LDREX in T2 (this particular case may not be a problem but if
> you create a situation with 3 threads that is incorrect).
Hey, wait a moment. It's true that with >=2 CPUs, another CPU could
write the location used by T1, so T1's STREX should not succeed.
But what about a single CPU system?
Even with 3 or more threads, I do not see how any sequence could
result in the STREX succeeding wrongly, because it can only be wrong
if there's an intermediate write to the same location, and we've
established that all writes to that location (including atomic_set)
use STREX. And in principle, even if atomic_set is changed in future,
all paths leading to it must clear the monitor flag somehow.
In other words, it looks like CLREX is not required in __switch_to()
on single CPU systems.
What do you think Catalin? Do you have a counterexample?
-- Jamie
next reply other threads:[~2009-09-13 19:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-13 19:49 Jamie Lokier [this message]
2009-09-13 21:24 ` LDREX/STREX and pre-emption on *non*-SMP hardware Catalin Marinas
2009-09-14 1:44 ` Jamie Lokier
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=20090913194938.GA30195@shareable.org \
--to=jamie@shareable.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).