aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2021-02-18 10:25:10 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2021-02-18 14:02:48 +0000
commitfa2528ac643519072c498b483d0dcc1fa5d99bc1 (patch)
tree255d2d54811e94f63b72fe40c4a88b4f11978e9f /lib
parentdf093aa9463b2121d8307fb91c4ba7cf17f4ea64 (diff)
downloadsrc-fa2528ac643519072c498b483d0dcc1fa5d99bc1.tar.gz
src-fa2528ac643519072c498b483d0dcc1fa5d99bc1.zip
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
Diffstat (limited to 'lib')
-rw-r--r--lib/libkvm/kvm_proc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c
index 63f7c2a8a824..eed2f3de6075 100644
--- a/lib/libkvm/kvm_proc.c
+++ b/lib/libkvm/kvm_proc.c
@@ -426,7 +426,7 @@ nopgrp:
TD_CAN_RUN(&mtd) ||
TD_IS_RUNNING(&mtd)) {
kp->ki_stat = SRUN;
- } else if (mtd.td_state ==
+ } else if (TD_GET_STATE(&mtd) ==
TDS_INHIBITED) {
if (P_SHOULDSTOP(&proc)) {
kp->ki_stat = SSTOP;