Page MenuHomeFreeBSD

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

Authored by vmaffione on Feb 13 2019, 9:51 AM.
Tags
None
Referenced Files
F81659167: D19177.diff
Fri, Apr 19, 2:22 PM
Unknown Object (File)
Wed, Apr 17, 8:50 PM
Unknown Object (File)
Wed, Apr 17, 8:41 PM
Unknown Object (File)
Wed, Apr 17, 3:25 AM
Unknown Object (File)
Dec 20 2023, 1:36 AM
Unknown Object (File)
Dec 18 2023, 9:36 AM
Unknown Object (File)
Dec 12 2023, 6:22 AM
Unknown Object (File)
Sep 21 2023, 9:02 AM
Subscribers

Details

Summary

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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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
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);
}

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.

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.

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.