per-CPU locks
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v7 Latest73 patches 4 repliesIn review
- v673 patches 35 repliesSuperseded
- v573 patches 8 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v4 RFC | 71 patches | 101 replies | Superseded | |
| v3 RFC | 56 patches | 61 replies | Superseded |
Changes in v7 from the cover letter
- Rebase on master
- Add a cpu_halted_set call to arm code that wasn't there in v6
- Add R-b's and Ack's.
- Add comment to patch 3's log to explain why the bitmap is added there, even though it only gains a user at the end of the series.
- Fix "prevent deadlock" comments before assertions; use "enforce locking order" instead, which is more accurate.
- Add a few more comments, as suggested by Alex.
Patches in v7 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/73 | cpu: convert queued work to a QSIMPLEQcpus-common.c cpus.c include/ +1 more | +24 | 0 replies | |
| 2/73 | cpu: rename cpu->work_mutex to cpu->lockcpus-common.c cpus.c include/ +1 more | +14 | 0 replies | |
| 3/73 | cpu: introduce cpu_mutex_lock/unlockcpus.c include/ stubs/ +1 more | +108 | 0 replies | |
| 4/73 | cpu: make qemu_work_cond per-cpucpus-common.c cpus.c include/ +1 more | +63 | 0 replies | |
| 5/73 | cpu: move run_on_cpu to cpus-commoncpus-common.c cpus.c include/ | +1 | 0 replies | |
| 6/73 | cpu: introduce process_queued_cpu_work_lockedcpus-common.c | +11 | 0 replies | |
| 7/73 | cpu: make per-CPU locks an alias of the BQL in TCG rr modecpus-common.c cpus.c include/ +2 more | +86 | 0 replies | |
| 8/73 | tcg-runtime: define helper_cpu_halted_setaccel/ accel/ | +9 | 0 replies | |
| 9/73 | ppc: convert to helper_cpu_halted_settarget/ | +2 | 0 replies | |
| 10/73 | cris: convert to helper_cpu_halted_settarget/ | +3 | 0 replies | |
| 11/73 | hppa: convert to helper_cpu_halted_settarget/ | +1 | 0 replies | |
| 12/73 | m68k: convert to helper_cpu_halted_settarget/ | +4 | 0 replies | |
| 13/73 | alpha: convert to helper_cpu_halted_settarget/ | +2 | 0 replies | |
| 14/73 | microblaze: convert to helper_cpu_halted_settarget/ | +1 | 0 replies | |
| 15/73 | cpu: define cpu_halted helpersinclude/ | +24 | 0 replies | |
| 16/73 | tcg-runtime: convert to cpu_halted_setaccel/ | +1 | 0 replies | |
| 17/73 | arm: convert to cpu_haltedhw/ hw/ hw/ +3 more | +9 | 0 replies | |
| 18/73 | ppc: convert to cpu_haltedhw/ hw/ hw/ +7 more | +27 | 0 replies | |
| 19/73 | sh4: convert to cpu_haltedtarget/ | +1 | 0 replies | |
| 20/73 | i386: convert to cpu_haltedtarget/ target/ target/ +6 more | +19 | 0 replies | |
| 21/73 | lm32: convert to cpu_haltedtarget/ | +2 | 0 replies | |
| 22/73 | m68k: convert to cpu_haltedtarget/ | +1 | 0 replies | |
| 23/73 | mips: convert to cpu_haltedhw/ hw/ target/ +2 more | +10 | 0 replies | |
| 24/73 | riscv: convert to cpu_haltedtarget/ | +1 | 0 replies | |
| 25/73 | s390x: convert to cpu_haltedhw/ target/ target/ +2 more | +22 | 0 replies | |
| 26/73 | sparc: convert to cpu_haltedhw/ hw/ hw/ +1 more | +8 | 0 replies | |
| 27/73 | xtensa: convert to cpu_haltedtarget/ target/ target/ | +3 | 0 replies | |
| 28/73 | gdbstub: convert to cpu_haltedgdbstub.c | +2 | 0 replies | |
| 29/73 | openrisc: convert to cpu_haltedtarget/ | +1 | 0 replies | |
| 30/73 | cpu-exec: convert to cpu_haltedaccel/ | +21 | 0 replies | |
| 31/73 | cpu: convert to cpu_haltedaccel/ cpus.c qom/ | +6 | 0 replies | |
| 32/73 | cpu: define cpu_interrupt_request helpersinclude/ qom/ | +58 | 0 replies | |
| 33/73 | ppc: use cpu_reset_interrupttarget/ | +1 | 0 replies | |
| 34/73 | exec: use cpu_reset_interruptexec.c | +1 | 0 replies | |
| 35/73 | i386: use cpu_reset_interrupttarget/ target/ target/ +3 more | +25 | 0 replies | |
| 36/73 | s390x: use cpu_reset_interrupttarget/ | +1 | 0 replies | |
| 37/73 | openrisc: use cpu_reset_interrupttarget/ | +1 | 0 replies | |
| 38/73 | arm: convert to cpu_interrupt_requesttarget/ target/ target/ | +11 | 0 replies | |
| 39/73 | i386: convert to cpu_interrupt_requesttarget/ target/ target/ | +5 | 0 replies | |
| 40/73 | i386/kvm: convert to cpu_interrupt_requesttarget/ | +35 | 0 replies | |
| 41/73 | i386/hax-all: convert to cpu_interrupt_requesttarget/ | +17 | 0 replies | |
| 42/73 | i386/whpx-all: convert to cpu_interrupt_requesttarget/ | +24 | 0 replies | |
| 43/73 | i386/hvf: convert to cpu_request_interrupttarget/ target/ | +20 | 0 replies | |
| 44/73 | ppc: convert to cpu_interrupt_requesthw/ target/ target/ | +10 | 0 replies | |
| 45/73 | sh4: convert to cpu_interrupt_requesttarget/ target/ | +2 | 0 replies | |
| 46/73 | cris: convert to cpu_interrupt_requesttarget/ target/ | +4 | 0 replies | |
| 47/73 | hppa: convert to cpu_interrupt_requesttarget/ | +1 | 0 replies | |
| 48/73 | lm32: convert to cpu_interrupt_requesttarget/ | +1 | 0 replies | |
| 49/73 | m68k: convert to cpu_interrupt_requesttarget/ | +1 | 0 replies | |
| 50/73 | mips: convert to cpu_interrupt_requesttarget/ target/ | +5 | 0 replies | |
| 51/73 | nios: convert to cpu_interrupt_requesttarget/ | +1 | 0 replies | |
| 52/73 | s390x: convert to cpu_interrupt_requesthw/ target/ | +2 | 0 replies | |
| 53/73 | alpha: convert to cpu_interrupt_requesttarget/ | +4 | 0 replies | |
| 54/73 | moxie: convert to cpu_interrupt_requesttarget/ | +1 | 0 replies | |
| 55/73 | sparc: convert to cpu_interrupt_requesthw/ target/ | +3 | 0 replies | |
| 56/73 | openrisc: convert to cpu_interrupt_requesthw/ target/ | +3 | 0 replies | |
| 57/73 | unicore32: convert to cpu_interrupt_requesttarget/ target/ | +2 | 0 replies | |
| 58/73 | microblaze: convert to cpu_interrupt_requesttarget/ | +1 | 0 replies | |
| 59/73 | accel/tcg: convert to cpu_interrupt_requestaccel/ accel/ accel/ | +18 | 0 replies | |
| 60/73 | cpu: convert to interrupt_requestqom/ | +2 | 0 replies | |
| 61/73 | cpu: call .cpu_has_work with the CPU lock heldinclude/ | +10 | 0 replies | |
| 62/73 | cpu: introduce cpu_has_work_with_iothread_lockinclude/ | +34 | 0 replies | |
| 63/73 | ppc: convert to cpu_has_work_with_iothread_locktarget/ | +12 | 0 replies | |
| 64/73 | mips: convert to cpu_has_work_with_iothread_locktarget/ | +3 | 0 replies | |
| 65/73 | s390x: convert to cpu_has_work_with_iothread_locktarget/ | +3 | 0 replies | |
| 66/73 | riscv: convert to cpu_has_work_with_iothread_locktarget/ | +4 | 0 replies | |
| 67/73 | sparc: convert to cpu_has_work_with_iothread_locktarget/ | +3 | 0 replies | |
| 68/73 | xtensa: convert to cpu_has_work_with_iothread_locktarget/ | +3 | 0 replies | |
| 69/73 | cpu: rename all_cpu_threads_idle to qemu_tcg_rr_all_cpu_threads_idlecpus.c | +6 | 0 replies | |
| 70/73 | cpu: protect CPU state with cpu->lock instead of the BQLcpus.c include/ qom/ | +225 | 0 replies | |
| 71/73 | cpus-common: release BQL earlier in run_on_cpucpus-common.c | +5 | 0 replies | |
| 72/73 | cpu: add async_run_on_cpu_no_bqlcpus-common.c include/ | +48 | 0 replies | |
| 73/73 | cputlb: queue async flush jobs without the BQLaccel/ | +5 | 0 replies |
Reviews trailers per patch
All 73 patches have a Reviewed-by or Acked-by.
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 10 reviewers.
Cover letter [PATCH v7 00/73] per-CPU locks
v6: https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg07650.html
All patches in the series have reviews now. Thanks everyone!
I've tested all patches with `make check-qtest -j' for all targets. The series is checkpatch-clean (just some warnings about __COVERITY__).
You can fetch the series from:
https://github.com/cota/qemu/tree/cpu-lock-v7
---v6->v7:
- Rebase on master
- Add a cpu_halted_set call to arm code that wasn't there in v6
- Add R-b's and Ack's.
- Add comment to patch 3's log to explain why the bitmap is added there, even though it only gains a user at the end of the series.
- Fix "prevent deadlock" comments before assertions; use "enforce locking order" instead, which is more accurate.
- Add a few more comments, as suggested by Alex.
v6->v7 diff (before rebase) below.
Thanks,
Emilio
---
accel/tcg/cpu-exec.c +1 -1
@@ -435,7 +435,7 @@ static inline bool cpu_handle_halt_locked(CPUState *cpu) && replay_interrupt()) {X86CPU *x86_cpu =X86_CPU (cpu); -/* prevent deadlock; cpu_mutex must be acquired _after_ the BQL */ +/* locking order: cpu_mutex must be acquired _after_ the BQL */ cpu_mutex_unlock (cpu);qemu_mutex_lock_iothread ();cpu_mutex_lock (cpu);
cpus.c +1 -1
@@ -2062,7 +2062,7 @@ void qemu_mutex_lock_iothread_impl(const char *file, int line) {QemuMutexLockFunc bql_lock =atomic_read (&qemu_bql_mutex_lock_func); -/* prevent deadlock with CPU mutex */ +/* enforce locking order */ g_assert (no_cpu_mutex_locked ());g_assert (!qemu_mutex_iothread_locked ());
include/qom/cpu.h +3 -1
@@ -322,7 +322,8 @@ struct qemu_work_item;* @mem_io_pc: Host Program Counter at which the memory was accessed. * @mem_io_vaddr: Target virtual address at which the memory was accessed. * @kvm_fd: vCPU file descriptor for KVM. -* @lock: Lock to prevent multiple access to per-CPU fields. +* @lock: Lock to prevent multiple access to per-CPU fields. Must be acquired +* after the BQL. * @cond: Condition variable for per-CPU events. * @work_list: List of pending asynchronous work. * @halted: Nonzero if the CPU is in suspended state.
@@ -804,6 +805,7 @@ static inline bool cpu_has_work(CPUState *cpu)bool (*func)(CPUState *cpu);bool ret; +/* some targets require us to hold the BQL when checking for work */ if (cc->has_work_with_iothread_lock) {if (qemu_mutex_iothread_locked ()) { func = cc->has_work_with_iothread_lock;
target/i386/kvm.c +4 -0
@@ -3216,6 +3216,10 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run)qemu_mutex_lock_iothread (); } +/* +* We might have cleared some bits in cpu->interrupt_request since reading +* it; read it again. +*/ interrupt_request =cpu_interrupt_request (cpu);/* Force the VCPU out of its inner loop to process any INIT requests