From: Tim Chen <tim.c.chen@linux.intel.com>
To: Michel Lespinasse <walken@google.com>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Waiman Long <waiman.long@hp.com>, Arnd Bergmann <arnd@arndb.de>,
Rik van Riel <riel@redhat.com>,
Aswin Chandramouleeswaran <aswin@hp.com>,
Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>,
"Figo. zhang" <figo1802@gmail.com>,
linux-arch@vger.kernel.org, Andi Kleen <andi@firstfloor.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
George Spelvin <linux@horizon.com>, Ingo Molnar <mingo@elte.hu>,
Peter Hurley <peter@hurleysoftware.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm <linux-mm@kvack.org>,
Andrea Arcangeli <aarcange@redhat.com>,
Alex Shi <alex.shi@linaro.org>,
LKML <linux-kernel@vger.kernel.org>,
Scott J Norton <scott.norton@hp.com>,
Thomas Gleixner <tglx@linutronix.de>,
Dave Hansen <dave.hansen@intel.com>,
Matthew R Wilcox <matthew.r.wilcox@intel.com>,
Will Deacon <will.deacon@arm.com>,
Davidlohr Bueso <davidlohr.bueso@hp.com>
Subject: Re: [PATCH v3 3/5] MCS Lock: Barrier corrections
Date: Thu, 07 Nov 2013 13:15:51 -0800 [thread overview]
Message-ID: <1383858951.11046.399.camel@schen9-DESK> (raw)
In-Reply-To: <CANN689FqUSnr=Prum0Kt6+0gr9dWKD8GT9Gbrtiyyg+PTyFkyA@mail.gmail.com>
On Thu, 2013-11-07 at 11:59 -0800, Michel Lespinasse wrote:
> On Thu, Nov 7, 2013 at 6:31 AM, Paul E. McKenney
> <paulmck@linux.vnet.ibm.com> wrote:
> > On Thu, Nov 07, 2013 at 04:50:23AM -0800, Michel Lespinasse wrote:
> >> On Thu, Nov 7, 2013 at 4:06 AM, Linus Torvalds
> >> <torvalds@linux-foundation.org> wrote:
> >> >
> >> > On Nov 7, 2013 6:55 PM, "Michel Lespinasse" <walken@google.com> wrote:
> >> >>
> >> >> Rather than writing arch-specific locking code, would you agree to
> >> >> introduce acquire and release memory operations ?
> >> >
> >> > Yes, that's probably the right thing to do. What ops do we need? Store with
> >> > release, cmpxchg and load with acquire? Anything else?
> >>
> >> Depends on what lock types we want to implement on top; for MCS we would need:
> >> - xchg acquire (common case) and load acquire (for spinning on our
> >> locker's wait word)
> >> - cmpxchg release (when there is no next locker) and store release
> >> (when writing to the next locker's wait word)
> >>
> >> One downside of the proposal is that using a load acquire for spinning
> >> puts the memory barrier within the spin loop. So this model is very
> >> intuitive and does not add unnecessary barriers on x86, but it my
> >> place the barriers in a suboptimal place for architectures that need
> >> them.
> >
> > OK, I will bite... Why is a barrier in the spinloop suboptimal?
>
> It's probably not a big deal - all I meant to say is that if you were
> manually placing barriers, you would probably put one after the loop
> instead. I don't deal much with architectures where such barriers are
> needed, so I don't know for sure if the difference means much.
We could do a load acquire at the end of the
spin loop in the lock function and not in the spin loop itself if cost
of barrier within spin loop is a concern.
Michel, are you planning to do an implementation of
load-acquire/store-release functions of various architectures?
Or is the approach of arch specific memory barrier for MCS
an acceptable one before load-acquire and store-release
are available? Are there any technical issues remaining with
the patchset after including including Waiman's arch specific barrier?
Tim
>
> > Can't say that I have tried measuring it, but the barrier should not
> > normally result in interconnect traffic. Given that the barrier is
> > required anyway, it should not affect lock-acquisition latency.
>
> Agree
>
> > So what am I missing here?
>
> I think you read my second email as me trying to shoot down a proposal
> - I wasn't, as I really like the acquire/release model and find it
> easy to program with, which is why I'm proposing it in the first
> place. I just wanted to be upfront about all potential downsides, so
> we can consider them and see if they are significant - I don't think
> they are, but I'm not the best person to judge that as I mostly just
> deal with x86 stuff.
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2013-11-07 21:16 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1383771175.git.tim.c.chen@linux.intel.com>
2013-11-06 21:36 ` [PATCH v3 0/4] MCS Lock: MCS lock code cleanup and optimizations Tim Chen
2013-11-06 21:41 ` Davidlohr Bueso
2013-11-06 23:55 ` Tim Chen
2013-11-06 21:42 ` H. Peter Anvin
2013-11-06 21:59 ` Michel Lespinasse
2013-11-06 21:37 ` [PATCH v3 1/5] MCS Lock: Restructure the MCS lock defines and locking code into its own file Tim Chen
2013-11-06 21:37 ` [PATCH v3 2/5] MCS Lock: optimizations and extra comments Tim Chen
2013-11-06 21:47 ` Tim Chen
2013-11-06 21:37 ` [PATCH v3 3/5] MCS Lock: Barrier corrections Tim Chen
2013-11-07 1:39 ` Linus Torvalds
2013-11-07 4:29 ` Waiman Long
2013-11-07 8:13 ` Ingo Molnar
2013-11-07 8:22 ` Linus Torvalds
2013-11-07 8:25 ` Ingo Molnar
2013-11-07 9:55 ` Michel Lespinasse
2013-11-07 12:06 ` Linus Torvalds
2013-11-07 12:50 ` Michel Lespinasse
2013-11-07 14:31 ` Paul E. McKenney
2013-11-07 19:59 ` Michel Lespinasse
2013-11-07 21:15 ` Tim Chen [this message]
2013-11-07 22:21 ` Peter Zijlstra
2013-11-07 22:43 ` Michel Lespinasse
2013-11-08 1:16 ` Tim Chen
2013-11-06 21:37 ` [PATCH v3 4/5] MCS Lock: Make mcs_spinlock.h includable in other files Tim Chen
2013-11-06 21:41 ` Tim Chen
2013-11-06 21:37 ` [PATCH v3 5/5] MCS Lock: Allow architecture specific memory barrier in lock/unlock Tim Chen
2013-11-06 21:42 ` Tim Chen
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=1383858951.11046.399.camel@schen9-DESK \
--to=tim.c.chen@linux.intel.com \
--cc=a.p.zijlstra@chello.nl \
--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=figo1802@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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=scott.norton@hp.com \
--cc=tglx@linutronix.de \
--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