target/riscv: Cache TB flags in CPURISCVState
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | target/riscv: Split out riscv_compute_tb_flagstarget/ | +69 | 0 replies | |
| 2/3 | target/riscv: Rebuild cached TB flags at state changestarget/ target/ target/ +5 more | +40 | 0 replies | |
| 3/3 | target/riscv: Rely on cached TB flags in riscv_get_tb_cpu_statetarget/ | +25 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/3] target/riscv: Cache TB flags in CPURISCVState
riscv_get_tb_cpu_state() recomputes TB flags on every lookup. Most of the inputs change infrequently, at CSR writes, traps, privilege changes or vsetvl. Cache the derived TB flags in CPURISCVState and rebuild them when their inputs may change. The design follows the Arm hflags cache, commit e979972a6a ("target/arm: Rely on hflags correct in cpu_get_tb_cpu_state") and its series [1].
Patch 1 extracts the flag computation. Patch 2 adds the cache and its rebuild points. Patch 3 switches TB lookup to the cache and adds a CONFIG_DEBUG_TCG check that reports the cached and recomputed values and aborts on a mismatch.
In an RV64 virt Linux boot and power-off profile, the self overhead of riscv_get_tb_cpu_state() in the vCPU thread dropped from 16.54% to 6.78%. Median boot time dropped from 5.69 s to 4.81 s (-15.5%) compared with the base revision. See patch 3 for measurement details.
Runtime tests with --enable-debug-tcg
- RV64 virt Linux boot and power-off, covering M/S/U modes.
- KVM selftests inside the RV64 virt guest (ebreak_test and kvm_page_table_test with Sv39, Sv48 and Sv57 guests). These exercise HS/VS transitions, two-stage translation and writes to hstatus, vsstatus and hgatp.
- A vle8ff.v regression test that checks tail elements after a fault-only-first load reduces vl below VLMAX without a trap.
- Guest reboot and migration save/restore, exercising the reset and post-load hooks.
- The vle8ff.v test under riscv64-linux-user.
Build-tested riscv32-softmmu. Boot timings were measured with release builds.
VU mode, M-mode accesses with MPRV+MPV, pointer masking and CFI were reviewed but not exercised.
[1] https://lore.kernel.org/qemu-devel/[email protected]/
SeungJu Cheon (3):
target/riscv: Split out riscv_compute_tb_flags target/riscv: Rebuild cached TB flags at state changes target/riscv: Rely on cached TB flags in riscv_get_tb_cpu_state
target/riscv/cpu.c | 1 + target/riscv/cpu.h | 19 +++++ target/riscv/machine.c | 1 + target/riscv/tcg/cpu_helper.c | 1 + target/riscv/tcg/csr.c | 8 +- target/riscv/tcg/debug.c | 2 + target/riscv/tcg/tcg-cpu.c | 123 +++++++++++++++++++++++-------- target/riscv/tcg/vector_helper.c | 2 + 8 files changed, 124 insertions(+), 33 deletions(-)
base-commit: 08c9bbb825148dec9669f5184ecf18823bb6d631
Signature · 1 line
2.52.0