aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/netmap/netmap_freebsd.c
diff options
context:
space:
mode:
authorVincenzo Maffione <vmaffione@FreeBSD.org>2019-02-25 08:50:25 +0000
committerVincenzo Maffione <vmaffione@FreeBSD.org>2019-02-25 08:50:25 +0000
commitc328e25c65b8a1d3e96b886bba35bed19eb330c0 (patch)
tree4b44620a351b28796af08e73ee9e5c4a4dbf6f42 /sys/dev/netmap/netmap_freebsd.c
parent40adc03f17aadac4d5581452cf122b4b06530835 (diff)
Notes
Diffstat (limited to 'sys/dev/netmap/netmap_freebsd.c')
-rw-r--r--sys/dev/netmap/netmap_freebsd.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c
index d99e526f3d10..c6cd24461b6b 100644
--- a/sys/dev/netmap/netmap_freebsd.c
+++ b/sys/dev/netmap/netmap_freebsd.c
@@ -105,6 +105,7 @@ int nm_os_selinfo_init(NM_SELINFO_T *si, const char *name) {
snprintf(si->mtxname, sizeof(si->mtxname), "nmkl%s", name);
mtx_init(&si->m, si->mtxname, NULL, MTX_DEF);
knlist_init_mtx(&si->si.si_note, &si->m);
+ si->kqueue_users = 0;
return (0);
}
@@ -1351,7 +1352,9 @@ void
nm_os_selwakeup(struct nm_selinfo *si)
{
selwakeuppri(&si->si, PI_NET);
- taskqueue_enqueue(si->ntfytq, &si->ntfytask);
+ if (si->kqueue_users > 0) {
+ taskqueue_enqueue(si->ntfytq, &si->ntfytask);
+ }
}
void
@@ -1364,20 +1367,28 @@ static void
netmap_knrdetach(struct knote *kn)
{
struct netmap_priv_d *priv = (struct netmap_priv_d *)kn->kn_hook;
- struct selinfo *si = &priv->np_si[NR_RX]->si;
+ struct nm_selinfo *si = priv->np_si[NR_RX];
- nm_prinf("remove selinfo %p", si);
- knlist_remove(&si->si_note, kn, /*islocked=*/0);
+ knlist_remove(&si->si.si_note, kn, /*islocked=*/0);
+ NMG_LOCK();
+ KASSERT(si->kqueue_users > 0, ("kqueue_user underflow on %s",
+ si->mtxname));
+ si->kqueue_users--;
+ nm_prinf("kqueue users for %s: %d", si->mtxname, si->kqueue_users);
+ NMG_UNLOCK();
}
static void
netmap_knwdetach(struct knote *kn)
{
struct netmap_priv_d *priv = (struct netmap_priv_d *)kn->kn_hook;
- struct selinfo *si = &priv->np_si[NR_TX]->si;
+ struct nm_selinfo *si = priv->np_si[NR_TX];
- nm_prinf("remove selinfo %p", si);
- knlist_remove(&si->si_note, kn, /*islocked=*/0);
+ knlist_remove(&si->si.si_note, kn, /*islocked=*/0);
+ NMG_LOCK();
+ si->kqueue_users--;
+ nm_prinf("kqueue users for %s: %d", si->mtxname, si->kqueue_users);
+ NMG_UNLOCK();
}
/*
@@ -1465,6 +1476,10 @@ netmap_kqfilter(struct cdev *dev, struct knote *kn)
kn->kn_fop = (ev == EVFILT_WRITE) ?
&netmap_wfiltops : &netmap_rfiltops;
kn->kn_hook = priv;
+ NMG_LOCK();
+ si->kqueue_users++;
+ nm_prinf("kqueue users for %s: %d", si->mtxname, si->kqueue_users);
+ NMG_UNLOCK();
knlist_add(&si->si.si_note, kn, /*islocked=*/0);
return 0;