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
Unknown Object (File)
Tue, Nov 12, 5:04 AM
Unknown Object (File)
Tue, Nov 12, 4:12 AM
Unknown Object (File)
Sun, Nov 10, 1:40 PM
Unknown Object (File)
Wed, Oct 16, 4:33 PM
Unknown Object (File)
Wed, Oct 16, 4:33 PM
Unknown Object (File)
Wed, Oct 16, 4:32 PM
Unknown Object (File)
Wed, Oct 16, 4:32 PM
Unknown Object (File)
Wed, Oct 16, 3:52 PM
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).