qemu-e2k/accel
Jamie Iles 83ecdb18eb accel/tcg/tcg-accel-ops-rr: ensure fairness with icount
The round-robin scheduler will iterate over the CPU list with an
assigned budget until the next timer expiry and may exit early because
of a TB exit.  This is fine under normal operation but with icount
enabled and SMP it is possible for a CPU to be starved of run time and
the system live-locks.

For example, booting a riscv64 platform with '-icount
shift=0,align=off,sleep=on -smp 2' we observe a livelock once the kernel
has timers enabled and starts performing TLB shootdowns.  In this case
we have CPU 0 in M-mode with interrupts disabled sending an IPI to CPU
1.  As we enter the TCG loop, we assign the icount budget to next timer
interrupt to CPU 0 and begin executing where the guest is sat in a busy
loop exhausting all of the budget before we try to execute CPU 1 which
is the target of the IPI but CPU 1 is left with no budget with which to
execute and the process repeats.

We try here to add some fairness by splitting the budget across all of
the CPUs on the thread fairly before entering each one.  The CPU count
is cached on CPU list generation ID to avoid iterating the list on each
loop iteration.  With this change it is possible to boot an SMP rv64
guest with icount enabled and no hangs.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Jamie Iles <quic_jiles@quicinc.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230427020925.51003-3-quic_jiles@quicinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2023-05-11 09:53:41 +01:00
..
hvf Fix 'writeable' typos 2022-06-08 19:38:47 +01:00
kvm kvm: dirty-ring: Fix race with vcpu creation 2023-04-04 18:46:46 +02:00
qtest accel/qtest: Support qtest accelerator for Windows 2022-10-28 11:17:12 +02:00
stubs includes: move tb_flush into its own header 2023-03-07 17:06:33 +00:00
tcg accel/tcg/tcg-accel-ops-rr: ensure fairness with icount 2023-05-11 09:53:41 +01:00
xen accel/xen: Fix DM state change notification in dm_restrict mode 2023-03-23 09:56:54 +00:00
Kconfig
accel-blocker.c accel: introduce accelerator blocker API 2023-01-11 09:59:39 +01:00
accel-common.c gdbstub: move sstep flags probing into AccelClass 2022-10-06 11:53:41 +01:00
accel-softmmu.c *: Add missing includes of qemu/error-report.h 2023-03-22 15:06:57 +00:00
accel-softmmu.h
accel-user.c
dummy-cpus.c accel/qtest: Support qtest accelerator for Windows 2022-10-28 11:17:12 +02:00
meson.build accel: introduce accelerator blocker API 2023-01-11 09:59:39 +01:00