On 23/10/17(Mon) 21:58, Alexander Bluhm wrote:
> On Wed, Oct 18, 2017 at 11:22:01AM +0200, Martin Pieuchot wrote:
> > Diff below is the last version of my kqueue diff to allow grabbing the
> > solock() and possibly sleeping, inside kqueue_scan().
> 
> I wonder why you don't call knote_release() when calling knote_drop().
> Another thread could sleep in knote_acquire() and never get a
> wakeup.

This is not a problem.  The way knote_acquire() is designed is to sleep
for a small amount of time, 1 * hz for the moment.  Here's what the
comment, coming from DragonflyBSD says:

  * If we cannot acquire the knote we sleep and return 0.  The knote
  * may be stale on return in this case and the caller must restart
  * whatever loop they are in.


>          I think there should be a call to knote_release() from
> knote_drop() just before freeing it.  Then other threads wake up
> and can continue.

This is an optimization.  You're saying that "waiting" for 1 * hz is
too long.  I doubt it makes any difference in practise. First because
it is a small interval.  But also because the top part of the kernel
is still serialized by the KERNEL_LOCK().  So if one thread wakes up
its sibling, the sibling will have to spin until it exits the kernel.

> Why is knote_release() not a void function?

Because it's a stripped down version of DragonflyBSD's one.  And I think
we should continue to sync with their work.  But I can change that for
now.

> I did run all regress tests with your diff, everything passes.
> Btw, I have added a link to my regress page where you can see the
> diffs in /usr/src when I did not run the tests with a snapshot.
> http://bluhm.genua.de/regress/results/regress.html

Reply via email to