* [PATCH v1] perf test workload thloop: Make count increments atomic
@ 2023-01-14 21:52 Ian Rogers
2023-01-19 16:09 ` Ian Rogers
0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2023-01-14 21:52 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Ian Rogers, linux-perf-users, linux-kernel
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 <irogers@google.com>
---
tools/perf/tests/workloads/thloop.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/tests/workloads/thloop.c b/tools/perf/tests/workloads/thloop.c
index 29193b75717e..af05269c2eb8 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)
--
2.39.0.314.g84b9a713c41-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] perf test workload thloop: Make count increments atomic
2023-01-14 21:52 [PATCH v1] perf test workload thloop: Make count increments atomic Ian Rogers
@ 2023-01-19 16:09 ` Ian Rogers
0 siblings, 0 replies; 2+ messages in thread
From: Ian Rogers @ 2023-01-19 16:09 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Ian Rogers, linux-perf-users, linux-kernel
On Sat, Jan 14, 2023 at 1:53 PM Ian Rogers <irogers@google.com> wrote:
>
> 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 <irogers@google.com>
> ---
> tools/perf/tests/workloads/thloop.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/workloads/thloop.c b/tools/perf/tests/workloads/thloop.c
> index 29193b75717e..af05269c2eb8 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);
Ping. No functional change, cleans up a lot of thread sanitizer
issues, the use of __atomic_fetch_add is consistent with other files.
Thanks,
Ian
> }
>
> static void *thfunc(void *arg)
> --
> 2.39.0.314.g84b9a713c41-goog
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-19 16:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-14 21:52 [PATCH v1] perf test workload thloop: Make count increments atomic Ian Rogers
2023-01-19 16:09 ` Ian Rogers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).