Page MenuHomeFreeBSD

kqueue: slightly clarify the flow in knlist_cleardel()
ClosedPublic

Authored by kevans on Apr 2 2026, 6:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 18, 1:19 AM
Unknown Object (File)
Mon, May 18, 1:13 AM
Unknown Object (File)
Sun, May 17, 5:54 PM
Unknown Object (File)
Tue, May 12, 10:58 AM
Unknown Object (File)
Tue, May 12, 10:57 AM
Unknown Object (File)
Tue, May 12, 10:57 AM
Unknown Object (File)
Sun, May 10, 2:16 PM
Unknown Object (File)
Sun, May 10, 2:11 PM
Subscribers

Details

Summary

This is purely a cosmetic change to make it a little easier on the eyes,
rather than jumping back to the else branch up top. Re-flow it to use
another loop on the outside and just inline the re-lock before we repeat
after awaking from fluxwait.

The !killkn path should maybe issue a wakeup if there's a thread in
KQ_SLEEP so that userland can observe the EOF, but this isn't a
practical problem today: pretty much every case of knlist_clear is tied
to a file descriptor and called in the close(2) path. As a consequence,
potentially affected knotes are almost always destroyed before we even
get to knlist_clear().

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kevans requested review of this revision.Apr 2 2026, 6:34 PM
sys/kern/kern_event.c
2798–2822

Could this be just for (;;) ?

sys/kern/kern_event.c
2798–2822

I was mainly trying to avoid bothering with SLIST_FOREACH_SAFE on the last iteration if it's empty after we re-enter from fluxwait, but I don't feel that strongly about it- this isn't exactly a hot path.

Use an infinite loop instead, it's a little cleaner feeling.

This revision is now accepted and ready to land.Apr 3 2026, 4:57 AM