diff options
authorLuiz Otavio O Souza <loos@FreeBSD.org>2015-08-03 22:14:45 +0000
committerLuiz Otavio O Souza <loos@FreeBSD.org>2015-08-03 22:14:45 +0000
commit9224217213dbf5ffc74bc54b83aff584304f0677 (patch)
parentfc6ab770113e1401ad4e8dc50bd4d585fecf9770 (diff)
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 manipulates 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 MFC after: 2 weeks Sponsored by: Rubicon Communications (Netgate)
Notes: svn path=/head/; revision=286260
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 2be4554cbd9e..985208b1975a 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -2035,10 +2035,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,