[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160509071220.GB3430@twins.programming.kicks-ass.net>
Date: Mon, 9 May 2016 09:12:20 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Peter Hurley <peter@...leysoftware.com>
Cc: Davidlohr Bueso <dave@...olabs.net>, mingo@...nel.org,
tglx@...utronix.de, Waiman.Long@....com, jason.low2@...com,
linux-kernel@...r.kernel.org, Davidlohr Bueso <dbueso@...e.de>
Subject: Re: [PATCH 1/4] locking/rwsem: Avoid stale ->count for
rwsem_down_write_failed()
On Sun, May 08, 2016 at 10:36:21PM -0700, Peter Hurley wrote:
> On 05/08/2016 09:56 PM, Davidlohr Bueso wrote:
> > The field is obviously updated w.o the lock and needs a READ_ONCE
> > while waiting for lock holder(s) to go away, just like we do with
> > all other ->count accesses.
>
> This isn't actually fixing a bug because it's passed through
> several full barriers which will force reloading from sem->count.
>
> I think the patch is ok if you want it just for consistency anyway,
> but please change $subject and changelog.
Agreed, and note that the READ_ONCE does prohibit load-tearing, while
the current code does not.
So in that respect the patched code is more strict. But yes, the current
code does not allow using a stale value of sem->count() because, as
PeterH notes, we've just passed through at least the full memory barrier
implied by set_current_state().
Powered by blists - more mailing lists