FreeBSD/sys/dev/netmap/netmap_freebsd.c
/*
 * The OS_selwakeup also needs to issue a KNOTE_UNLOCKED.
 * We use a non-zero argument to distinguish the call from the one
 * in kevent_scan() which instead also needs to run netmap_poll().
 * The knote uses a global mutex for the time being. We might
 * try to reuse the one in the si, but it is not allocated
 * permanently so it might be a bit tricky.
 *
 * The *kqfilter function registers one or another f_event
 * depending on read or write mode.
 * In the call to f_event() td_fpop is NULL so any child function
 * calling devfs_get_cdevpriv() would fail - and we need it in
 * netmap_poll(). As a workaround we store priv into kn->kn_hook
 * and pass it as first argument to netmap_poll(), which then
 * uses the failure to tell that we are called from f_event()
 * and do not need the selrecord().
 */
The OS_selwakeup also needs to issue a KNOTE_UNLOCKED.
We use a non-zero argument to distinguish the call from the one
in kevent_scan() which instead also needs to run netmap_poll().
The knote uses a global mutex for the time being. We might
try to reuse the one in the si, but it is not allocated
permanently so it might be a bit tricky.

The *kqfilter function registers one or another f_event
depending on read or write mode.
In the call to f_event() td_fpop is NULL so any child function
calling devfs_get_cdevpriv() would fail - and we need it in
netmap_poll(). As a workaround we store priv into kn->kn_hook
and pass it as first argument to netmap_poll(), which then
uses the failure to tell that we are called from f_event()
and do not need the selrecord().
The OS_selwakeup also needs to issue a KNOTE_UNLOCKED . We use a non - zero argument to distinguish the call from the one in kevent_scan () which instead also needs to run netmap_poll () . The knote uses a global mutex for the time being . We might try to reuse the one in the si but it is not allocated permanently so it might be a bit tricky . The * kqfilter function registers one or another f_event depending on read or write mode . In the call to f_event () td_fpop is NULL so any child function calling devfs_get_cdevpriv () would fail - and we need it in netmap_poll () . As a workaround we store priv into kn - > kn_hook and pass it as first argument to netmap_poll () which then uses the failure to tell that we are called from f_event () and do not need the selrecord () .
void
freebsd_selwakeup(struct nm_selinfo *si, int pri)
{
	if (netmap_verbose)
		D("on knote %p", &si->si.si_note);
	selwakeuppri(&si->si, pri);
	KNOTE_UNLOCKED(&si->si.si_note, 0x100 );
}
void freebsd_selwakeup ( struct nm_selinfo * si , int pri ) { if ( netmap_verbose ) D ( " " , & si -> si . si_note ) ; selwakeuppri ( & si -> si , pri ) ; KNOTE_UNLOCKED ( & si -> si . si_note , 0x100 ) ; }
The OS_selwakeup also needs to issue a KNOTE_UNLOCKED.
The OS_selwakeup also needs to issue a KNOTE_UNLOCKED .
/* use a non-zero hint to tell the notification from the
	 * call done in kqueue_scan() which uses 0
	 */ /* notification */