From: Peter Zijlstra <peterz@infradead.org>
To: Will Deacon <will.deacon@arm.com>
Cc: 陈华才 <chenhc@lemote.com>, "Paul Burton" <paul.burton@mips.com>,
"Ralf Baechle" <ralf@linux-mips.org>,
"James Hogan" <james.hogan@mips.com>,
linux-mips <linux-mips@linux-mips.org>,
"Fuxin Zhang" <zhangfx@lemote.com>,
wuzhangjin <wuzhangjin@gmail.com>,
"Huacai Chen" <chenhuacai@gmail.com>,
stable <stable@vger.kernel.org>,
"Alan Stern" <stern@rowland.harvard.edu>,
AndreaParri <andrea.parri@amarulasolutions.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"David Howells" <dhowells@redhat.com>,
"Jade Alglave" <j.alglave@ucl.ac.uk>,
"Luc Maranget" <luc.maranget@inria.fr>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
"Akira Yokosawa" <akiyks@gmail.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] MIPS: implement smp_cond_load_acquire() for Loongson-3
Date: Wed, 20 Jun 2018 11:22:26 +0200 [thread overview]
Message-ID: <20180620092226.GM2476@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180620081715.GA27776@arm.com>
On Wed, Jun 20, 2018 at 09:17:16AM +0100, Will Deacon wrote:
> On Wed, Jun 20, 2018 at 11:31:55AM +0800, 陈华才 wrote:
> > Loongson-3's Store Fill Buffer is nearly the same as your "Store Buffer",
> > and it increases the memory ordering weakness. So, smp_cond_load_acquire()
> > only need a __smp_mb() before the loop, not after every READ_ONCE(). In
> > other word, the following code is just OK:
> >
> > #define smp_cond_load_acquire(ptr, cond_expr) \
> > ({ \
> > typeof(ptr) __PTR = (ptr); \
> > typeof(*ptr) VAL; \
> > __smp_mb(); \
> > for (;;) { \
> > VAL = READ_ONCE(*__PTR); \
> > if (cond_expr) \
> > break; \
> > cpu_relax(); \
> > } \
> > __smp_mb(); \
> > VAL; \
> > })
> >
> > the __smp_mb() before loop is used to avoid "reads prioritised over
> > writes", which is caused by SFB's weak ordering and similar to ARM11MPCore
> > (mentioned by Will Deacon).
>
> Sure, but smp_cond_load_acquire() isn't the only place you'll see this sort
> of pattern in the kernel. In other places, the only existing arch hook is
> cpu_relax(), so unless you want to audit all loops and add a special
> MIPs-specific smp_mb() to those that are affected, I think your only option
> is to stick it in cpu_relax().
>
> I assume you don't have a control register that can disable this
> prioritisation in the SFB?
Right, I think we also want to clarify that this 'feature' is not
supported by the Linux kernel in general and LKMM in specific.
It really is a CPU bug. And the cpu_relax() change is a best effort
work-around.
next prev parent reply other threads:[~2018-06-20 9:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1529042858-9483-1-git-send-email-chenhc@lemote.com>
2018-06-18 18:51 ` Paul Burton
2018-06-19 6:40 ` 陈华才
2018-06-19 7:22 ` Peter Zijlstra
2018-06-20 3:31 ` 陈华才
2018-06-20 8:17 ` Will Deacon
2018-06-20 9:22 ` Peter Zijlstra [this message]
2018-06-19 7:17 ` Peter Zijlstra
2018-06-19 8:52 ` Will Deacon
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=20180620092226.GM2476@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akiyks@gmail.com \
--cc=andrea.parri@amarulasolutions.com \
--cc=boqun.feng@gmail.com \
--cc=chenhc@lemote.com \
--cc=chenhuacai@gmail.com \
--cc=dhowells@redhat.com \
--cc=j.alglave@ucl.ac.uk \
--cc=james.hogan@mips.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=luc.maranget@inria.fr \
--cc=npiggin@gmail.com \
--cc=paul.burton@mips.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=ralf@linux-mips.org \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=will.deacon@arm.com \
--cc=wuzhangjin@gmail.com \
--cc=zhangfx@lemote.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
all inboxes | Powered by JetHome®