[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <24e67e43-c50c-7e0f-305a-c7f6129f8d70@redhat.com>
Date: Tue, 19 Oct 2021 18:59:43 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Wanpeng Li <kernellwp@...il.com>, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org
Cc: Sean Christopherson <seanjc@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>
Subject: Re: [PATCH v3 3/3] KVM: vCPU kick tax cut for running vCPU
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;
> + }
Powered by blists - more mailing lists