Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Aug 2015 22:14:45 +0000 (UTC)
From:      Luiz Otavio O Souza <loos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r286260 - head/sys/net
Message-ID:  <201508032214.t73MEjW1038794@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: loos
Date: Mon Aug  3 22:14:45 2015
New Revision: 286260
URL: https://svnweb.freebsd.org/changeset/base/286260

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

Modified:
  head/sys/net/bpf.c

Modified: head/sys/net/bpf.c
==============================================================================
--- head/sys/net/bpf.c	Mon Aug  3 22:07:50 2015	(r286259)
+++ head/sys/net/bpf.c	Mon Aug  3 22:14:45 2015	(r286260)
@@ -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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508032214.t73MEjW1038794>