lkml.org 
[lkml]   [2022]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 37/44] KVM: Rename and move CPUHP_AP_KVM_STARTING to ONLINE section
On Thu, Nov 10, 2022, Robert Hoo wrote:
> > -static int kvm_starting_cpu(unsigned int cpu)
> > +static int kvm_online_cpu(unsigned int cpu)
> > {
> > + int ret = 0;
> > +
> > raw_spin_lock(&kvm_count_lock);
> > - if (kvm_usage_count)
> > + /*
> > + * Abort the CPU online process if hardware virtualization
> > cannot
> > + * be enabled. Otherwise running VMs would encounter
> > unrecoverable
> > + * errors when scheduled to this CPU.
> > + */
> > + if (kvm_usage_count) {
> > + WARN_ON_ONCE(atomic_read(&hardware_enable_failed));
> > +
> > hardware_enable_nolock(NULL);
> > + if (atomic_read(&hardware_enable_failed)) {
> > + atomic_set(&hardware_enable_failed, 0);
>
> I see other places using this hardware_enable_failed with atomic_inc(),
> should here use atomic_dec() instead of straightly set to 0?

Meh, both options are flawed. E.g. if hardware_enable_failed was left dangling
(the WARN above), then atomic_dec() won't remedy the problem and KVM will reject
onlining CPUs indefinitely. Forcing the atomic back to '0' will remedy that
particular issue, but could lead to problems if there are other bugs.

> Though here is embraced by spin_lock, hardware_enable_nolock() can be
> invoked in other places in parallel?

Only because of a KVM bug, which gets fixed in the next patch:

KVM: Disable CPU hotplug during hardware enabling

\
 
 \ /
  Last update: 2022-11-10 17:50    [W:0.873 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site