diff options
author | Alex Richardson <arichardson@FreeBSD.org> | 2021-02-18 10:25:10 +0000 |
---|---|---|
committer | Alex Richardson <arichardson@FreeBSD.org> | 2021-02-18 14:02:48 +0000 |
commit | fa2528ac643519072c498b483d0dcc1fa5d99bc1 (patch) | |
tree | 255d2d54811e94f63b72fe40c4a88b4f11978e9f /sys/gdb/gdb_main.c | |
parent | df093aa9463b2121d8307fb91c4ba7cf17f4ea64 (diff) | |
download | src-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 'sys/gdb/gdb_main.c')
-rw-r--r-- | sys/gdb/gdb_main.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/gdb/gdb_main.c b/sys/gdb/gdb_main.c index 6e0c9f21f947..a9e935ebfbb5 100644 --- a/sys/gdb/gdb_main.c +++ b/sys/gdb/gdb_main.c @@ -510,11 +510,11 @@ do_qXfer_threads_read(void) sbuf_putc(&ctx.qXfer.sb, '>'); - if (ctx.iter->td_state == TDS_RUNNING) + if (TD_GET_STATE(ctx.iter) == TDS_RUNNING) sbuf_cat(&ctx.qXfer.sb, "Running"); - else if (ctx.iter->td_state == TDS_RUNQ) + else if (TD_GET_STATE(ctx.iter) == TDS_RUNQ) sbuf_cat(&ctx.qXfer.sb, "RunQ"); - else if (ctx.iter->td_state == TDS_CAN_RUN) + else if (TD_GET_STATE(ctx.iter) == TDS_CAN_RUN) sbuf_cat(&ctx.qXfer.sb, "CanRun"); else if (TD_ON_LOCK(ctx.iter)) sbuf_cat(&ctx.qXfer.sb, "Blocked"); |