Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177484950
D19177.1794544394.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D19177.1794544394.diff
View Options
Index: head/sys/dev/netmap/netmap_freebsd.c
===================================================================
--- head/sys/dev/netmap/netmap_freebsd.c
+++ head/sys/dev/netmap/netmap_freebsd.c
@@ -105,6 +105,7 @@
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 @@
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 @@
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 @@
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;
Index: head/sys/dev/netmap/netmap_kern.h
===================================================================
--- head/sys/dev/netmap/netmap_kern.h
+++ head/sys/dev/netmap/netmap_kern.h
@@ -132,11 +132,14 @@
#define MBUF_QUEUED(m) 1
struct nm_selinfo {
+ /* Support for select(2) and poll(2). */
struct selinfo si;
+ /* Support for kqueue(9). See comments in netmap_freebsd.c */
struct taskqueue *ntfytq;
struct task ntfytask;
struct mtx m;
char mtxname[32];
+ int kqueue_users;
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 13, 4:33 AM (10 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41690363
Default Alt Text
D19177.1794544394.diff (2 KB)
Attached To
Mode
D19177: netmap: don't schedule kqueue notify task when kqueue is not used
Attached
Detach File
Event Timeline