On Mon, Feb 15, 2016 at 06:22:14PM -0800, Jason Low wrote:
On Mon, 2016-02-15 at 18:15 -0800, Jason Low wrote:My concern was the 'pointless' divergence between the code-paths. The
On Fri, 2016-02-12 at 14:14 -0800, Davidlohr Bueso wrote:Actually, since waiters bypass the optimistic spin queue, that means the
On Fri, 12 Feb 2016, Peter Zijlstra wrote:mutex_can_spin_on_owner() returns false if the task needs to reschedule
On Fri, Feb 12, 2016 at 12:32:12PM -0500, Waiman Long wrote:afaict because mutex_can_spin_on_owner() fails immediately when the counter
static bool mutex_optimistic_spin(struct mutex *lock,Why doesn't the waiter have to check mutex_can_spin_on_owner() ?
+ struct ww_acquire_ctx *ww_ctx,
+ const bool use_ww_ctx, int waiter)
{
struct task_struct *task = current;
+ bool acquired = false;
+ if (!waiter) {
+ if (!mutex_can_spin_on_owner(lock))
+ goto done;
is -1, which is a nono for the waiters case.
or if the lock owner is not on_cpu. In either case, the task will end up
not spinning when it enters the spin loop. So it makes sense if the
waiter also checks mutex_can_spin_on_owner() so that the optimistic spin
queue overhead can be avoided in those cases.
the mutex_can_spin_on_owner() isn't really beneficial. So Waiman is
right in that it's fine to skip this in the waiter case.
less they diverge the easier it is to understand and review.
If it doesn't hurt, please keep it the same. If it does need to diverge,
include a comment on why.