Re: [PATCH v3 4/4] futex: Avoid taking hb lock if nothing to wakeup

From: Davidlohr Bueso
Date: Thu Dec 19 2013 - 18:42:55 EST


On Thu, 2013-12-19 at 15:14 -0800, Linus Torvalds wrote:
> On Thu, Dec 19, 2013 at 10:45 AM, Davidlohr Bueso <davidlohr@xxxxxx> wrote:
> >
> > - increment the counter at queue_lock() as we always end up calling
> > queue_me() which adds the element to the list. Upon any error,
> > queue_unlock() is called for housekeeping, for which we decrement
> > to mach the increment done in queue_lock().
> >
> > - decrement the counter at __unqueue_me() to reflect when an element is
> > removed from the queue for wakeup related purposes.
>
> I still hate this whole separate counter thing. It seems really annoying.
>
> If re-ordering things didn't work out, then why can't just the counter
> we *already* have in the spinlock itself work as the counter? Your
> counter update logic seems to basically match when you take the
> spinlock anyway.
>
> The *testing* side doesn't actually care about how many waiters there
> are, it only cares about whether there are waiters.

True.

> And it can look at
> the wait-list for that - but you want to close the race between the
> entry actually getting added to the list using this counter. But the
> place you increment the new counter is the same place as you take the
> spinlock, which does that ticket increment. No?

I don't think so. If we rely on this, then we could end up missing
to-be-queued tasks that are in the process of acquiring the lock, so
waiters could sleep forever. So we need a way of acknowledging that a
task is in the process of waiting when concurrently doing wakeups.

Thanks,
Davidlohr

--
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/