[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1425922969.2475.394.camel@j-VirtualBox>
Date: Mon, 09 Mar 2015 10:42:49 -0700
From: Jason Low <jason.low2@...com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Ingo Molnar <mingo@...nel.org>,
Davidlohr Bueso <dave@...olabs.net>,
Tim Chen <tim.c.chen@...ux.intel.com>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Michel Lespinasse <walken@...gle.com>,
Sasha Levin <sasha.levin@...cle.com>,
LKML <linux-kernel@...r.kernel.org>,
Dave Jones <davej@...emonkey.org.uk>,
Ming Lei <ming.lei@...onical.com>, jason.low2@...com
Subject: Re: [PATCH] locking/rwsem: Fix lock optimistic spinning when owner
is not running
On Sat, 2015-03-07 at 10:21 +0100, Peter Zijlstra wrote:
> On Fri, Mar 06, 2015 at 11:45:31PM -0800, Jason Low wrote:
> > static noinline
> > bool rwsem_spin_on_owner(struct rw_semaphore *sem, struct task_struct *owner)
> > {
> > long count;
> >
> > rcu_read_lock();
> > + while (sem->owner == owner) {
> > + /*
> > + * Ensure we emit the owner->on_cpu, dereference _after_
> > + * checking sem->owner still matches owner, if that fails,
> > + * owner might point to free()d memory, if it still matches,
> > + * the rcu_read_lock() ensures the memory stays valid.
> > + */
> > + barrier();
> > +
> > + /* abort spinning when need_resched or owner is not running */
> > + if (!owner->on_cpu || need_resched()) {
> > rcu_read_unlock();
> > return false;
> > }
>
> Thanks, looks good; do we want to change the mutex code (again) to more
> closely resemble this too? It still has the while (true) instead of the
> while(lock->owner != owner).
Yeah, I wondered about the same thing, though I wasn't sure if you
wanted an additional patch just for that change.
Guess you answered it for me :)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists