Re: [PATCH -tip/master v2] locking/mutex: Refactor optimistic spinning code

From: Davidlohr Bueso
Date: Tue Jul 29 2014 - 00:32:12 EST


On Mon, 2014-07-28 at 20:41 -0700, Jason Low wrote:
> On Mon, 2014-07-28 at 19:55 -0700, Davidlohr Bueso wrote:
> > +static bool mutex_optimistic_spin(struct mutex *lock,
> > + struct ww_acquire_ctx *ww_ctx, const bool use_ww_ctx)
> > +{
> > + struct task_struct *task = current;
> > +
> > + if (!mutex_can_spin_on_owner(lock))
> > + return false;
> > +
> > + if (!osq_lock(&lock->osq))
> > + return false;
>
> In the !osq_lock() case, we could exit the cancellable MCS spinlock due
> to need_resched(). However, this would return from the function rather
> than doing the need_resched() check below. Perhaps we can add something
> like "goto out" which goes to the below check?

Ah, yes. This used to be a goto slowpath. It would have served the other
way around, if having the need_resched() check outside of
mutex_optimistic_spin().

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/