From: "Michael S. Tsirkin" <mst@redhat.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
Davidlohr Bueso <dbueso@suse.de>,
Peter Zijlstra <peterz@infradead.org>,
the arch/x86 maintainers <x86@kernel.org>,
linux-kernel@vger.kernel.org,
virtualization <virtualization@lists.linux-foundation.org>,
Borislav Petkov <bp@alien8.de>,
Thomas Gleixner <tglx@linutronix.de>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH v2 0/3] x86: faster mb()+other barrier.h tweaks
Date: Wed, 27 Jan 2016 16:07:56 +0200 [thread overview]
Message-ID: <20160127120222-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <56A7E722.7030701@zytor.com>
On Tue, Jan 26, 2016 at 01:37:38PM -0800, H. Peter Anvin wrote:
> On 01/26/16 00:20, Michael S. Tsirkin wrote:
> > On Tue, Jan 12, 2016 at 02:25:24PM -0800, H. Peter Anvin wrote:
> >
> > Hi hpa,
> > Any luck getting some feedback on this one?
> >
>
> Yes. What we know so far is that *most* cases it will work, but there
> are apparently a few corner cases where MFENCE or a full-blown
> serializing instruction is necessary. We are trying to characterize
> those corner cases and see if any of them affect the kernel.
It would be very interesting to know your findings.
Going over the manual I found one such case, and then going over the
kernel code I found some questionable uses of barriers - it would be
interesting to find out what some other cases are.
So I think it's probably useful to find out the full answer, anyway.
Awaiting the answers with interest.
> Even if they are, we can probably make those barriers explicitly
> different, but we don't want to go ahead with the change until we know
> where we need to care.
>
> -hpa
Thanks!
Now that you definitely said there are corner cases, I poked some more
at the manual and found one:
CLFLUSH is only ordered by the MFENCE instruction. It is not guaranteed
to be ordered by any other fencing or serializing instructions or by
another CLFLUSH instruction. For example, software can use an MFENCE
instruction to ensure that previous stores are included in the
write-back.
There are instances of this in mwait_play_dead,
clflush_cache_range, mwait_idle_with_hints, mwait_idle ..
A comment near pcommit_sfence includes an example
flush_and_commit_buffer code which is interesting -
it assumes sfence flushes clflush.
So it appears that pcommit_sfence in that file is wrong then?
At least on processors where it falls back on clflush.
mwait_idle is the only one that calls smp_mb and not mb()
I couldn't figure out why - original patches did mb()
there.
Outside core kernel - drm_cache_flush_clflush, drm_clflush_sg,
drm_clflush_virt_range.
Then there's gru_start_instruction in drivers/misc/sgi-gru/.
But otherwise drivers/misc/sgi-gru/ calls clflush in gru_flush_cache
without calling mb() - this could be a bug.
Looking at all users, it seems that only mwait_idle calls smp_mb,
around clflush, others call mb().
So at least as a first step, maybe it makes sense to scope this down
somewhat by changing mwait_idle to call mb() and then optimizing
__smp_mb instead of mb?
I'll post v3 that does this.
--
MST
next prev parent reply other threads:[~2016-01-27 14:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-12 22:10 [PATCH v2 0/3] x86: faster mb()+other barrier.h tweaks Michael S. Tsirkin
2016-01-12 22:10 ` [PATCH v2 1/3] x86: drop mfence in favor of lock+addl Michael S. Tsirkin
2016-01-12 22:10 ` [PATCH v2 2/3] x86: drop a comment left over from X86_OOSTORE Michael S. Tsirkin
2016-01-12 22:25 ` One Thousand Gnomes
2016-01-12 22:10 ` [PATCH v2 3/3] x86: tweak the comment about use of wmb for IO Michael S. Tsirkin
2016-01-12 22:25 ` [PATCH v2 0/3] x86: faster mb()+other barrier.h tweaks H. Peter Anvin
2016-01-26 8:20 ` Michael S. Tsirkin
2016-01-26 21:37 ` H. Peter Anvin
2016-01-27 14:07 ` Michael S. Tsirkin [this message]
2016-01-27 14:14 ` Peter Zijlstra
2016-01-27 14:18 ` Michael S. Tsirkin
[not found] ` <20181011173707.26pekp65tlipvhdx@alap3.anarazel.de>
2018-10-11 18:11 ` Michael S. Tsirkin
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=20160127120222-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=bp@alien8.de \
--cc=dave@stgolabs.net \
--cc=dbueso@suse.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=x86@kernel.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).