qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/19] accel, cpus: clean up cpu->exit_request
@ 2025-09-08 10:12 Paolo Bonzini
  2025-09-08 10:12 ` [PATCH 01/19] target/ppc: limit cpu_interrupt_exittb to system emulation Paolo Bonzini
                   ` (18 more replies)
  0 siblings, 19 replies; 22+ messages in thread
From: Paolo Bonzini @ 2025-09-08 10:12 UTC (permalink / raw)
  To: qemu-devel

cpu->exit_request is used to kick vCPU threads into qemu_wait_io_event().
The code that handles the signaling of cpu->exit_request is messy, mostly
due to no one ever taking a look at it as a whole.  In fact already in commit
4b8523ee896 ("kvm: First step to push iothread lock out of inner run loop",
2015-07-01), the read of cpu->exit_request was placed outside the BQL
critical section without much attention to ordering; and it only got
worse from that point, in no small part due to a young and naive me.

This series is complementary to the cpu->interrupt_request cleanups
that Igor did in "memory: reintroduce BQL-free fine-grained PIO/MMIO"
(https://lore.kernel.org/qemu-devel/20250808120137.2208800-1-imammedo@redhat.com/T/),
and in fact includes some extra changes to interrupt_request at the
beginning.

Paolo

Paolo Bonzini (19):
  target/ppc: limit cpu_interrupt_exittb to system emulation
  target/sparc: limit cpu_check_irqs to system emulation
  target/i386: limit a20 to system emulation
  target-arm: remove uses of cpu_interrupt() for user-mode emulation
  user-exec: remove cpu_interrupt() stub
  treewide: clear bits of cs->interrupt_request with cpu_reset_interrupt()
  cpu-common: use atomic access for interrupt_request
  cpus: document that qemu_cpu_kick() can be used for BQL-less operation
  accel: use store_release/load_acquire for cross-thread exit_request
  accel: use atomic accesses for exit_request
  accel/tcg: create a thread-kick function for TCG
  accel/tcg: inline cpu_exit()
  cpus: remove TCG-ism from cpu_exit()
  cpus: properly kick CPUs out of inner execution loop
  treewide: rename qemu_wait_io_event/qemu_wait_io_event_common
  bsd-user, linux-user: introduce qemu_process_cpu_events
  cpus: clear exit_request in qemu_process_cpu_events
  accel: make all calls to qemu_process_cpu_events look the same
  tcg/user: do not set exit_request gratuitously

v2->v3:
- [accel: use store_release/load_acquire for cross-thread exit_request]
  improve comments for memory barriers, match rr_kick_next_cpu() more
  accurately

- [cpus: properly kick CPUs out of inner execution loop]
  fix comment

- [treewide: rename qemu_wait_io_event/qemu_wait_io_event_common]
  new patch; new names used throughout in patches 16-19

 docs/devel/tcg-icount.rst           |   2 +-
 accel/tcg/tcg-accel-ops-mttcg.h     |   3 -
 accel/tcg/tcg-accel-ops.h           |   1 +
 bsd-user/aarch64/target_arch_cpu.h  |   2 +-
 bsd-user/arm/target_arch_cpu.h      |   2 +-
 bsd-user/i386/target_arch_cpu.h     |   2 +-
 bsd-user/riscv/target_arch_cpu.h    |   2 +-
 bsd-user/x86_64/target_arch_cpu.h   |   2 +-
 include/hw/core/cpu.h               |  22 +-
 include/system/cpus.h               |   3 +-
 target/arm/internals.h              |   5 +
 accel/dummy-cpus.c                  |   2 +-
 accel/hvf/hvf-accel-ops.c           |   2 +-
 accel/kvm/kvm-accel-ops.c           |   3 +-
 accel/kvm/kvm-all.c                 |  23 +-
 accel/tcg/cpu-exec.c                |  34 ++-
 accel/tcg/tcg-accel-ops-mttcg.c     |  12 +-
 accel/tcg/tcg-accel-ops-rr.c        |  55 ++--
 accel/tcg/tcg-accel-ops.c           |   4 +-
 accel/tcg/user-exec.c               |  11 +-
 bsd-user/main.c                     |   5 -
 cpu-common.c                        |   3 +-
 hw/core/cpu-common.c                |  19 +-
 hw/core/cpu-system.c                |   2 +-
 hw/ppc/ppc.c                        |   2 +
 hw/ppc/spapr_hcall.c                |   7 +-
 hw/ppc/spapr_rtas.c                 |   2 +-
 linux-user/aarch64/cpu_loop.c       |   2 +-
 linux-user/alpha/cpu_loop.c         |   2 +-
 linux-user/arm/cpu_loop.c           |   2 +-
 linux-user/hexagon/cpu_loop.c       |   2 +-
 linux-user/hppa/cpu_loop.c          |   2 +-
 linux-user/i386/cpu_loop.c          |   2 +-
 linux-user/loongarch64/cpu_loop.c   |   2 +-
 linux-user/m68k/cpu_loop.c          |   2 +-
 linux-user/main.c                   |   5 -
 linux-user/microblaze/cpu_loop.c    |   2 +-
 linux-user/mips/cpu_loop.c          |   2 +-
 linux-user/openrisc/cpu_loop.c      |   2 +-
 linux-user/ppc/cpu_loop.c           |   2 +-
 linux-user/riscv/cpu_loop.c         |   2 +-
 linux-user/s390x/cpu_loop.c         |   2 +-
 linux-user/sh4/cpu_loop.c           |   2 +-
 linux-user/sparc/cpu_loop.c         |   2 +-
 linux-user/xtensa/cpu_loop.c        |   2 +-
 replay/replay-events.c              |   3 +-
 system/cpu-timers.c                 |   6 +-
 system/cpus.c                       |  15 +-
 target/arm/cpu-irq.c                | 381 ++++++++++++++++++++++++++++
 target/arm/cpu.c                    | 370 ---------------------------
 target/arm/el2-stubs.c              |  37 +++
 target/arm/helper.c                 |   4 +
 target/arm/tcg/mte_helper.c         |   2 +-
 target/avr/helper.c                 |   4 +-
 target/i386/helper.c                |   2 +
 target/i386/hvf/x86hvf.c            |   8 +-
 target/i386/kvm/hyperv.c            |   1 -
 target/i386/kvm/kvm.c               |  20 +-
 target/i386/nvmm/nvmm-accel-ops.c   |   8 +-
 target/i386/nvmm/nvmm-all.c         |  19 +-
 target/i386/tcg/system/seg_helper.c |  13 +-
 target/i386/tcg/system/svm_helper.c |   2 +-
 target/i386/whpx/whpx-accel-ops.c   |   6 +-
 target/i386/whpx/whpx-all.c         |  23 +-
 target/openrisc/sys_helper.c        |   2 +-
 target/ppc/helper_regs.c            |   2 +
 target/rx/helper.c                  |   4 +-
 target/s390x/tcg/excp_helper.c      |   2 +-
 target/sparc/int32_helper.c         |   2 +
 target/sparc/int64_helper.c         |   2 +
 target/arm/meson.build              |   2 +
 71 files changed, 645 insertions(+), 566 deletions(-)
 create mode 100644 target/arm/cpu-irq.c
 create mode 100644 target/arm/el2-stubs.c

-- 
2.51.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2025-09-10  7:15 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-08 10:12 [PATCH v3 00/19] accel, cpus: clean up cpu->exit_request Paolo Bonzini
2025-09-08 10:12 ` [PATCH 01/19] target/ppc: limit cpu_interrupt_exittb to system emulation Paolo Bonzini
2025-09-08 10:12 ` [PATCH 02/19] target/sparc: limit cpu_check_irqs " Paolo Bonzini
2025-09-08 10:12 ` [PATCH 03/19] target/i386: limit a20 " Paolo Bonzini
2025-09-08 10:12 ` [PATCH 04/19] target-arm: remove uses of cpu_interrupt() for user-mode emulation Paolo Bonzini
2025-09-08 10:12 ` [PATCH 05/19] user-exec: remove cpu_interrupt() stub Paolo Bonzini
2025-09-08 10:12 ` [PATCH 06/19] treewide: clear bits of cs->interrupt_request with cpu_reset_interrupt() Paolo Bonzini
2025-09-08 10:12 ` [PATCH 07/19] cpu-common: use atomic access for interrupt_request Paolo Bonzini
2025-09-08 10:12 ` [PATCH 08/19] cpus: document that qemu_cpu_kick() can be used for BQL-less operation Paolo Bonzini
2025-09-08 10:12 ` [PATCH 09/19] accel: use store_release/load_acquire for cross-thread exit_request Paolo Bonzini
2025-09-08 10:12 ` [PATCH 10/19] accel: use atomic accesses for exit_request Paolo Bonzini
2025-09-08 10:12 ` [PATCH 11/19] accel/tcg: create a thread-kick function for TCG Paolo Bonzini
2025-09-08 10:12 ` [PATCH 12/19] accel/tcg: inline cpu_exit() Paolo Bonzini
2025-09-08 10:12 ` [PATCH 13/19] cpus: remove TCG-ism from cpu_exit() Paolo Bonzini
2025-09-08 10:12 ` [PATCH 14/19] cpus: properly kick CPUs out of inner execution loop Paolo Bonzini
2025-09-10  7:13   ` Richard Henderson
2025-09-08 10:12 ` [PATCH 15/19] treewide: rename qemu_wait_io_event/qemu_wait_io_event_common Paolo Bonzini
2025-09-10  7:14   ` Richard Henderson
2025-09-08 10:12 ` [PATCH 16/19] bsd-user, linux-user: introduce qemu_process_cpu_events Paolo Bonzini
2025-09-08 10:12 ` [PATCH 17/19] cpus: clear exit_request in qemu_process_cpu_events Paolo Bonzini
2025-09-08 10:12 ` [PATCH 18/19] accel: make all calls to qemu_process_cpu_events look the same Paolo Bonzini
2025-09-08 10:12 ` [PATCH 19/19] tcg/user: do not set exit_request gratuitously Paolo Bonzini

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).