From nobody Wed Feb 01 17:32:01 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P6TW52LQ2z3bJ1V; Wed, 1 Feb 2023 17:32:01 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P6TW51qYHz3Pkb; Wed, 1 Feb 2023 17:32:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675272721; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/42Re8zptttSpdzb8tLYIk0NsZSd/uESYGVkAUba34Q=; b=uVJQLEbLHc5Czm8rVanBbNZSDn1pU5/WeP7DM1Yp8W1Y380uWT2pWm94Wiyg1P/UpiLdvX DmbRJ1rtNntEQn/b+2OvY55GIECZ2BRwxnUC8w21NJQM/Ue5PtgNFLqy5CTK0rWxr5TMKs JM8L+Jm4ldsDgJGvpK8/3qN5dTBVxgHQp7v4ThFlkH/4qxhyeqSImV6VNSg4NjlrokcFgJ YaMROO0ojkK5KVj/Xsw+31QX/uhVpKW4pizrdhg+I/IXeu0CHW/l1dzhnCE5PI/qlnW3KP Dd5kF3jJyKGhVLKjAhPljwYMAtzAl9r0zZSf7XBOZ4ea4zXHw9I2/3QlUm4m+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675272721; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/42Re8zptttSpdzb8tLYIk0NsZSd/uESYGVkAUba34Q=; b=sgi/FM2bXMaSzUsBcRadKK1vY8aZwyeosYZnTz33yaNfMUPHxd0aeDAlEF+HDYT0Be9bjT vUPoKccARnKMCOkz/j9fk8mi7TpLiGwGZ5afKr3bR1u5TooTZtnAkuQxQBQYVeb+siq8LQ EF3IUUEKMWFqUsW1rRNzbqFvCBz9grwNdNkNcPmyRbNLkmFICAliyAnQ7Sfxivg1m2CO9U 0rXLsClGF11q+Fd7Hp2gTUc3Qg6VafAlN29/eu8bU7lru6SX33kycyuZUKCwRe0Meb07yN dpv+YJocfDXKivQ7x+qyodVn9S1dzq1XQDfSxzaKIcHqHij5A2v7AzneQlxXrA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675272721; a=rsa-sha256; cv=none; b=erZxEGo5Nssdt4/Ij2kKTUN0XMo4t7SAq+9m0CxdSGyT0X41bthy2gc9/lnuCC4xe4kBVl +i3BwCfPprDH4IDnLebFI5tpYvjXdQ2vZIp9umyLFbKK1u8A8M9ZqUJUGvT15n4o3tCvZf gyO6zww8oO7bYt27RFgpbmbhtoxGU8N0j0VxYtkbQuK2XNqiSbGKSjRwXfYN2XKzkwgW4o 1hueI0Fx5pu7pCiOP+b8LF4owc9PnVgXPtLnXkgovM1Cr3XFnHpT2OO7RSEec9Ok/VVcEI ceszi/X9pUI1MSXxGuLeJZ6BRivItrBes/umKI9lqY3DiKgk6e300b8zppmj4A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P6TW50xCmzNB0; Wed, 1 Feb 2023 17:32:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 311HW1ov058096; Wed, 1 Feb 2023 17:32:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 311HW1fX058095; Wed, 1 Feb 2023 17:32:01 GMT (envelope-from git) Date: Wed, 1 Feb 2023 17:32:01 GMT Message-Id: <202302011732.311HW1fX058095@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: b547900689ec - stable/13 - netmap: Tell the compiler to avoid reloading ring indices List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b547900689ec6b500fefbf76585e7e4650a49dc2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b547900689ec6b500fefbf76585e7e4650a49dc2 commit b547900689ec6b500fefbf76585e7e4650a49dc2 Author: Mark Johnston AuthorDate: 2023-01-23 19:41:05 +0000 Commit: Mark Johnston CommitDate: 2023-02-01 17:22:31 +0000 netmap: Tell the compiler to avoid reloading ring indices Per the removed comments these fields should be loaded only once, since they can in principle be modified concurrently, though this would be a violation of the userspace contract with netmap. No functional change intended. Reviewed by: vmaffione MFC after: 1 week Sponsored by: Zenarmor Sponsored by: OPNsense Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D38061 (cherry picked from commit 56c438fcd4a755f0abe8254779c39a0c4b530c75) --- sys/dev/netmap/netmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/netmap/netmap.c b/sys/dev/netmap/netmap.c index 1b8a4ff1d5d4..8c4481c2e6c3 100644 --- a/sys/dev/netmap/netmap.c +++ b/sys/dev/netmap/netmap.c @@ -1671,8 +1671,8 @@ netmap_unget_na(struct netmap_adapter *na, struct ifnet *ifp) u_int nm_txsync_prologue(struct netmap_kring *kring, struct netmap_ring *ring) { - u_int head = ring->head; /* read only once */ - u_int cur = ring->cur; /* read only once */ + u_int head = NM_ACCESS_ONCE(ring->head); + u_int cur = NM_ACCESS_ONCE(ring->cur); u_int n = kring->nkr_num_slots; nm_prdis(5, "%s kcur %d ktail %d head %d cur %d tail %d", @@ -1749,8 +1749,8 @@ nm_rxsync_prologue(struct netmap_kring *kring, struct netmap_ring *ring) * - cur could in principle go back, however it does not matter * because we are processing a brand new rxsync() */ - cur = kring->rcur = ring->cur; /* read only once */ - head = kring->rhead = ring->head; /* read only once */ + cur = kring->rcur = NM_ACCESS_ONCE(ring->cur); + head = kring->rhead = NM_ACCESS_ONCE(ring->head); #if 1 /* kernel sanity checks */ NM_FAIL_ON(kring->nr_hwcur >= n || kring->nr_hwtail >= n); #endif /* kernel sanity checks */