public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Vineet Gupta <Vineet.Gupta1@synopsys.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Michel Lespinasse <walken@google.com>,
	"arc-linux-dev@synopsys.com" <arc-linux-dev@synopsys.com>,
	lkml <linux-kernel@vger.kernel.org>,
	David Hildenbrand <dahi@linux.vnet.ibm.com>,
	"ralf@linux-mips.org" <ralf@linux-mips.org>
Subject: Re: [PATCH 1/4] ARC: add barriers to futex code
Date: Thu, 6 Aug 2015 15:11:42 +0100	[thread overview]
Message-ID: <20150806141142.GE25483@arm.com> (raw)
In-Reply-To: <20150806134826.GF25159@twins.programming.kicks-ass.net>

On Thu, Aug 06, 2015 at 02:48:26PM +0100, Peter Zijlstra wrote:
> On Thu, Aug 06, 2015 at 06:05:20PM +0530, Vineet Gupta wrote:
> > The atomic ops on futex need to provide the full barrier just like
> > regular atomics in kernel.
> > 
> > Also remove pagefault_enable/disable in futex_atomic_cmpxchg_inatomic()
> > as core code already does that
> 
> Urgh, and of course tglx just left for holidays :-)

Damn, he's really missing out on this!

> > +++ b/arch/arc/include/asm/futex.h
> > @@ -20,6 +20,7 @@
> >  
> >  #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg)\
> >  							\
> > +	smp_mb();					\
> >  	__asm__ __volatile__(				\
> >  	"1:	llock	%1, [%2]		\n"	\
> >  		insn				"\n"	\
> > @@ -40,12 +41,14 @@
> >  							\
> >  	: "=&r" (ret), "=&r" (oldval)			\
> >  	: "r" (uaddr), "r" (oparg), "ir" (-EFAULT)	\
> > -	: "cc", "memory")
> > +	: "cc", "memory");				\
> > +	smp_mb();					\
> >  
> 
> 
> So:
> 
>  - alhpa: only has the first smp_mb(), suggesting RELEASE
>  - arm: only has the first smp_mb(), suggesting RELEASE
>  - arm64: has store-release + smp_mb(), suggesting full barriers

I'd be ok relaxing that to smp_mb() but I don't think I'm brave enough
to go all the way to an STLXR. You can lose SC if you combine explicit
barrier instructions with the acquire/release instructions and I dread
to think what userspace is doing...

>  - MIPS: has LLSC_MB after, suggesting ACQUIRE

Yikes, so there's a fun semantic difference there. Maybe we should go
look at glibc (which only uses one of the futex ops in pthread_cond_wait
iirc).

>  - powerpc: lwsync before, sync after, full barrier
> 
> x86 is of course boring and fully ordered
> 
> Looking at the usage site of futex_atomic_op_inuser(), that's in
> futex_wake_op() which might suggest RELEASE is indeed sufficient.
> 
> Which leaves me puzzled on MIPS, but what do I know.
> 
> At the very least this patch isn't wrong, fully ordered is sufficient.

Agreed.

Will

  reply	other threads:[~2015-08-06 14:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-06 12:35 [PATCH 0/4] ARC futex fixes Vineet Gupta
2015-08-06 12:35 ` [PATCH 1/4] ARC: add barriers to futex code Vineet Gupta
2015-08-06 13:15   ` David Hildenbrand
2015-08-06 13:28     ` Vineet Gupta
2015-08-06 13:48   ` Peter Zijlstra
2015-08-06 14:11     ` Will Deacon [this message]
2015-08-07 11:40     ` Peter Zijlstra
2015-08-06 12:35 ` [PATCH 2/4] ARC: futex cosmetics Vineet Gupta
2015-08-06 12:35 ` [PATCH 3/4] ARC: make futex_atomic_cmpxchg_inatomic() return bimodal Vineet Gupta
2015-08-06 12:35 ` [PATCH 4/4] ARC: Enable HAVE_FUTEX_CMPXCHG Vineet Gupta
2015-08-06 13:46 ` [PATCH 5/4] ARC: ensure futex ops are atomic in !LLSC config Vineet Gupta
2015-08-17  7:46 ` [PATCH 0/4] ARC futex fixes Vineet Gupta

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=20150806141142.GE25483@arm.com \
    --to=will.deacon@arm.com \
    --cc=Vineet.Gupta1@synopsys.com \
    --cc=arc-linux-dev@synopsys.com \
    --cc=dahi@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=ralf@linux-mips.org \
    --cc=tglx@linutronix.de \
    --cc=walken@google.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