From: Ian Rogers Date: Sat, 14 Jan 2023 21:52:51 +0000 (-0800) Subject: perf test workload thloop: Make count increments atomic X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=1962ab6f6e0b39e4216206205bda14aff87705f3;p=linux.git perf test workload thloop: Make count increments atomic The count variable is incremented by multiple threads, doing so without an atomic operation causes thread sanitizer warnings. Switch to using relaxed atomics. Signed-off-by: Ian Rogers Cc: Alexander Shishkin Cc: Ingo Molnar Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20230114215251.271678-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/tests/workloads/thloop.c b/tools/perf/tests/workloads/thloop.c index 29193b75717ef..af05269c2eb8a 100644 --- a/tools/perf/tests/workloads/thloop.c +++ b/tools/perf/tests/workloads/thloop.c @@ -20,7 +20,7 @@ static void sighandler(int sig __maybe_unused) noinline void test_loop(void) { while (!done) - count++; + __atomic_fetch_add(&count, 1, __ATOMIC_RELAXED); } static void *thfunc(void *arg)