From: Christian Borntraeger <borntraeger@de.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: linux-arch@vger.kernel.org, linux-mips@linux-mips.org,
linux-x86_64@vger.kernel.org, linux-s390@vger.kernel.org,
Paolo Bonzini <pbonzini@redhat.com>,
paulmck@linux.vnet.ibm.com, mingo@kernel.org,
torvalds@linux-foundation.org,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
David Howells <dhowells@redhat.com>,
Russell King <linux@arm.linux.org.uk>
Subject: Re: [PATCHv2 04/10] x86/spinlock: Replace ACCESS_ONCE with READ_ONCE/ASSIGN_ONCE
Date: Tue, 25 Nov 2014 21:29:01 +0100 [thread overview]
Message-ID: <5474E68D.4010707@de.ibm.com> (raw)
In-Reply-To: <1416919117-50652-5-git-send-email-borntraeger@de.ibm.com>
Am 25.11.2014 um 13:38 schrieb Christian Borntraeger:
> ACCESS_ONCE does not work reliably on non-scalar types. For
> example gcc 4.6 and 4.7 might remove the volatile tag for such
> accesses during the SRA (scalar replacement of aggregates) step
> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145)
>
> Change the spinlock code to replace ACCESS_ONCE with READ_ONCE
> and ASSIGN_ONCE.
>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
> arch/x86/include/asm/spinlock.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
> index 9295016..af6e673 100644
> --- a/arch/x86/include/asm/spinlock.h
> +++ b/arch/x86/include/asm/spinlock.h
> @@ -92,7 +92,7 @@ static __always_inline void arch_spin_lock(arch_spinlock_t *lock)
> unsigned count = SPIN_THRESHOLD;
>
> do {
> - if (ACCESS_ONCE(lock->tickets.head) == inc.tail)
> + if (ASSIGN_ONCE(inc.tail, lock->tickets.head))
As Mike pointed out: this should be
if (READ_ONCE(lock->tickets.head) == inc.tail)
of course.
next prev parent reply other threads:[~2014-11-25 20:29 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-25 12:38 [PATCHv2 00/10] ACCESS_ONCE and non-scalar accesses Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 01/10] KVM: s390: Fix ipte locking Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 02/10] kernel: Provide READ_ONCE and ASSIGN_ONCE Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 15:59 ` Paul E. McKenney
2014-11-25 17:28 ` Linus Torvalds
2014-11-25 17:50 ` Paul E. McKenney
2014-11-25 19:35 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 03/10] mm: replace ACCESS_ONCE with READ_ONCE Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 04/10] x86/spinlock: Replace ACCESS_ONCE with READ_ONCE/ASSIGN_ONCE Christian Borntraeger
2014-11-25 20:29 ` Christian Borntraeger [this message]
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 05/10] x86: Replace ACCESS_ONCE in gup with READ_ONCE Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 06/10] mips: " Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 07/10] arm64: Replace ACCESS_ONCE for spinlock code " Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 08/10] arm: " Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 09/10] tighten rules for ACCESS ONCE Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-25 12:38 ` [PATCHv2 10/10] KVM: s390: change ipte lock from barrier to READ_ONCE Christian Borntraeger
2014-11-25 12:38 ` Christian Borntraeger
2014-11-26 19:20 ` [PATCHv3 00/10] ACCESS_ONCE and non-scalar accesses Christian Borntraeger
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=5474E68D.4010707@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=alexei.starovoitov@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=dhowells@redhat.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-x86_64@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=torvalds@linux-foundation.org \
--cc=will.deacon@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.