qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/18] accel, cpus: clean up cpu->exit_request
@ 2025-08-29 15:28 Paolo Bonzini
  2025-08-29 15:28 ` [PATCH 01/18] target/ppc: limit cpu_interrupt_exittb to system emulation Paolo Bonzini
                   ` (17 more replies)
  0 siblings, 18 replies; 58+ messages in thread
From: Paolo Bonzini @ 2025-08-29 15:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: peterx, richard.henderson, imammedo

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.

v1->v2:
- new patches 1-8, leftovers from Igor's own cleanup
- patch 9: use "true" instead of 1, editorial cleanups
- dropped "accel/hvf: check exit_request before running the vCPU"
- patch 10: add more comments, use "true" instead of 1
- patch 12: use accel/tcg/tcg-accel-ops.h for prototype, split out
  patch 12 ("accel/tcg: inline cpu_exit()"), place user-mode
  emulation version of qemu_cpu_kick() in accel/tcg/user-exec.c
- patch 14: fix compilation errors
- patch 15: new, fixes infinite loops in user-mode emulation
- patches 16-17: split in two parts
- patch 18: improve commit message

Paolo Bonzini (18):
  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
  bsd-user, linux-user: introduce qemu_wait_io_event
  cpus: clear exit_request in qemu_wait_io_event
  accel: make all calls to qemu_wait_io_event look the same
  tcg/user: do not set exit_request gratuitously

 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               |   1 -
 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        |  42 +--
 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                       |   9 +-
 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, 631 insertions(+), 559 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] 58+ messages in thread

end of thread, other threads:[~2025-09-01 13:33 UTC | newest]

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

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