Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Dec 2018 15:15:46 +0000 (UTC)
From:      Vincenzo Maffione <vmaffione@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r342368 - head/sys/dev/netmap
Message-ID:  <201812221515.wBMFFknS006898@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vmaffione
Date: Sat Dec 22 15:15:45 2018
New Revision: 342368
URL: https://svnweb.freebsd.org/changeset/base/342368

Log:
  netmap: fix bug in netmap_poll() optimization
  
  The bug was introduced by r339639, although it is present in the upstream
  netmap code since 2015. It is due to resetting the want_rx variable to
  POLLIN, rather than resetting it to POLLIN|POLLRDNORM.
  It only affects select(), which uses POLLRDNORM. poll() is not affected,
  because it uses POLLIN.
  Also, it only affects FreeBSD, because Linux skips the optimization
  implemented by the piece of code where the bug occurs.
  
  MFC after:	3 days
  Sponsored by:	Sunny Valley Networks

Modified:
  head/sys/dev/netmap/netmap.c

Modified: head/sys/dev/netmap/netmap.c
==============================================================================
--- head/sys/dev/netmap/netmap.c	Sat Dec 22 11:38:54 2018	(r342367)
+++ head/sys/dev/netmap/netmap.c	Sat Dec 22 15:15:45 2018	(r342368)
@@ -3304,16 +3304,19 @@ netmap_poll(struct netmap_priv_d *priv, int events, NM
 	}
 	if (want_rx) {
 		enum txrx t = NR_RX;
-		want_rx = 0; /* look for a reason to run the handlers */
+		int rxsync_needed = 0;
+
+		/* look for a reason to run the handlers */
 		for (i = priv->np_qfirst[t]; i < priv->np_qlast[t]; i++) {
 			kring = NMR(na, t)[i];
 			if (kring->ring->cur == kring->ring->tail /* try fetch new buffers */
 			    || kring->rhead != kring->ring->head /* release buffers */) {
-				want_rx = 1;
+				rxsync_needed = 1;
+				break;
 			}
 		}
-		if (!want_rx)
-			revents |= events & (POLLIN | POLLRDNORM); /* we have data */
+		if (!rxsync_needed)
+			revents |= want_rx; /* we have data */
 	}
 #endif
 



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