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)
Jan 9 2024, 9:01 PM
Unknown Object (File)
Dec 26 2023, 5:14 PM
Unknown Object (File)
Dec 22 2023, 11:03 PM
Unknown Object (File)
Dec 12 2023, 11:29 AM
Unknown Object (File)
Oct 31 2023, 8:44 PM
Unknown Object (File)
Jun 25 2023, 9:57 PM
Unknown Object (File)
Feb 17 2023, 4:12 PM
Unknown Object (File)
Feb 13 2023, 4:56 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
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 47978
Build 44865: 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
727

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
727

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
586

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

702–703

Another READ_ONCE

860–861

Another READ_ONCE

889–890

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).