From 73995701a7446670b1a5f515825b0e74d1e8cb1e Mon Sep 17 00:00:00 2001 From: loos Date: Mon, 17 Aug 2015 19:06:14 +0000 Subject: [PATCH] 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) git-svn-id: svn://svn.freebsd.org/base/stable/10@286859 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/net/bpf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/net/bpf.c b/sys/net/bpf.c index cc73e005f..914dad61f 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, -- 2.45.0