Re: git: 1f4b0ea4f3eb - main - kqueue: Add a helper macro for sleeping on in-flux knotes

From: Mark Johnston <markj_at_freebsd.org>
Date: Wed, 29 Jul 2026 12:46:57 UTC
On Wed, Jul 29, 2026 at 04:05:43AM -0700, Kevin Bowling wrote:
> Hi Mark,
> 
> This is resulting in relatively easy to trigger panic with 'syncthing'
> running under INVARIANTS:
> panic: kqueue_scan: knote 0xfffffe018aeab930 not on kqueue 0xfffff80010aa2400
> 
> The panic occurs at the new KASSERT in KQ_FLUX_SLEEP_WMESG(), called
> from kqueue_scan() line 2197. Two Syncthing threads were concurrently
> scanning the same kqueue.
> 
> kgdb showed that the knote named in the panic was exactly the other
> scanning thread’s local marker:
> 
> &marker = 0xfffffe018aeab930
> marker.kn_status = KN_MARKER
> marker.kn_kq = NULL
> kq = 0xfffff80010aa2400

I just committed a change which should address this:
https://cgit.freebsd.org/src/commit/?id=9a9349ea1da2d80e979fa87b430551d8f6dac7f4