public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Peter Hurley <peter@hurleysoftware.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org, Will Deacon <will.deacon@arm.com>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-arch@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Waiman Long <waiman.long@hp.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Alex Shi <alex.shi@linaro.org>, Andi Kleen <andi@firstfloor.org>,
	Michel Lespinasse <walken@google.com>,
	Davidlohr Bueso <davidlohr.bueso@hp.com>,
	Matthew R Wilcox <matthew.r.wilcox@intel.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Rik van Riel <riel@redhat.com>,
	Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>,
	George Spelvin <linux@horizon.com>,
	"H. Peter Anvin" <hpa@zytor.com>, Arnd Bergmann <arnd@arndb.de>,
	Aswin Chandramouleeswaran <aswin@hp.com>,
	Sco
Subject: Re: [RFC] Control dependencies
Date: Mon, 25 Nov 2013 10:42:23 +0100	[thread overview]
Message-ID: <20131125094223.GV10022@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <528F9B8D.2090806@hurleysoftware.com>

On Fri, Nov 22, 2013 at 12:59:41PM -0500, Peter Hurley wrote:
> On 11/22/2013 08:46 AM, Peter Zijlstra wrote:
> >How about the below version?
> >
> >---
> >--- a/kernel/events/ring_buffer.c
> >+++ b/kernel/events/ring_buffer.c
> >@@ -61,19 +61,20 @@ static void perf_output_put_handle(struc
> >  	 *
> >  	 *   kernel				user
> >  	 *
> >-	 *   READ ->data_tail			READ ->data_head
> >-	 *   smp_mb()	(A)			smp_rmb()	(C)
> >-	 *   WRITE $data			READ $data
> >-	 *   smp_wmb()	(B)			smp_mb()	(D)
> >-	 *   STORE ->data_head			WRITE ->data_tail
> >+	 *   if (LOAD ->data_tail) {		LOAD ->data_head
> >+	 *			(A)		smp_rmb()	(C)
> >+	 *	STORE $data			LOAD $data
> >+	 *	smp_wmb()	(B)		smp_mb()	(D)
> >+	 *	STORE ->data_head		STORE ->data_tail
> 
> 
> I wasn't subscribed to linux-arch so missed the smp_store_release()
> outcome, if there was one.
> 
> Are (B) and (D) still slated for changing to STORE.rel semantics,
> aka smp_store_release()?

The earlier proposal would have A and C be smp_load_acquire() and B and
D be smp_store_release().

> I realize that, for the perf ring buffer, (D) is in userspace but
> I'm also interested in non-perf situations where (D) would be in the
> kernel.

So we're still debating the exact semantics of smp_store_release(), it
now looks like it needs a heavier memory barrier than previously
thought. In which case using it wouldn't make sense for me anymore.

Note that C and D are in userspace and not in any hot path (usually)
They're only issued once to read an entire buffer backlog at once, so I
don't really care about them all that much.

A and B otoh are in kernel space and are issued for every single event
written, so I'm interested to get them as cheaply as possible.

With this proposed patch, we remove a full barrier, with the earlier
smp_load_acquire() / smp_store_release() patches we would only
downgrade the full barrier to an acquire barrier, which is still more
than no barrier at all.

And now it looks like the smp_store_release() would actually upgrade the
wmb to a full barrier on some systems at least.

WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <peterz@infradead.org>
To: Peter Hurley <peter@hurleysoftware.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org, Will Deacon <will.deacon@arm.com>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-arch@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Waiman Long <waiman.long@hp.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Alex Shi <alex.shi@linaro.org>, Andi Kleen <andi@firstfloor.org>,
	Michel Lespinasse <walken@google.com>,
	Davidlohr Bueso <davidlohr.bueso@hp.com>,
	Matthew R Wilcox <matthew.r.wilcox@intel.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Rik van Riel <riel@redhat.com>,
	Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>,
	George Spelvin <linux@horizon.com>,
	"H. Peter Anvin" <hpa@zytor.com>, Arnd Bergmann <arnd@arndb.de>,
	Aswin Chandramouleeswaran <aswin@hp.com>,
	Scott J Norton <scott.norton@hp.com>,
	"Figo.zhang" <figo1802@gmail.com>
Subject: Re: [RFC] Control dependencies
Date: Mon, 25 Nov 2013 10:42:23 +0100	[thread overview]
Message-ID: <20131125094223.GV10022@twins.programming.kicks-ass.net> (raw)
Message-ID: <20131125094223.12P2MLGeSHF601ZQzdQSpW_gpYNTAniNURDmrWCN5ao@z> (raw)
In-Reply-To: <528F9B8D.2090806@hurleysoftware.com>

On Fri, Nov 22, 2013 at 12:59:41PM -0500, Peter Hurley wrote:
> On 11/22/2013 08:46 AM, Peter Zijlstra wrote:
> >How about the below version?
> >
> >---
> >--- a/kernel/events/ring_buffer.c
> >+++ b/kernel/events/ring_buffer.c
> >@@ -61,19 +61,20 @@ static void perf_output_put_handle(struc
> >  	 *
> >  	 *   kernel				user
> >  	 *
> >-	 *   READ ->data_tail			READ ->data_head
> >-	 *   smp_mb()	(A)			smp_rmb()	(C)
> >-	 *   WRITE $data			READ $data
> >-	 *   smp_wmb()	(B)			smp_mb()	(D)
> >-	 *   STORE ->data_head			WRITE ->data_tail
> >+	 *   if (LOAD ->data_tail) {		LOAD ->data_head
> >+	 *			(A)		smp_rmb()	(C)
> >+	 *	STORE $data			LOAD $data
> >+	 *	smp_wmb()	(B)		smp_mb()	(D)
> >+	 *	STORE ->data_head		STORE ->data_tail
> 
> 
> I wasn't subscribed to linux-arch so missed the smp_store_release()
> outcome, if there was one.
> 
> Are (B) and (D) still slated for changing to STORE.rel semantics,
> aka smp_store_release()?

The earlier proposal would have A and C be smp_load_acquire() and B and
D be smp_store_release().

> I realize that, for the perf ring buffer, (D) is in userspace but
> I'm also interested in non-perf situations where (D) would be in the
> kernel.

So we're still debating the exact semantics of smp_store_release(), it
now looks like it needs a heavier memory barrier than previously
thought. In which case using it wouldn't make sense for me anymore.

Note that C and D are in userspace and not in any hot path (usually)
They're only issued once to read an entire buffer backlog at once, so I
don't really care about them all that much.

A and B otoh are in kernel space and are issued for every single event
written, so I'm interested to get them as cheaply as possible.

With this proposed patch, we remove a full barrier, with the earlier
smp_load_acquire() / smp_store_release() patches we would only
downgrade the full barrier to an acquire barrier, which is still more
than no barrier at all.

And now it looks like the smp_store_release() would actually upgrade the
wmb to a full barrier on some systems at least.




  parent reply	other threads:[~2013-11-25  9:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-21 16:17 [RFC] Control dependencies Peter Zijlstra
2013-11-21 16:17 ` Peter Zijlstra
2013-11-21 18:02 ` Paul E. McKenney
2013-11-21 18:02   ` Paul E. McKenney
2013-11-21 19:28   ` Paul E. McKenney
2013-11-21 19:28     ` Paul E. McKenney
2013-11-22 13:46   ` Peter Zijlstra
2013-11-22 13:46     ` Peter Zijlstra
2013-11-22 17:59     ` Peter Hurley
2013-11-22 17:59       ` Peter Hurley
2013-11-25  9:42       ` Peter Zijlstra [this message]
2013-11-25  9:42         ` Peter Zijlstra
2013-11-22 18:16     ` Paul E. McKenney
2013-11-22 18:16       ` Paul E. McKenney

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=20131125094223.GV10022@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.shi@linaro.org \
    --cc=andi@firstfloor.org \
    --cc=arnd@arndb.de \
    --cc=aswin@hp.com \
    --cc=dave.hansen@intel.com \
    --cc=davidlohr.bueso@hp.com \
    --cc=hpa@zytor.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@horizon.com \
    --cc=matthew.r.wilcox@intel.com \
    --cc=mingo@elte.hu \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peter@hurleysoftware.com \
    --cc=raghavendra.kt@linux.vnet.ibm.com \
    --cc=riel@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tim.c.chen@linux.intel.com \
    --cc=torvalds@linux-foundation.org \
    --cc=waiman.long@hp.com \
    --cc=walken@google.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox