Skip to content

per-CPU locks

Robert Foley kvm qemu-arm qemu-devel qemu-riscv 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v10 Latest73 patches 0 repliesNew
  2. v974 patches 4 repliesSuperseded
  3. v874 patches 25 repliesSuperseded

Changes in v10 from the cover letter

- Fixed one case in cpu_throttle_thread, where we were using qemu_global_mutex instead of cpu->lock for the halt_cond.
- Changed qemu_cpu_kick() to ensure we are under the CPU lock so we do not miss a notification.
- Added a few more reviewed-bys.

Patches in v10 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/73cpu: rename cpu->work_mutex to cpu->lockcpus-common.c cpus.c hw/core/cpu.c +1 more+15 -130 replies
2/73cpu: introduce cpu_mutex_lock/unlockcpus.c hw/core/machine.c include/hw/core/cpu.h +2 more+101 -20 replies
3/73cpu: make qemu_work_cond per-cpucpus-common.c cpus.c hw/core/cpu.c +1 more+63 -180 replies
4/73cpu: move run_on_cpu to cpus-commoncpus-common.c cpus.c include/hw/core/cpu.h+1 -160 replies
5/73cpu: introduce process_queued_cpu_work_lockedcpus-common.c+11 -60 replies
6/73cpu: make per-CPU locks an alias of the BQL in TCG rr modecpus-common.c cpus.c hw/core/cpu.c +2 more+110 -130 replies
7/73tcg-runtime: define helper_cpu_halted_setaccel/tcg/tcg-runtime.c accel/tcg/tcg-runtime.h+9 -00 replies
8/73ppc: convert to helper_cpu_halted_settarget/ppc/translate.c+2 -40 replies
9/73cris: convert to helper_cpu_halted_settarget/cris/translate.c+3 -20 replies
10/73hppa: convert to helper_cpu_halted_settarget/hppa/translate.c+1 -20 replies
11/73m68k: convert to helper_cpu_halted_settarget/m68k/translate.c+4 -50 replies
12/73alpha: convert to helper_cpu_halted_settarget/alpha/translate.c+2 -40 replies
13/73microblaze: convert to helper_cpu_halted_settarget/microblaze/translate.c+1 -30 replies
14/73cpu: define cpu_halted helpersinclude/hw/core/cpu.h+24 -00 replies
15/73tcg-runtime: convert to cpu_halted_setaccel/tcg/tcg-runtime.c+1 -10 replies
16/73hw/semihosting: convert to cpu_halted_sethw/semihosting/console.c+2 -20 replies
17/73arm: convert to cpu_haltedhw/arm/omap1.c hw/arm/pxa2xx_gpio.c hw/arm/pxa2xx_pic.c +3 more+9 -90 replies
18/73ppc: convert to cpu_haltedhw/ppc/e500.c hw/ppc/ppc.c hw/ppc/ppce500_spin.c +7 more+34 -300 replies
19/73sh4: convert to cpu_haltedtarget/sh4/op_helper.c+1 -10 replies
20/73i386: convert to cpu_haltedtarget/i386/cpu.c target/i386/cpu.h target/i386/hax-all.c +6 more+20 -200 replies
21/73lm32: convert to cpu_haltedtarget/lm32/op_helper.c+2 -20 replies
22/73m68k: convert to cpu_haltedtarget/m68k/op_helper.c+1 -10 replies
23/73mips: convert to cpu_haltedhw/mips/cps.c hw/misc/mips_itu.c target/mips/cp0_helper.c +3 more+10 -100 replies
24/73riscv: convert to cpu_haltedtarget/riscv/op_helper.c+1 -10 replies
25/73s390x: convert to cpu_haltedhw/intc/s390_flic.c target/s390x/cpu.c target/s390x/excp_helper.c +2 more+22 -140 replies
26/73sparc: convert to cpu_haltedhw/sparc/leon3.c hw/sparc/sun4m.c hw/sparc64/sparc64.c +1 more+8 -80 replies
27/73xtensa: convert to cpu_haltedtarget/xtensa/cpu.c target/xtensa/exc_helper.c target/xtensa/helper.c+3 -30 replies
28/73gdbstub: convert to cpu_haltedgdbstub.c+2 -20 replies
29/73openrisc: convert to cpu_haltedtarget/openrisc/sys_helper.c+1 -10 replies
30/73cpu-exec: convert to cpu_haltedaccel/tcg/cpu-exec.c+21 -40 replies
31/73cpu: convert to cpu_haltedaccel/tcg/cpu-exec.c cpus.c hw/core/cpu.c +1 more+5 -50 replies
32/73cpu: define cpu_interrupt_request helpershw/core/cpu.c include/hw/core/cpu.h+58 -60 replies
33/73ppc: use cpu_reset_interrupttarget/ppc/excp_helper.c+1 -10 replies
34/73exec: use cpu_reset_interruptexec.c+1 -10 replies
35/73i386: use cpu_reset_interrupttarget/i386/hax-all.c target/i386/hvf/x86hvf.c target/i386/kvm.c +3 more+25 -260 replies
36/73s390x: use cpu_reset_interrupttarget/s390x/excp_helper.c+1 -10 replies
37/73openrisc: use cpu_reset_interrupttarget/openrisc/sys_helper.c+1 -10 replies
38/73arm: convert to cpu_interrupt_requesttarget/arm/cpu.c target/arm/helper.c target/arm/machine.c+11 -130 replies
39/73i386: convert to cpu_interrupt_requesttarget/i386/cpu.c target/i386/helper.c target/i386/svm_helper.c+5 -50 replies
40/73i386/kvm: convert to cpu_interrupt_requesttarget/i386/kvm.c+35 -230 replies
41/73i386/hax-all: convert to cpu_interrupt_requesttarget/i386/hax-all.c+19 -150 replies
42/73i386/whpx-all: convert to cpu_interrupt_requesttarget/i386/whpx-all.c+24 -170 replies
43/73i386/hvf: convert to cpu_request_interrupttarget/i386/hvf/hvf.c target/i386/hvf/x86hvf.c+20 -140 replies
44/73ppc: convert to cpu_interrupt_requesthw/ppc/ppc.c target/i386/hvf/x86hvf.c target/ppc/kvm.c +1 more+9 -100 replies
45/73sh4: convert to cpu_interrupt_requesttarget/sh4/cpu.c target/sh4/helper.c+2 -20 replies
46/73cris: convert to cpu_interrupt_requesttarget/cris/cpu.c target/cris/helper.c+3 -30 replies
47/73hppa: convert to cpu_interrupt_requesttarget/hppa/cpu.c+1 -10 replies
48/73lm32: convert to cpu_interrupt_requesttarget/lm32/cpu.c+1 -10 replies
49/73m68k: convert to cpu_interrupt_requesttarget/m68k/cpu.c+1 -10 replies
50/73mips: convert to cpu_interrupt_requesttarget/mips/cpu.c target/mips/kvm.c+5 -40 replies
51/73nios: convert to cpu_interrupt_requesttarget/nios2/cpu.c+1 -10 replies
52/73s390x: convert to cpu_interrupt_requesthw/intc/s390_flic.c target/s390x/cpu.c+2 -20 replies
53/73alpha: convert to cpu_interrupt_requesttarget/alpha/cpu.c+4 -40 replies
54/73moxie: convert to cpu_interrupt_requesttarget/moxie/cpu.c+1 -10 replies
55/73sparc: convert to cpu_interrupt_requesthw/sparc64/sparc64.c target/sparc/cpu.c+3 -30 replies
56/73openrisc: convert to cpu_interrupt_requesthw/openrisc/cputimer.c target/openrisc/cpu.c+3 -30 replies
57/73unicore32: convert to cpu_interrupt_requesttarget/unicore32/cpu.c target/unicore32/softmmu.c+2 -20 replies
58/73microblaze: convert to cpu_interrupt_requesttarget/microblaze/cpu.c+1 -10 replies
59/73accel/tcg: convert to cpu_interrupt_requestaccel/tcg/cpu-exec.c accel/tcg/tcg-all.c accel/tcg/translate-all.c+18 -110 replies
60/73cpu: convert to interrupt_requesthw/core/cpu.c+2 -20 replies
61/73cpu: call .cpu_has_work with the CPU lock heldinclude/hw/core/cpu.h+10 -20 replies
62/73cpu: introduce cpu_has_work_with_iothread_lockinclude/hw/core/cpu.h+34 -30 replies
63/73ppc: convert to cpu_has_work_with_iothread_locktarget/ppc/translate_init.inc.c+14 -50 replies
64/73mips: convert to cpu_has_work_with_iothread_locktarget/mips/cpu.c+3 -10 replies
65/73s390x: convert to cpu_has_work_with_iothread_locktarget/s390x/cpu.c+3 -10 replies
66/73riscv: convert to cpu_has_work_with_iothread_locktarget/riscv/cpu.c+4 -10 replies
67/73sparc: convert to cpu_has_work_with_iothread_locktarget/sparc/cpu.c+3 -10 replies
68/73xtensa: convert to cpu_has_work_with_iothread_locktarget/xtensa/cpu.c+3 -10 replies
69/73cpu: rename all_cpu_threads_idle to qemu_tcg_rr_all_cpu_threads_idlecpus.c+6 -40 replies
70/73cpu: protect CPU state with cpu->lock instead of the BQLcpus.c hw/core/cpu.c include/hw/core/cpu.h+248 -1080 replies
71/73cpus-common: release BQL earlier in run_on_cpucpus-common.c+5 -150 replies
72/73cpu: add async_run_on_cpu_no_bqlcpus-common.c include/hw/core/cpu.h+48 -50 replies
73/73cputlb: queue async flush jobs without the BQLaccel/tcg/cputlb.c+5 -50 replies

Reviews trailers per patch

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

PatchRichard HendersonAlex BennéePalmer DabbeltAlistair FrancisDavid GibsonEdgar E. IglesiasLaurent VivierMark Cave-AylandDavid HildenbrandCornelia HuckPhilippe Mathieu-Daudé
1/73R-b R-b
2/73R-b
3/73R-b R-b
4/73R-b R-b
5/73R-b R-b
6/73R-b R-b
7/73R-b R-b
8/73R-b R-b A-b
9/73R-b R-b R-b
10/73R-b R-b
11/73R-b R-b R-b
12/73R-b R-b
13/73R-b R-b R-b
14/73R-b R-b
15/73R-b R-b
16/73R-b
17/73R-b R-b
18/73R-b A-b
19/73R-b R-b
20/73R-b R-b
21/73R-b R-b
22/73R-b R-b R-b
23/73R-b R-b
24/73R-b R-b R-b
25/73R-b R-b R-b
26/73R-b R-b R-b
27/73R-b R-b
28/73R-b R-b
29/73R-b R-b
30/73R-b R-b
31/73R-b R-b
32/73R-b R-b
33/73R-b R-b A-b R-b
34/73R-b R-b
35/73R-b R-b
36/73R-b R-b R-b R-b
37/73R-b R-b R-b
38/73R-b R-b
39/73R-b R-b
40/73R-b R-b
41/73R-b R-b
42/73R-b
43/73R-b
44/73R-b A-b
45/73R-b R-b
46/73R-b R-b R-b
47/73R-b R-b
48/73R-b R-b
49/73R-b R-b
50/73R-b
51/73R-b R-b
52/73R-b R-b R-b
53/73R-b R-b
54/73R-b R-b
55/73R-b R-b R-b
56/73R-b R-b
57/73R-b R-b
58/73R-b R-b R-b
59/73R-b R-b
60/73R-b R-b
61/73R-b R-b
62/73R-b R-b
63/73R-b A-b
64/73R-b
65/73R-b R-b
66/73R-b R-b R-b
67/73R-b A-b
68/73R-b
69/73R-b R-b
70/73R-b R-b
71/73R-b R-b
72/73R-b R-b
73/73R-b R-b T-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 11 reviewers.

Read the v10 thread

Cover letter [PATCH v10 00/73] per-CPU locks

Changes for v10:
- Fixed one case in cpu_throttle_thread, where we were using qemu_global_mutex instead of cpu->lock for the halt_cond.
- Changed qemu_cpu_kick() to ensure we are under the CPU lock so we do not miss a notification.
- Added a few more reviewed-bys.

v9: https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg06289.html

Quoting an earlier patch in the series:
"For context, the goal of this series is to substitute the BQL for the per-CPU locks in many places, notably the execution loop in cpus.c. This leads to better scalability for MTTCG, since CPUs don't have to acquire a contended global lock (the BQL) every time they stop executing code.
See the last commit for some performance numbers."

Emilio G. Cota (68):
cpu: rename cpu->work_mutex to cpu->lock
cpu: introduce cpu_mutex_lock/unlock
cpu: make qemu_work_cond per-cpu
cpu: move run_on_cpu to cpus-common
cpu: introduce process_queued_cpu_work_locked
cpu: make per-CPU locks an alias of the BQL in TCG rr mode
tcg-runtime: define helper_cpu_halted_set
ppc: convert to helper_cpu_halted_set
cris: convert to helper_cpu_halted_set
hppa: convert to helper_cpu_halted_set
m68k: convert to helper_cpu_halted_set
alpha: convert to helper_cpu_halted_set
microblaze: convert to helper_cpu_halted_set
cpu: define cpu_halted helpers
tcg-runtime: convert to cpu_halted_set
arm: convert to cpu_halted
ppc: convert to cpu_halted
sh4: convert to cpu_halted
i386: convert to cpu_halted
lm32: convert to cpu_halted
m68k: convert to cpu_halted
mips: convert to cpu_halted
riscv: convert to cpu_halted
s390x: convert to cpu_halted
sparc: convert to cpu_halted
xtensa: convert to cpu_halted
gdbstub: convert to cpu_halted
openrisc: convert to cpu_halted
cpu-exec: convert to cpu_halted
cpu: convert to cpu_halted
cpu: define cpu_interrupt_request helpers
exec: use cpu_reset_interrupt
arm: convert to cpu_interrupt_request
i386: convert to cpu_interrupt_request
i386/kvm: convert to cpu_interrupt_request
i386/hax-all: convert to cpu_interrupt_request i386/whpx-all: convert to cpu_interrupt_request
i386/hvf: convert to cpu_request_interrupt
ppc: convert to cpu_interrupt_request
sh4: convert to cpu_interrupt_request
cris: convert to cpu_interrupt_request
hppa: convert to cpu_interrupt_request
lm32: convert to cpu_interrupt_request
m68k: convert to cpu_interrupt_request
mips: convert to cpu_interrupt_request
nios: convert to cpu_interrupt_request
s390x: convert to cpu_interrupt_request
alpha: convert to cpu_interrupt_request
moxie: convert to cpu_interrupt_request
sparc: convert to cpu_interrupt_request
openrisc: convert to cpu_interrupt_request
unicore32: convert to cpu_interrupt_request
microblaze: convert to cpu_interrupt_request
accel/tcg: convert to cpu_interrupt_request
cpu: convert to interrupt_request
cpu: call .cpu_has_work with the CPU lock held
cpu: introduce cpu_has_work_with_iothread_lock
ppc: convert to cpu_has_work_with_iothread_lock
mips: convert to cpu_has_work_with_iothread_lock
s390x: convert to cpu_has_work_with_iothread_lock
riscv: convert to cpu_has_work_with_iothread_lock
sparc: convert to cpu_has_work_with_iothread_lock
xtensa: convert to cpu_has_work_with_iothread_lock
cpu: rename all_cpu_threads_idle to qemu_tcg_rr_all_cpu_threads_idle
cpu: protect CPU state with cpu->lock instead of the BQL
cpus-common: release BQL earlier in run_on_cpu
cpu: add async_run_on_cpu_no_bql
cputlb: queue async flush jobs without the BQL

Paolo Bonzini (4):
ppc: use cpu_reset_interrupt
i386: use cpu_reset_interrupt
s390x: use cpu_reset_interrupt
openrisc: use cpu_reset_interrupt

Robert Foley (1):
hw/semihosting: convert to cpu_halted_set

 accel/tcg/cpu-exec.c            |  40 ++-
 accel/tcg/cputlb.c              |  10 +-
 accel/tcg/tcg-all.c             |  12 +-
 accel/tcg/tcg-runtime.c         |   7 +
 accel/tcg/tcg-runtime.h         |   2 +
 accel/tcg/translate-all.c       |   2 +-
 cpus-common.c                   | 108 ++++++--
 cpus.c                          | 456 ++++++++++++++++++++++++++------
 exec.c                          |   2 +-
 gdbstub.c                       |   4 +-
 hw/arm/omap1.c                  |   4 +-
 hw/arm/pxa2xx_gpio.c            |   2 +-
 hw/arm/pxa2xx_pic.c             |   2 +-
 hw/core/cpu.c                   |  28 +-
 hw/core/machine-qmp-cmds.c      |   2 +-
 hw/core/machine.c               |   1 +
 hw/intc/s390_flic.c             |   4 +-
 hw/mips/cps.c                   |   2 +-
 hw/misc/mips_itu.c              |   4 +-
 hw/openrisc/cputimer.c          |   2 +-
 hw/ppc/e500.c                   |   4 +-
 hw/ppc/ppc.c                    |  12 +-
 hw/ppc/ppce500_spin.c           |   6 +-
 hw/ppc/spapr_cpu_core.c         |   4 +-
 hw/ppc/spapr_hcall.c            |  14 +-
 hw/ppc/spapr_rtas.c             |   8 +-
 hw/semihosting/console.c        |   4 +-
 hw/sparc/leon3.c                |   2 +-
 hw/sparc/sun4m.c                |   8 +-
 hw/sparc64/sparc64.c            |   8 +-
 include/hw/core/cpu.h           | 196 ++++++++++++--
 stubs/Makefile.objs             |   1 +
 stubs/cpu-lock.c                |  27 ++
 target/alpha/cpu.c              |   8 +-
 target/alpha/translate.c        |   6 +-
 target/arm/arm-powerctl.c       |   6 +-
 target/arm/cpu.c                |   8 +-
 target/arm/helper.c             |  16 +-
 target/arm/machine.c            |   2 +-
 target/arm/op_helper.c          |   2 +-
 target/cris/cpu.c               |   2 +-
 target/cris/helper.c            |   4 +-
 target/cris/translate.c         |   5 +-
 target/hppa/cpu.c               |   2 +-
 target/hppa/translate.c         |   3 +-
 target/i386/cpu.c               |   4 +-
 target/i386/cpu.h               |   2 +-
 target/i386/hax-all.c           |  42 +--
 target/i386/helper.c            |   8 +-
 target/i386/hvf/hvf.c           |  12 +-
 target/i386/hvf/x86hvf.c        |  37 +--
 target/i386/kvm.c               |  82 +++---
 target/i386/misc_helper.c       |   2 +-
 target/i386/seg_helper.c        |  13 +-
 target/i386/svm_helper.c        |   6 +-
 target/i386/whpx-all.c          |  57 ++--
 target/lm32/cpu.c               |   2 +-
 target/lm32/op_helper.c         |   4 +-
 target/m68k/cpu.c               |   2 +-
 target/m68k/op_helper.c         |   2 +-
 target/m68k/translate.c         |   9 +-
 target/microblaze/cpu.c         |   2 +-
 target/microblaze/translate.c   |   4 +-
 target/mips/cp0_helper.c        |   6 +-
 target/mips/cpu.c               |  11 +-
 target/mips/kvm.c               |   4 +-
 target/mips/op_helper.c         |   2 +-
 target/mips/translate.c         |   4 +-
 target/moxie/cpu.c              |   2 +-
 target/nios2/cpu.c              |   2 +-
 target/openrisc/cpu.c           |   4 +-
 target/openrisc/sys_helper.c    |   4 +-
 target/ppc/excp_helper.c        |   6 +-
 target/ppc/helper_regs.h        |   2 +-
 target/ppc/kvm.c                |   6 +-
 target/ppc/translate.c          |   6 +-
 target/ppc/translate_init.inc.c |  41 +--
 target/riscv/cpu.c              |   5 +-
 target/riscv/op_helper.c        |   2 +-
 target/s390x/cpu.c              |  28 +-
 target/s390x/excp_helper.c      |   4 +-
 target/s390x/kvm.c              |   2 +-
 target/s390x/sigp.c             |   8 +-
 target/sh4/cpu.c                |   2 +-
 target/sh4/helper.c             |   2 +-
 target/sh4/op_helper.c          |   2 +-
 target/sparc/cpu.c              |   6 +-
 target/sparc/helper.c           |   2 +-
 target/unicore32/cpu.c          |   2 +-
 target/unicore32/softmmu.c      |   2 +-
 target/xtensa/cpu.c             |   6 +-
 target/xtensa/exc_helper.c      |   2 +-
 target/xtensa/helper.c          |   2 +-
 93 files changed, 1063 insertions(+), 456 deletions(-)
 create mode 100644 stubs/cpu-lock.c
Signature · 1 line
2.17.1