[PW_SID:1068634] [v2] RISC-V: KVM: Batch stage-2 remote TLB flushes#1637
[PW_SID:1068634] [v2] RISC-V: KVM: Batch stage-2 remote TLB flushes#1637linux-riscv-bot wants to merge 1 commit intoworkflow__riscv__fixesfrom
Conversation
KVM RISC-V triggers a TLB flush for every single stage-2 PTE
modification (unmap or write-protect) now. Although KVM coalesces the
hardware IPIs, the software overhead of executing the flush work
for every 4K page is large, especially during dirty page tracking.
Following the approach used in x86 and arm64, this patch optimizes
the MMU logic by making the PTE manipulation functions return a boolean
indicating if a leaf PTE was actually changed. The outer MMU functions
bubble up this flag to batch the remote TLB flushes. This change makes
the generic KVM MMU callbacks (e.g., `kvm_unmap_gfn_range()`) actually
effective by returning the true flush requirement rather than `false`.
Consequently, the flush operation is executed only once per batch.
Moving it outside of the `mmu_lock` also reduces lock contention.
For directory pages, we keep the synchronous flush to ensure safety.
Tested with tools/testing/selftests/kvm on a 4-vCPU guest (Host
environment: QEMU 10.2.1 RISC-V)
1. demand_paging_test (1GB memory)
# time ./demand_paging_test -b 1G -v 4
- Total execution time reduced from ~2m33s to ~2m25s
2. dirty_log_perf_test (1GB memory)
# ./dirty_log_perf_test -b 1G -v 4
- "Clear dirty log time" per iteration dropped significantly from
~3.02s to ~0.20s
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Signed-off-by: Jinyu Tang <tjytimi@163.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v2] RISC-V: KVM: Batch stage-2 remote TLB flushes" |
|
Patch 1: "[v2] RISC-V: KVM: Batch stage-2 remote TLB flushes" |
|
Patch 1: "[v2] RISC-V: KVM: Batch stage-2 remote TLB flushes" |
|
Patch 1: "[v2] RISC-V: KVM: Batch stage-2 remote TLB flushes" |
|
Patch 1: "[v2] RISC-V: KVM: Batch stage-2 remote TLB flushes" |
|
Patch 1: "[v2] RISC-V: KVM: Batch stage-2 remote TLB flushes" |
|
Patch 1: "[v2] RISC-V: KVM: Batch stage-2 remote TLB flushes" |
|
Patch 1: "[v2] RISC-V: KVM: Batch stage-2 remote TLB flushes" |
|
Patch 1: "[v2] RISC-V: KVM: Batch stage-2 remote TLB flushes" |
|
Patch 1: "[v2] RISC-V: KVM: Batch stage-2 remote TLB flushes" |
|
Patch 1: "[v2] RISC-V: KVM: Batch stage-2 remote TLB flushes" |
|
Patch 1: "[v2] RISC-V: KVM: Batch stage-2 remote TLB flushes" |
PR for series 1068634 applied to workflow__riscv__fixes
Name: [v2] RISC-V: KVM: Batch stage-2 remote TLB flushes
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1068634
Version: 2