From: David Howells <dhowells@redhat.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: dhowells@redhat.com, Peter Zijlstra <peterz@infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-arch <linux-arch@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: cmpxchg and x86 flags output
Date: Tue, 21 Jun 2016 10:06:20 +0100 [thread overview]
Message-ID: <4467.1466499980@warthog.procyon.org.uk> (raw)
In-Reply-To: <5e5b99d7-c739-9743-b3e0-fbe0636d6dee@zytor.com>
H. Peter Anvin <hpa@zytor.com> wrote:
> Well, that sounds promising. I wonder how David's model, using
> intrinsics (do we have enough intrinsics to actually be able to do this
> "correctly"?), compare to using the flags output from assembly.
There is an advantage to using the intriniscs on arches with explicit
barriers. On powerpc64, for example, the compiler can move the release memory
barrier earlier to push register-only instructions between the barrier and the
lwarx. This would allow the memory barrier to be executed concurrently with
those instructions.
The compiler could also move the acquire memory barrier later, pulling
register-only instructions between the stwcx and that barrier, though I don't
see any advantage to doing so.
Whereas if the release barrier is in the same asm block as the lwarx, the
compiler cannot do anything with it.
Another advantage is that the compiler can switch between instruction variants
automatically, allowing us to get rid of the size-based switch statements for
things like cmpxchg().
However, there's probably not a great deal of difference to be had if the
inline asm codes the appropriate instruction in each case for something like
x86*. The emitted code ought to look the same. The second biggest win for
the intriniscs, I think, is the ability to ask the CMPXCHG instruction whether
it actually did anything rather than comparing the result. I added two
variants, one that only returned the yes/no and one that passed back the value
as well as the yes/no.
David
next prev parent reply other threads:[~2016-06-21 9:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-14 23:53 cmpxchg and x86 flags output H. Peter Anvin
2016-06-15 8:50 ` Peter Zijlstra
2016-06-16 22:21 ` H. Peter Anvin
2016-06-21 9:06 ` David Howells [this message]
2016-06-21 17:00 ` H. Peter Anvin
2016-06-22 16:11 ` David Howells
2016-06-22 16:36 ` H. Peter Anvin
2016-06-22 17:11 ` Linus Torvalds
2016-06-22 17:49 ` H. Peter Anvin
2016-06-21 17:24 ` H. Peter Anvin
2016-06-22 0:09 ` H. Peter Anvin
2016-06-22 16:14 ` David Howells
2016-08-19 17:22 ` H. Peter Anvin
2016-08-22 15:13 ` David Howells
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=4467.1466499980@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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