summary refs log tree commit diff stats
path: root/include/hw/core
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-08-08 18:55:48 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2025-09-17 19:00:55 +0200
commitf084ff128b6136e1aebfd73e1cf7066a077a79bf (patch)
treed79f494cbc5bc28369bedfee0cdc5fed2d765a94 /include/hw/core
parentac6c8a390b451913995ee784ef7261b8928e5ace (diff)
downloadfocaccia-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 'include/hw/core')
-rw-r--r--include/hw/core/cpu.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 8b57bcd92c..338757e525 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -422,6 +422,15 @@ struct qemu_work_item;
  * valid under cpu_list_lock.
  * @created: Indicates whether the CPU thread has been successfully created.
  * @halt_cond: condition variable sleeping threads can wait on.
+ * @exit_request: Another thread requests the CPU to call qemu_wait_io_event().
+ *   Should be read only by CPU thread with load-acquire, to synchronize with
+ *   other threads' store-release operation.
+ *
+ *   In some cases, accelerator-specific code will write exit_request from
+ *   within the same thread, to "bump" the effect of qemu_cpu_kick() to
+ *   the one provided by cpu_exit(), especially when processing interrupt
+ *   flags.  In this case, the write and read happen in the same thread
+ *   and the write therefore can use qemu_atomic_set().
  * @interrupt_request: Indicates a pending interrupt request.
  *   Only used by system emulation.
  * @halted: Nonzero if the CPU is in suspended state.