Skip to content

[PW_SID:1123077] RISC-V: KVM: Optimize hfence request handling for SMP guests#2239

Closed
linux-riscv-bot wants to merge 2 commits into
workflow__riscv__fixesfrom
pw1123077
Closed

[PW_SID:1123077] RISC-V: KVM: Optimize hfence request handling for SMP guests#2239
linux-riscv-bot wants to merge 2 commits into
workflow__riscv__fixesfrom
pw1123077

Conversation

@linux-riscv-bot

Copy link
Copy Markdown

PR for series 1123077 applied to workflow__riscv__fixes

Name: RISC-V: KVM: Optimize hfence request handling for SMP guests
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1123077
Version: 2

yechao-w added 2 commits July 7, 2026 15:48
FENCE.I does not need hfence data, but it currently goes through the
generic make_xfence_request() path with NULL data, incurring unnecessary
per-VCPU checks.

Split out a separate make_xfence_request_nodata() function to handle
FENCE.I directly, and move the data validity check to the top of the
generic function to avoid redundant checks.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
When handling hfence requests in make_xfence_request(), the current code
uses a single 'actual_req' variable and a single vcpu_mask. If any VCPU
fails to enqueue the hfence data (because its queue is full), the request
falls back to 'fallback_req' for all VCPUs, even if other VCPUs still
have available queue space.

This can cause unnecessary fallback for healthy VCPUs, and more seriously,
those healthy VCPUs will not process their already-enqueued hfence
requests because no 'req' is set for them. As a result, their queues will
quickly become full as well, degrading performance for SMP guests.

Fix this by maintaining two separate bitmaps: one for VCPUs that
successfully enqueued the hfence data (req_vcpu_mask) and another for
those that failed (fallback_req_vcpu_mask). Then send the appropriate
requests to each group. This ensures that fallback is only applied to
VCPUs that actually need it, preserving the efficiency of the normal
path for others.

Fixes: 13acfec ("RISC-V: KVM: Add remote HFENCE functions based on VCPU requests")
Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Introduce make_xfence_request_nodata for FENCE.I requests"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 120.56 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Introduce make_xfence_request_nodata for FENCE.I requests"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1144.74 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Introduce make_xfence_request_nodata for FENCE.I requests"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1479.62 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Introduce make_xfence_request_nodata for FENCE.I requests"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.59 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Introduce make_xfence_request_nodata for FENCE.I requests"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 22.12 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Introduce make_xfence_request_nodata for FENCE.I requests"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.74 seconds
Result: WARNING
Output:

CHECK: Alignment should match open parenthesis
#40: FILE: arch/riscv/kvm/tlb.c:339:
+			if (vcpu->vcpu_id < hbase ||
+				vcpu->vcpu_id >= hbase + BITS_PER_LONG)

total: 0 errors, 0 warnings, 1 checks, 56 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 846d0d6dc26e ("RISC-V: KVM: Introduce make_xfence_request_nodata for FENCE.I requests") 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, 56 lines checked
CHECK: Alignment should match open parenthesis


@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Introduce make_xfence_request_nodata for FENCE.I requests"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 84.54 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Introduce make_xfence_request_nodata for FENCE.I requests"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Introduce make_xfence_request_nodata for FENCE.I requests"
kdoc
Desc: Detects for kdoc errors
Duration: 0.76 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Introduce make_xfence_request_nodata for FENCE.I requests"
module-param
Desc: Detect module_param changes
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Introduce make_xfence_request_nodata for FENCE.I requests"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v2,1/2] RISC-V: KVM: Introduce make_xfence_request_nodata for FENCE.I requests"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.64 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 121.79 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1186.23 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1478.63 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.44 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 22.17 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.64 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 84.52 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request"
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 2: "[v2,2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request"
kdoc
Desc: Detects for kdoc errors
Duration: 0.75 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request"
module-param
Desc: Detect module_param changes
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 2: "[v2,2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
linux-riscv-bot deleted the pw1123077 branch July 8, 2026 05:09
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