My worry is that I did something wrong in the slowpath, and that there is
some thundering-herd-wakeup kind of thing that makes that much slower than
it should be.
The slow path doesn't much matter from the angle of counting individual
cycles, but it still matters very much from a bigger picture. Does it have
bad behavior where we wake up a thousand readers, but then a writer gets
to come in first and all the readers have to go to sleep again?
That's one thing I tried to avoid in the second version (the "Another
approch" commit) where a read-wakeup actually moves the readers from the
pending count to the final count - both to get more fairness (which can be
_bad_ for performance), but also because I think it can avoid pathological
cases (reader starvation and unnecessary futex wakeup).
Linus
--