HomeFreeBSD

Use atomic loads/stores when updating td->td_state

Description

Use atomic loads/stores when updating td->td_state

KCSAN complains about racy accesses in the locking code. Those races are
fine since they are inside a TD_SET_RUNNING() loop that expects the value
to be changed by another CPU.

Use relaxed atomic stores/loads to indicate that this variable can be
written/read by multiple CPUs at the same time. This will also prevent
the compiler from doing unexpected re-ordering.

Reported by: GENERIC-KCSAN
Test Plan: KCSAN no longer complains, kernel still runs fine.
Reviewed By: markj, mjg (earlier version)
Differential Revision: https://reviews.freebsd.org/D28569

Details

Provenance
arichardsonAuthored on Feb 18 2021, 10:25 AM
Reviewer
markj
Differential Revision
D28569: Use atomic loads/stores when updating td->td_state
Parents
R10:df093aa9463b: tests/sys/audit: Avoid race caused by starting auditd(8) for testing
Branches
Unknown
Tags
Unknown