Skip to content

[PW_SID:1063052] [v1] RISC-V: KVM: Batch stage-2 remote TLB flushes#1572

Closed
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw1063052
Closed

[PW_SID:1063052] [v1] RISC-V: KVM: Batch stage-2 remote TLB flushes#1572
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw1063052

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

PR for series 1063052 applied to workflow__riscv__fixes

Name: [v1] RISC-V: KVM: Batch stage-2 remote TLB flushes
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1063052
Version: 1

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

Signed-off-by: Jinyu Tang <tjytimi@163.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v1] RISC-V: KVM: Batch stage-2 remote TLB flushes"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 138.11 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v1] RISC-V: KVM: Batch stage-2 remote TLB flushes"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1036.48 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v1] RISC-V: KVM: Batch stage-2 remote TLB flushes"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1401.05 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v1] RISC-V: KVM: Batch stage-2 remote TLB flushes"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.60 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v1] RISC-V: KVM: Batch stage-2 remote TLB flushes"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.74 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v1] RISC-V: KVM: Batch stage-2 remote TLB flushes"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 2.09 seconds
Result: WARNING
Output:

CHECK: Alignment should match open parenthesis
#249: FILE: arch/riscv/kvm/mmu.c:127:
+		kvm_flush_remote_tlbs_range(kvm, start >> PAGE_SHIFT,
+			(end - start) >> PAGE_SHIFT);

CHECK: Alignment should match open parenthesis
#300: FILE: arch/riscv/kvm/mmu.c:604:
+		flush = kvm_riscv_gstage_unmap_range(&gstage, 0UL,
+					kvm_riscv_gstage_gpa_size, false);

total: 0 errors, 0 warnings, 2 checks, 244 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 952ff4712d40 ("RISC-V: KVM: Batch stage-2 remote TLB flushes") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 0 warnings, 2 checks, 244 lines checked
CHECK: Alignment should match open parenthesis


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v1] RISC-V: KVM: Batch stage-2 remote TLB flushes"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 83.41 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v1] RISC-V: KVM: Batch stage-2 remote TLB flushes"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v1] RISC-V: KVM: Batch stage-2 remote TLB flushes"
kdoc
Desc: Detects for kdoc errors
Duration: 0.90 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v1] RISC-V: KVM: Batch stage-2 remote TLB flushes"
module-param
Desc: Detect module_param changes
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v1] RISC-V: KVM: Batch stage-2 remote TLB flushes"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v1] RISC-V: KVM: Batch stage-2 remote TLB flushes"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.32 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot deleted the pw1063052 branch March 15, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants