summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorloos <loos@FreeBSD.org>2015-08-17 19:06:14 +0000
committerloos <loos@FreeBSD.org>2015-08-17 19:06:14 +0000
commit47eb9e91e4cef40c34486f99c1fe7584fc41e91c (patch)
tree4cad47b92a39c7611e37f20abb376f06bd3e0341 /sys/net
parent21e0cf5c4b7fda90cdb022c7c0494cf099287f59 (diff)
downloadFreeBSD-src-47eb9e91e4cef40c34486f99c1fe7584fc41e91c.zip
FreeBSD-src-47eb9e91e4cef40c34486f99c1fe7584fc41e91c.tar.gz
MFC r286260:
Remove the mtx_sleep() from the kqueue f_event filter. The filter is called from the network hot path and must not sleep. The filter runs with the descriptor lock held and does not manipulate the buffers, so it is not necessary sleep when the hold buffer is in use. Just ignore the hold buffer contents when it is being copied to user space (when hold buffer in use is set). This fix the "Sleeping thread owns a non-sleepable lock" panic when the userland thread is too busy reading the packets from bpf(4). PR: 200323 Sponsored by: Rubicon Communications (Netgate)
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/bpf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index cc73e00..914dad6 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1984,10 +1984,10 @@ filt_bpfread(struct knote *kn, long hint)
ready = bpf_ready(d);
if (ready) {
kn->kn_data = d->bd_slen;
- while (d->bd_hbuf_in_use)
- mtx_sleep(&d->bd_hbuf_in_use, &d->bd_lock,
- PRINET, "bd_hbuf", 0);
- if (d->bd_hbuf)
+ /*
+ * Ignore the hold buffer if it is being copied to user space.
+ */
+ if (!d->bd_hbuf_in_use && d->bd_hbuf)
kn->kn_data += d->bd_hlen;
} else if (d->bd_rtout > 0 && d->bd_state == BPF_IDLE) {
callout_reset(&d->bd_callout, d->bd_rtout,
OpenPOWER on IntegriCloud