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)
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
Unknown Object (File)
Sep 27 2024, 4:27 AM
Unknown Object (File)
Sep 24 2024, 4:44 PM
Unknown Object (File)
Sep 23 2024, 4:49 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).