mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Darren Hart <dvhart@linux.intel.com>
Cc: Davidlohr Bueso <davidlohr@hp.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Mike Galbraith <efault@gmx.de>,
	jeffm@suse.com, "Norton, Scott J" <scott.norton@hp.com>,
	tom.vaden@hp.com, "Chandramouleeswaran, Aswin" <aswin@hp.com>,
	Waiman Long <Waiman.Long@hp.com>, Jason Low <jason.low2@hp.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [PATCH 4/5] futex: Avoid taking hb lock if nothing to wakeup
Date: Mon, 25 Nov 2013 21:26:25 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.02.1311252106430.30673@ionos.tec.linutronix.de> (raw)
In-Reply-To: <1385409830.12342.41.camel@dvhart-mobl4.amr.corp.intel.com>

On Mon, 25 Nov 2013, Darren Hart wrote:
> On Mon, 2013-11-25 at 20:47 +0100, Thomas Gleixner wrote:
> > > which restores the ordering guarantee, which the hash bucket lock
> > > provided so far.
> > 
> > Actually that's not true by design, it just happens to work.
> > 
> > atomic_inc() on x86 is a "lock incl".
> > 
> >  The LOCK prefix just guarantees that the cache line which is affected
> >  by the INCL is locked. And it guarantees that locked operations
> >  serialize all outstanding load and store operations.
> > 
> >  But Documentation/atomic_ops.txt says about atomic_inc():
> > 
> >  "One very important aspect of these two routines is that they DO NOT
> >   require any explicit memory barriers.  They need only perform the
> >   atomic_t counter update in an SMP safe manner."
> > 
> >  So while this has a barrier on x86, it's not guaranteed.
> 
> 
> But it is guaranteed to be "in an SMP safe manner"... which I guess just
> means that two writes will not intermix bytes, but no guarantee that the
> value will be visible to other CPUs unless some kind of barrier is
> explicitly imposed.
> 
> Correct?

Yep, that's what it sayes.
 
> > So now your code melts down to:
> > 
> >  write(hb->waiters)    |    write(uaddr)
> >  mb                    |    read(hb->waiters)
> >  read(uaddr)
> > 
> > I fear you simply managed to make the window small enough that your
> > testing was not longer able expose it.
> 
> Does seem to be the case.

You must be aware, that between the the write(uaddr) and the
read(hb->waiters) is the syscall, i.e. a user/kernel space
transition.

sysenter/syscall have no documented barriers inside, but we don't know
whether the actual hw implementation provides one or if the memory ops
between modifying uaddr and reaching the read(hb->waiters) point
including the real atomic op on the waiter side are good enough to
paper over the issue.

Thanks,

	tglx




  reply	other threads:[~2013-11-25 20:26 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-23  0:56 [PATCH 0/5] futex: Wakeup optimizations Davidlohr Bueso
2013-11-23  0:56 ` [PATCH 1/5] futex: Misc cleanups Davidlohr Bueso
2013-11-23  6:52   ` Darren Hart
2013-11-23  0:56 ` [PATCH 2/5] futex: Check for pi futex_q only once Davidlohr Bueso
2013-11-23  6:33   ` Darren Hart
2013-11-24  5:19     ` Davidlohr Bueso
2013-11-23  0:56 ` [PATCH 3/5] futex: Larger hash table Davidlohr Bueso
2013-11-23  6:52   ` Darren Hart
2013-11-23  0:56 ` [PATCH 4/5] futex: Avoid taking hb lock if nothing to wakeup Davidlohr Bueso
2013-11-23  1:25   ` Linus Torvalds
2013-11-23  3:03     ` Jason Low
2013-11-23  3:19     ` Davidlohr Bueso
2013-11-23  7:23       ` Darren Hart
2013-11-23 13:16       ` Thomas Gleixner
2013-11-24  3:46         ` Linus Torvalds
2013-11-24  5:15           ` Davidlohr Bueso
2013-11-25 12:01             ` Thomas Gleixner
2013-11-25 16:23           ` Thomas Gleixner
2013-11-25 16:36             ` Peter Zijlstra
2013-11-25 17:32               ` Thomas Gleixner
2013-11-25 17:38                 ` Peter Zijlstra
2013-11-25 18:55                 ` Davidlohr Bueso
2013-11-25 19:52                   ` Thomas Gleixner
2013-11-25 19:47         ` Thomas Gleixner
2013-11-25 20:03           ` Darren Hart
2013-11-25 20:26             ` Thomas Gleixner [this message]
2013-11-26 13:53             ` Thomas Gleixner
2013-11-23  4:05     ` Waiman Long
2013-11-23  5:40   ` Darren Hart
2013-11-23  5:42     ` Hart, Darren
2013-11-23  7:20   ` Darren Hart
2013-11-23  0:56 ` [PATCH 5/5] sched,futex: Provide delayed wakeup list Davidlohr Bueso
2013-11-23 11:48   ` Peter Zijlstra
2013-11-23 12:01     ` Peter Zijlstra
2013-11-24  5:25       ` Davidlohr Bueso
2013-11-23  5:55 ` [PATCH 0/5] futex: Wakeup optimizations Darren Hart
2013-11-23  6:35   ` Mike Galbraith
2013-11-23  6:38   ` Davidlohr Bueso
2014-01-12 23:31 [PATCH v6 " Davidlohr Bueso
2014-01-12 23:31 ` [PATCH 4/5] futex: Avoid taking hb lock if nothing to wakeup Davidlohr Bueso

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=alpine.DEB.2.02.1311252106430.30673@ionos.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=Waiman.Long@hp.com \
    --cc=aswin@hp.com \
    --cc=davidlohr@hp.com \
    --cc=dvhart@linux.intel.com \
    --cc=efault@gmx.de \
    --cc=jason.low2@hp.com \
    --cc=jeffm@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=scott.norton@hp.com \
    --cc=tom.vaden@hp.com \
    --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

all inboxes | Powered by JetHome®