git: 56c438fcd4a7 - main - netmap: Tell the compiler to avoid reloading ring indices
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 23 Jan 2023 19:52:45 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=56c438fcd4a755f0abe8254779c39a0c4b530c75 commit 56c438fcd4a755f0abe8254779c39a0c4b530c75 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2023-01-23 19:41:05 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2023-01-23 19:41:05 +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 --- 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 4bafa507384d..448d9a81eefb 100644 --- a/sys/dev/netmap/netmap.c +++ b/sys/dev/netmap/netmap.c @@ -1710,8 +1710,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", @@ -1788,8 +1788,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 */