qemu-e2k/accel/tcg
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
..
atomic_common.c.inc tcg: Add tcg_gen_{non}atomic_cmpxchg_i128 2023-02-04 06:19:42 -10:00
atomic_template.h Replace config-time define HOST_WORDS_BIGENDIAN 2022-04-06 10:50:37 +02:00
cpu-exec-common.c *: Add missing includes of qemu/plugin.h 2023-03-22 15:06:57 +00:00
cpu-exec.c accel/tcg: Use one_insn_per_tb global instead of old singlestep global 2023-05-02 15:47:40 +01:00
cputlb.c accel/tcg: Fix atomic_mmu_lookup for reads 2023-05-11 09:49:25 +01:00
debuginfo.c accel/tcg: Add debuginfo support 2023-01-16 10:14:12 -10:00
debuginfo.h coroutine: Split qemu/coroutine-core.h off qemu/coroutine.h 2023-01-20 07:21:46 +01:00
internal.h accel/tcg: Use one_insn_per_tb global instead of old singlestep global 2023-05-02 15:47:40 +01:00
ldst_common.c.inc exec/memop: Adding signedness to quad definitions 2022-01-08 15:46:10 +10:00
meson.build accel/tcg: Restrict 'qapi-commands-machine.h' to system emulation 2023-02-27 22:29:01 +01:00
monitor.c accel/tcg: Report one-insn-per-tb in 'info jit', not 'info status' 2023-05-02 15:47:40 +01:00
perf.c accel/tcg: Replace TARGET_TB_PCREL with CF_PCREL 2023-03-01 07:31:44 -10:00
perf.h tcg: add perfmap and jitdump 2023-01-16 10:14:12 -10:00
plugin-gen.c tcg: Create tcg/tcg-temp-internal.h 2023-03-13 06:42:05 -07:00
plugin-helpers.h tcg: exclude non-memory effecting helpers from instrumentation 2023-02-02 11:48:20 +00:00
tb-context.h tcg: Move tb_phys_invalidate_count to tb_ctx 2021-07-09 09:38:33 -07:00
tb-hash.h include/hw/core: Create struct CPUJumpCache 2022-10-04 12:13:12 -07:00
tb-jmp-cache.h accel/tcg: Move jmp-cache CF_PCREL checks to caller 2023-03-01 07:33:03 -10:00
tb-maint.c tb-maint: do not use mb_read/mb_set 2023-05-08 11:10:49 +02:00
tcg-accel-ops-icount.c accel/tcg/tcg-accel-ops-rr: ensure fairness with icount 2023-05-11 09:53:41 +01:00
tcg-accel-ops-icount.h accel/tcg/tcg-accel-ops-rr: ensure fairness with icount 2023-05-11 09:53:41 +01:00
tcg-accel-ops-mttcg.c Revert "accel/tcg: Init TCG cflags in vCPU thread handler" 2022-10-25 22:01:14 +10:00
tcg-accel-ops-mttcg.h Clean up header guards that don't match their file name 2022-05-11 16:49:06 +02:00
tcg-accel-ops-rr.c accel/tcg/tcg-accel-ops-rr: ensure fairness with icount 2023-05-11 09:53:41 +01:00
tcg-accel-ops-rr.h Clean up header guards that don't match their file name 2022-05-11 16:49:06 +02:00
tcg-accel-ops.c accel/tcg: Fix overwrite problems of tcg_cflags 2023-04-04 08:19:49 -07:00
tcg-accel-ops.h Clean up header guards that don't match their file name 2022-05-11 16:49:06 +02:00
tcg-all.c accel/tcg: Use one_insn_per_tb global instead of old singlestep global 2023-05-02 15:47:40 +01:00
tcg-runtime-gvec.c tcg: Add tcg_gen_gvec_andcs 2023-05-02 13:05:45 -07:00
tcg-runtime.c accel/tcg: Move helper_lookup_tb_ptr to cpu-exec.c 2021-07-09 20:23:06 -07:00
tcg-runtime.h tcg: Add tcg_gen_gvec_andcs 2023-05-02 13:05:45 -07:00
trace-events accel/tcg: Remove trace events from trace-root.h 2022-12-20 17:11:12 -08:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
translate-all.c accel/tcg: Pass last not end to tb_invalidate_phys_range 2023-03-28 15:23:10 -07:00
translator.c accel/tcg: Remove translator_loop_temp_check 2023-03-05 13:44:07 -08:00
user-exec-stub.c replay: Extract core API to 'exec/replay-core.h' 2023-02-27 22:29:01 +01:00
user-exec.c accel/tcg: Add cpu_ld*_code_mmu 2023-05-02 13:05:45 -07:00