lkml.org 
[lkml]   [2021]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v3 3/3] KVM: vCPU kick tax cut for running vCPU
From
On 19/10/21 10:12, Wanpeng Li wrote:
> - if (kvm_vcpu_wake_up(vcpu))
> - return;
> + me = get_cpu();
> +
> + if (rcuwait_active(kvm_arch_vcpu_get_wait(vcpu)) && kvm_vcpu_wake_up(vcpu))
> + goto out;

This is racy. You are basically doing the same check that
rcuwait_wake_up does, but without the memory barrier before.

Also here:

> + if (vcpu == __this_cpu_read(kvm_running_vcpu)) {
> + WARN_ON_ONCE(vcpu->mode == IN_GUEST_MODE);

it's better to do

if (vcpu == ... && !WARN_ON_ONCE(vcpu->mode == IN_GUEST_MODE))
goto out;

so that if the bug happens you do get a smp_send_reschedule() and fail
safely.

Paolo

> + goto out;
> + }

\
 
 \ /
  Last update: 2021-10-19 19:01    [W:0.115 / U:4.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site