Re: [PATCH 0/4] locks: avoid thundering-herd wake-ups

From: J. Bruce Fields
Date: Thu Aug 09 2018 - 21:05:27 EST


On Fri, Aug 10, 2018 at 09:56:07AM +1000, NeilBrown wrote:
> On Thu, Aug 09 2018, J. Bruce Fields wrote:
> > If we only cared about the former, and only in simple cases, we could
> > walk the entire list and skip waking up only the locks that conflict
> > with the first one we wake. We wouldn't need the tree.
>
> Yes, we could do that. It would probably make the code simpler.
> It would mean doing the conflicts() tests when performing wake-up rather
> than prior to going to sleep. In general it would mean doing the tests
> more often, as the tree effectively records the results of the previous
> time conflicts() was run.
> You might get a quadratic effect though ... wouldn't you want to
> skip anything that conflicts with anything that has been woken?

I was thinking it'd be simplest just to check for conflict with the
first thing that you decide to wake. That might be all that's necessary
for typical cases.

If you wanted to keep a running list of the locks you've chosen to wake
so far and check each one against that list, I guess you could.

> If the tree-management code turns out to be too complex, it would
> certainly be an option. I think the tree approach should result in less
> total CPU usage..

Have we ever looked into the CPU usage of deadlock detection? Might
experiment with turning that off. But I may be biased by my white-hot
hatred of it.

--b.