diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-08-08 18:55:48 +0200 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-09-17 19:00:55 +0200 |
| commit | f084ff128b6136e1aebfd73e1cf7066a077a79bf (patch) | |
| tree | d79f494cbc5bc28369bedfee0cdc5fed2d765a94 /accel/tcg/tcg-accel-ops-rr.c | |
| parent | ac6c8a390b451913995ee784ef7261b8928e5ace (diff) | |
| download | focaccia-qemu-f084ff128b6136e1aebfd73e1cf7066a077a79bf.tar.gz focaccia-qemu-f084ff128b6136e1aebfd73e1cf7066a077a79bf.zip | |
accel: use atomic accesses for exit_request
CPU threads write exit_request as a "note to self" that they need to
go out to a slow path. This write happens out of the BQL and can be
a data race with another threads' cpu_exit(); use atomic accesses
consistently.
While at it, change the source argument from int ("1") to bool ("true").
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'accel/tcg/tcg-accel-ops-rr.c')
| -rw-r--r-- | accel/tcg/tcg-accel-ops-rr.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index e8b0e370a8..d13e0d8b44 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -212,7 +212,7 @@ static void *rr_cpu_thread_fn(void *arg) cpu = first_cpu; /* process any pending work */ - cpu->exit_request = 1; + qatomic_set(&cpu->exit_request, true); while (1) { /* Only used for icount_enabled() */ @@ -293,7 +293,7 @@ static void *rr_cpu_thread_fn(void *arg) /* Does not need a memory barrier because a spurious wakeup is okay. */ qatomic_set(&rr_current_cpu, NULL); - if (cpu && cpu->exit_request) { + if (cpu && qatomic_read(&cpu->exit_request)) { qatomic_set_mb(&cpu->exit_request, 0); } |