This change adds a counter (kqueue_users) to keep track of how many kqueue users are referencing a given struct nm_selinfo.
In this way, nm_os_selwakeup() can schedule the kevent notification task only when kqueue is actually being used.
This is important to avoid wasting CPU in the common case where kqueue is not used.
Details
Details
Two bhyve VMs over VALE.
Local testing kqueue usage.
Diff Detail
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
sys/dev/netmap/netmap_freebsd.c | ||
---|---|---|
1355 ↗ | (On Diff #53868) | Maybe we can use the knlist_empty (9) function to check if kqueue is used? Something like: mtx_lock(&si->m); if (!knlist_empty(&si->si.si_note)) { mtx_unlock(&si->m); taskqueue_enqueue(si->ntfytq, &si->ntfytask); } else { mtx_unlock(&si->m); } |
Comment Actions
We can't. We use a taskqueue there precisely because we cannot take the si->m lock (or we get LOR).
Comment Actions
Thanks.
In my tests I can see that without the patch, two pkt-gen communicating over a VALE port will consume 9% CPU on kqueue processing (although kqueue is not used), on a separate CPU.
With the patch, the 9% goes away.