Page MenuHomeFreeBSD

wg: Remove some atomics for kp pointers.
Needs ReviewPublic

Authored by jhb on Jul 29 2022, 4:57 PM.
Tags
None
Referenced Files
F105944643: D35991.id108716.diff
Sun, Dec 22, 10:32 PM
F105923623: D35991.diff
Sun, Dec 22, 5:45 PM
Unknown Object (File)
Nov 16 2024, 5:13 PM
Unknown Object (File)
Nov 15 2024, 2:03 PM
Unknown Object (File)
Nov 15 2024, 2:01 PM
Unknown Object (File)
Nov 15 2024, 1:39 PM
Unknown Object (File)
Nov 12 2024, 5:04 AM
Unknown Object (File)
Nov 12 2024, 4:12 AM
Subscribers

Details

Reviewers
markj
Summary

Atomics are not needed for accesses synchronized by a mutex.

There is one unlocked read of the pointer for which the atomic
load doesn't do anything (in terms of limiting races).

Atomics remain for accesses under the NET_EPOCH to provide
READ_ONCE semantics.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 46683
Build 43572: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Jul 29 2022, 4:57 PM

There is one unlocked read of the pointer for which the atomic load doesn't do anything (in terms of limiting races).

Does it make sense for this case to have a comment (i.e., explaining why the race is not important)?

sys/dev/wg/wg_noise.c
730

This is the unlocked read and it's just an optimization to avoid the lock below (and not an uncommon pattern, so I think it is obvious in context)

sys/dev/wg/wg_noise.c
730

Fair enough, I did not look at each case to find the unlocked read and when pointed out in context it's clear enough to me. [That said I don't think a comment wouldn't be out of place]

sys/dev/wg/wg_noise.c
589

Possibly these two should remain as atomics as they are used to provide READ_ONCE semantics.

706

Another READ_ONCE

865

Another READ_ONCE

894

Another READ_ONCE

jhb retitled this revision from wg_noise: Remove atomics for kp pointers. to wg_noise: Remove some atomics for kp pointers..Oct 7 2022, 7:35 PM
jhb edited the summary of this revision. (Show Details)
jhb edited the summary of this revision. (Show Details)
  • Keep atomics for READ_ONCE cases.
jhb retitled this revision from wg_noise: Remove some atomics for kp pointers. to wg: Remove some atomics for kp pointers..Oct 7 2022, 9:55 PM
  • Rebase post atomic(9).