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
Unknown Object (File)
Tue, Dec 10, 7:37 PM
Unknown Object (File)
Nov 22 2024, 11:02 AM
Unknown Object (File)
Nov 18 2024, 6:16 AM
Unknown Object (File)
Oct 6 2024, 9:40 AM
Unknown Object (File)
Oct 3 2024, 10:36 AM
Unknown Object (File)
Oct 3 2024, 8:35 AM
Unknown Object (File)
Oct 1 2024, 10:47 AM
Unknown Object (File)
Oct 1 2024, 8:46 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.