From owner-svn-src-head@freebsd.org Sat Dec 22 16:23:43 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2CEF313577DE; Sat, 22 Dec 2018 16:23:43 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C679F8D5D7; Sat, 22 Dec 2018 16:23:42 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BAA5F2783F; Sat, 22 Dec 2018 16:23:42 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBMGNgHV043762; Sat, 22 Dec 2018 16:23:42 GMT (envelope-from vmaffione@FreeBSD.org) Received: (from vmaffione@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBMGNgX6043761; Sat, 22 Dec 2018 16:23:42 GMT (envelope-from vmaffione@FreeBSD.org) Message-Id: <201812221623.wBMGNgX6043761@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vmaffione set sender to vmaffione@FreeBSD.org using -f From: Vincenzo Maffione Date: Sat, 22 Dec 2018 16:23:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r342369 - head/sys/dev/netmap X-SVN-Group: head X-SVN-Commit-Author: vmaffione X-SVN-Commit-Paths: head/sys/dev/netmap X-SVN-Commit-Revision: 342369 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C679F8D5D7 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.93 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.94)[-0.935,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Dec 2018 16:23:43 -0000 Author: vmaffione Date: Sat Dec 22 16:23:42 2018 New Revision: 342369 URL: https://svnweb.freebsd.org/changeset/base/342369 Log: netmap: fix txsync check in netmap poll To check if txsync can be skipped, it is necessary to look for unseen TX space. However, this means comparing ring->cur against ring->tail, rather than ring->head against ring->tail (like nm_ring_empty() does). This change also adds some more comments to explain the optimization performed at the beginning of netmap_poll(). 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 15:15:45 2018 (r342368) +++ head/sys/dev/netmap/netmap.c Sat Dec 22 16:23:42 2018 (r342369) @@ -3292,31 +3292,38 @@ netmap_poll(struct netmap_priv_d *priv, int events, NM * that we must call nm_os_selrecord() unconditionally. */ if (want_tx) { - enum txrx t = NR_TX; - for (i = priv->np_qfirst[t]; want[t] && i < priv->np_qlast[t]; i++) { + const enum txrx t = NR_TX; + for (i = priv->np_qfirst[t]; i < priv->np_qlast[t]; i++) { kring = NMR(na, t)[i]; - /* XXX compare ring->cur and kring->tail */ - if (!nm_ring_empty(kring->ring)) { + if (kring->ring->cur != kring->ring->tail) { + /* Some unseen TX space is available, so what + * we don't need to run txsync. */ revents |= want[t]; - want[t] = 0; /* also breaks the loop */ + want[t] = 0; + break; } } } if (want_rx) { - enum txrx t = NR_RX; + const enum txrx t = NR_RX; 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 */) { + if (kring->ring->cur == kring->ring->tail + || kring->rhead != kring->ring->head) { + /* There are no unseen packets on this ring, + * or there are some buffers to be returned + * to the netmap port. We therefore go ahead + * and run rxsync. */ rxsync_needed = 1; break; } } - if (!rxsync_needed) - revents |= want_rx; /* we have data */ + if (!rxsync_needed) { + revents |= want_rx; + want_rx = 0; + } } #endif