Skip to content

[PW_SID:995179] [v2] riscv: skip csr restore if vcpu preempted reload - #828

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

[PW_SID:995179] [v2] riscv: skip csr restore if vcpu preempted reload#828
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw995179

Conversation

@linux-riscv-bot

Copy link
Copy Markdown

PR for series 995179 applied to workflow__riscv__fixes

Name: [v2] riscv: skip csr restore if vcpu preempted reload
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=995179
Version: 2

The kvm_arch_vcpu_load() function is called in two cases for riscv:
1. When entering KVM_RUN from userspace ioctl.
2. When a preempted VCPU is scheduled back.

In the second case, if no other KVM VCPU has run on this CPU since the
current VCPU was preempted, the guest CSR (including AIA CSRS) values
are still valid in the hardware and do not need to be restored.

This patch is to skip the CSR write path when:
1. The VCPU was previously preempted
(vcpu->scheduled_out == 1).
2. It is being reloaded on the same physical CPU
(vcpu->arch.last_exit_cpu == cpu).
3. No other KVM VCPU has used this CPU in the meantime
(vcpu == __this_cpu_read(kvm_former_vcpu)).

This reduces many CSR writes with frequent preemption on the same CPU.

Signed-off-by: Jinyu Tang <tjytimi@163.com>
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: skip csr restore if vcpu preempted reload"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 103.59 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: skip csr restore if vcpu preempted reload"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1052.03 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: skip csr restore if vcpu preempted reload"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1353.98 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: skip csr restore if vcpu preempted reload"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.51 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: skip csr restore if vcpu preempted reload"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 21.90 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: skip csr restore if vcpu preempted reload"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.75 seconds
Result: WARNING
Output:

CHECK: Alignment should match open parenthesis
#49: FILE: arch/riscv/kvm/vcpu.c:587:
+	if  (vcpu == __this_cpu_read(kvm_former_vcpu) &&
+		vcpu->arch.last_exit_cpu == cpu)

total: 0 errors, 0 warnings, 1 checks, 43 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 1cd54f87f622 ("riscv: skip csr restore if vcpu preempted reload") 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, 1 checks, 43 lines checked
CHECK: Alignment should match open parenthesis


@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: skip csr restore if vcpu preempted reload"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 74.66 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: skip csr restore if vcpu preempted reload"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: skip csr restore if vcpu preempted reload"
kdoc
Desc: Detects for kdoc errors
Duration: 0.85 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: skip csr restore if vcpu preempted reload"
module-param
Desc: Detect module_param changes
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: skip csr restore if vcpu preempted reload"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2] riscv: skip csr restore if vcpu preempted reload"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot
linux-riscv-bot deleted the pw995179 branch August 25, 2025 14:20
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