From: Andi Kleen <ak@suse.de>
To: ajwade@cpe001346162bf9-cm0011ae8cd564.cpe.net.cable.rogers.com
Cc: vatsa@in.ibm.com, Oleg Nesterov <oleg@tv-sign.ru>,
linux-kernel@vger.kernel.org,
Dipankar Sarma <dipankar@in.ibm.com>,
"Paul E. McKenney" <paulmck@us.ibm.com>,
Andrew Morton <akpm@osdl.org>, Ingo Molnar <mingo@elte.hu>
Subject: Re: Semantics of smp_mb() [was : Re: [PATCH] Fix RCU race in access of nohz_cpu_mask ]
Date: 13 Dec 2005 04:20:13 -0700 [thread overview]
Message-ID: <p73vext8cr6.fsf@verdi.suse.de> (raw)
In-Reply-To: <200512130007.48712.ajwade@cpe001346162bf9-cm0011ae8cd564.cpe.net.cable.rogers.com>
Andrew James Wade <andrew.j.wade@gmail.com> writes:
>
> What does it mean for a write to start? For that matter, what does it mean
> for a write to complete?
wmb() or smp_smb() really makes no guarantees when a write
completes (e.g. when another CPU or a device sees the new value)
It just guarantees ordering. This means when you do e.g.
*p = 1;
wmb();
*p = 2;
wmb();
then another CPU will never see 2 before 1 (but possibly it might
miss the "1 state completely"). When it actually sees the values
(or if it keeps using whatever value was in *p before the first
assignment) is undefined.
The definition quoted above is wrong I think. Rusty can you
perhaps fix it up?
> I think my focusing on the hardware details (of which I am woefully
> ignorant) was a mistake: the hardware can really do whatever it wants so
> long as it implements the expected abstract machine model, and it is
> ordering that matters in that model. So it makes sense that ordering, not
> time, is what the definitions of the memory barriers focus on.
Exactly.
> > Does this mb() garantees that the new value of ->cur will be visible
> > on other cpus immediately after smp_sees 1 or 2 is undefined. mb() (so that rcu_pending() will
> > notice it) ?
> is really just about the timeliness with which writes before a smp_mb()
> become visible to other CPUs. Does Linux run on architectures in which
> writes are not propagated in a timely manner (that is: other CPUs can read
> stale values for a "considerable" time)? I rather doubt it.
>
> But with a proviso to my answer: the compiler will happily hoist reads out
> of loops. So writes won't necessarily get read in a timely manner.
Or just consider interrupts. Any CPU can stop for an very long time
at any time as seen by the other CPUs. Or it might take an machine check
and come back. You can never make any assumptions about when another
CPU sees a write unless you add explicit synchronization like a spinlock.
-Andi
next prev parent reply other threads:[~2005-12-13 6:48 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-08 19:31 [PATCH] Fix RCU race in access of nohz_cpu_mask Oleg Nesterov
2005-12-09 2:46 ` Srivatsa Vaddagiri
2005-12-09 19:17 ` Oleg Nesterov
2005-12-10 15:19 ` Srivatsa Vaddagiri
2005-12-10 18:55 ` Oleg Nesterov
2005-12-11 17:41 ` Semantics of smp_mb() [was : Re: [PATCH] Fix RCU race in access of nohz_cpu_mask ] Srivatsa Vaddagiri
2005-12-11 21:21 ` Andrew James Wade
2005-12-11 23:45 ` Rusty Russell
2005-12-12 0:49 ` Keith Owens
2005-12-12 8:41 ` Srivatsa Vaddagiri
2005-12-12 19:33 ` Oleg Nesterov
2005-12-13 5:20 ` Paul E. McKenney
2005-12-13 5:07 ` Andrew James Wade
2005-12-13 5:43 ` Paul E. McKenney
2005-12-13 11:20 ` Andi Kleen [this message]
2005-12-13 16:20 ` Paul E. McKenney
2005-12-13 22:27 ` Keith Owens
2005-12-13 22:50 ` Paul E. McKenney
2005-12-14 1:12 ` Andi Kleen
2005-12-14 1:46 ` Paul E. McKenney
2005-12-15 21:15 ` Semantics of smp_mb() Roland Dreier
2005-12-16 7:46 ` Semantics of smp_mb() [was : Re: [PATCH] Fix RCU race in access of nohz_cpu_mask ] Jeremy Higdon
2006-03-13 18:39 ` Paul E. McKenney
2006-03-31 4:56 ` Jeremy Higdon
2006-03-31 6:18 ` Paul E. McKenney
2006-03-31 23:38 ` Jesse Barnes
2005-12-12 3:10 ` [PATCH] Fix RCU race in access of nohz_cpu_mask Paul E. McKenney
2005-12-12 4:32 ` Andrew Morton
2005-12-12 4:38 ` David S. Miller
2005-12-12 4:47 ` Nick Piggin
2005-12-12 4:49 ` Paul Mackerras
2005-12-12 6:27 ` Keith Owens
2005-12-09 2:56 ` Srivatsa Vaddagiri
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=p73vext8cr6.fsf@verdi.suse.de \
--to=ak@suse.de \
--cc=ajwade@cpe001346162bf9-cm0011ae8cd564.cpe.net.cable.rogers.com \
--cc=akpm@osdl.org \
--cc=dipankar@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--cc=paulmck@us.ibm.com \
--cc=vatsa@in.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox