Author: loos
Date: Mon Aug 17 19:06:14 2015
New Revision: 286859
URL: https://svnweb.freebsd.org/changeset/base/286859

Log:
  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)

Modified:
  stable/10/sys/net/bpf.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/net/bpf.c
==============================================================================
--- stable/10/sys/net/bpf.c     Mon Aug 17 19:02:23 2015        (r286858)
+++ stable/10/sys/net/bpf.c     Mon Aug 17 19:06:14 2015        (r286859)
@@ -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,
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to