[PW_SID:1123039] RISC-V: KVM: Optimize hfence request handling for SMP guests#2235
[PW_SID:1123039] RISC-V: KVM: Optimize hfence request handling for SMP guests#2235linux-riscv-bot wants to merge 2 commits into
Conversation
Currently, the check for `data` and `data->type` is performed inside the loop iterating over each VCPU. Since these values are invariant during the loop, this check is redundant and adds unnecessary overhead. Move the validation to the beginning of the function, returning early if the hfence data or its type is invalid. This avoids repeated checks and reduces CPU cycles, which is particularly beneficial for SMP guests with a large number of VCPUs. 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>
|
Patch 1: "[1/2] RISC-V: KVM: Move hfence type check out of loop" |
|
Patch 1: "[1/2] RISC-V: KVM: Move hfence type check out of loop" |
|
Patch 1: "[1/2] RISC-V: KVM: Move hfence type check out of loop" |
|
Patch 1: "[1/2] RISC-V: KVM: Move hfence type check out of loop" |
|
Patch 1: "[1/2] RISC-V: KVM: Move hfence type check out of loop" |
|
Patch 1: "[1/2] RISC-V: KVM: Move hfence type check out of loop" |
|
Patch 1: "[1/2] RISC-V: KVM: Move hfence type check out of loop" |
|
Patch 1: "[1/2] RISC-V: KVM: Move hfence type check out of loop" |
|
Patch 1: "[1/2] RISC-V: KVM: Move hfence type check out of loop" |
|
Patch 1: "[1/2] RISC-V: KVM: Move hfence type check out of loop" |
|
Patch 1: "[1/2] RISC-V: KVM: Move hfence type check out of loop" |
|
Patch 1: "[1/2] RISC-V: KVM: Move hfence type check out of loop" |
|
Patch 2: "[2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request" |
|
Patch 2: "[2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request" |
|
Patch 2: "[2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request" |
|
Patch 2: "[2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request" |
|
Patch 2: "[2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request" |
|
Patch 2: "[2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request" |
|
Patch 2: "[2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request" |
|
Patch 2: "[2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request" |
|
Patch 2: "[2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request" |
|
Patch 2: "[2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request" |
|
Patch 2: "[2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request" |
|
Patch 2: "[2/2] RISC-V: KVM: Separate req and fallback_req masks in make_xfence_request" |
PR for series 1123039 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=1123039
Version: 1