Skip to content

accel, cpus: clean up cpu->exit_request

Paolo Bonzini qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest19 patches 6 repliesIn review
  2. v218 patches 39 repliesSuperseded
  3. v18 patches 22 repliesSuperseded

Changes in v3 from the cover letter

- [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

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/19target/ppc: limit cpu_interrupt_exittb to system emulationtarget/ppc/helper_regs.c+2 -00 replies
2/19target/sparc: limit cpu_check_irqs to system emulationtarget/sparc/int32_helper.c target/sparc/int64_helper.c+4 -00 replies
3/19target/i386: limit a20 to system emulationtarget/i386/helper.c+2 -00 replies
4/19target-arm: remove uses of cpu_interrupt() for user-mode emulationtarget/arm/cpu-irq.c target/arm/cpu.c target/arm/el2-stubs.c +3 more+429 -3700 replies
5/19user-exec: remove cpu_interrupt() stubaccel/tcg/user-exec.c+0 -50 replies
6/19treewide: clear bits of cs->interrupt_request with cpu_reset_interrupt()accel/tcg/cpu-exec.c hw/core/cpu-system.c target/avr/helper.c +9 more+39 -400 replies
7/19cpu-common: use atomic access for interrupt_requesthw/core/cpu-common.c include/hw/core/cpu.h system/cpus.c+2 -140 replies
8/19cpus: document that qemu_cpu_kick() can be used for BQL-less operationinclude/hw/core/cpu.h+2 -10 replies
9/19accel: use store_release/load_acquire for cross-thread exit_requestaccel/kvm/kvm-all.c accel/tcg/cpu-exec.c accel/tcg/tcg-accel-ops-rr.c +3 more+29 -190 replies
10/19accel: use atomic accesses for exit_requestaccel/kvm/kvm-all.c accel/tcg/tcg-accel-ops-mttcg.c accel/tcg/tcg-accel-ops-rr.c +6 more+24 -150 replies
11/19accel/tcg: create a thread-kick function for TCGaccel/tcg/cpu-exec.c accel/tcg/tcg-accel-ops-mttcg.c accel/tcg/tcg-accel-ops-mttcg.h +7 more+16 -210 replies
12/19accel/tcg: inline cpu_exit()accel/tcg/cpu-exec.c+12 -20 replies
13/19cpus: remove TCG-ism from cpu_exit()hw/core/cpu-common.c+1 -30 replies
14/19cpus: properly kick CPUs out of inner execution loopcpu-common.c hw/ppc/ppc.c hw/ppc/spapr_hcall.c +6 more+17 -141 reply
15/19treewide: rename qemu_wait_io_event/qemu_wait_io_event_commonaccel/dummy-cpus.c accel/hvf/hvf-accel-ops.c accel/kvm/kvm-accel-ops.c +8 more+15 -151 reply
16/19bsd-user, linux-user: introduce qemu_process_cpu_eventsaccel/tcg/user-exec.c bsd-user/aarch64/target_arch_cpu.h bsd-user/arm/target_arch_cpu.h +22 more+36 -230 replies
17/19cpus: clear exit_request in qemu_process_cpu_eventsaccel/kvm/kvm-all.c accel/tcg/cpu-exec.c accel/tcg/tcg-accel-ops-rr.c +5 more+9 -110 replies
18/19accel: make all calls to qemu_process_cpu_events look the sameaccel/dummy-cpus.c accel/hvf/hvf-accel-ops.c accel/kvm/kvm-accel-ops.c +4 more+30 -390 replies
19/19tcg/user: do not set exit_request gratuitouslyaccel/tcg/cpu-exec.c+2 -04 replies

Reviews trailers per patch

All 19 patches have a Reviewed-by or Acked-by.

PatchIgor MammedovRichard HendersonPhilippe Mathieu-DaudéPeter Xu
1/19R-b R-b
2/19R-b R-b
3/19R-b R-b R-b
4/19R-b
5/19R-b R-b
6/19R-b R-b R-b
7/19R-b R-b R-b
8/19R-b
9/19R-b R-b R-b
10/19R-b R-b R-b R-b
11/19R-b R-b R-b
12/19R-b R-b
13/19R-b R-b R-b
14/19R-b
15/19R-b
16/19R-b R-b
17/19R-b R-b
18/19R-b R-b
19/19R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v3 thread

Cover letter [PATCH v3 00/19] accel, cpus: clean up cpu->exit_request

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/[email protected]/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
Signature · 1 line
2.51.0