[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1402335482.6071.36.camel@j-VirtualBox>
Date: Mon, 09 Jun 2014 10:38:02 -0700
From: Jason Low <jason.low2@...com>
To: Davidlohr Bueso <davidlohr@...com>
Cc: Peter Zijlstra <peterz@...radead.org>, mingo@...nel.org,
tglx@...utronix.de, akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org, paulmck@...ux.vnet.ibm.com,
tim.c.chen@...ux.intel.com, hpa@...or.com, Waiman.Long@...com,
aswin@...com, scott.norton@...com, chegu_vinod@...com
Subject: Re: [RFC PATCH 1/3] locking/mutex: Try to acquire mutex only if it
is unlocked
On Wed, 2014-06-04 at 13:58 -0700, Davidlohr Bueso wrote:
> On Wed, 2014-06-04 at 13:57 -0700, Davidlohr Bueso wrote:
> > In addition, how about the following helpers instead:
> > - mutex_is_unlocked() : count > 0
> > - mutex_has_waiters() : count < 0, or list_empty(->wait_list)
> ^ err, that's !list_empty()
Between checking for (count < 0) or checking for !list_empty(wait_list)
for waiters:
Now that I think about it, I would expect a mutex_has_waiters() function
to return !list_empty(wait_list) as that really tells whether or not
there are waiters. For example, in highly contended cases, there can
still be waiters on the mutex if count is 1.
Likewise, in places where we currently use "MUTEX_SHOW_NO_WAITER", we
need to check for (count < 0) to ensure lock->count is a negative value
before the thread sleeps on the mutex.
One option would be to still remove MUTEX_SHOW_NO_WAITER(), directly use
atomic_read() in place of the macro, and just comment on why we have an
extra atomic_read() that may "appear redundant". Another option could be
to provide a function that checks for "potential waiters" on the mutex.
Any thoughts?
--
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