Page MenuHomeFreeBSD

netmap: don't schedule kqueue notify task when kqueue is not used

Authored by vmaffione on Feb 13 2019, 9:51 AM.



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.

Test Plan

Two bhyve VMs over VALE.
Local testing kqueue usage.

Diff Detail

rS FreeBSD src repository
Lint Skipped
Unit Tests Skipped

Event Timeline

vmaffione retitled this revision from netmap: don't schedule kqueue notify task when kqueue is used to netmap: don't schedule kqueue notify task when kqueue is not used.Feb 13 2019, 9:52 AM

Maybe we can use the knlist_empty (9) function to check if kqueue is used?

Something like:

if (!knlist_empty(&si->si.si_note)) {
       taskqueue_enqueue(si->ntfytq, &si->ntfytask);
} else {

We can't. We use a taskqueue there precisely because we cannot take the si->m lock (or we get LOR).

Oops, I forgot this. I will test the current patch.

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.

Sorry for the long delay. My tests didn't find any regression.

This revision is now accepted and ready to land.Feb 18 2019, 10:55 AM

No worries, and thanks for testing!

This revision was automatically updated to reflect the committed changes.