public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] Activate Virtualization On Demand v2
Date: Tue, 16 Jun 2009 16:08:04 +0200	[thread overview]
Message-ID: <4A37A744.1050705@suse.de> (raw)
In-Reply-To: <4A37A59D.5070604@redhat.com>

Avi Kivity wrote:
> On 06/15/2009 02:30 PM, Alexander Graf wrote:
>> X86 CPUs need to have some magic happening to enable the virtualization
>> extensions on them. This magic can result in unpleasant results for
>> users, like blocking other VMMs from working (vmx) or using invalid TLB
>> entries (svm).
>>
>> Currently KVM activates virtualization when the respective kernel module
>> is loaded. This blocks us from autoloading KVM modules without breaking
>> other VMMs.
>>
>> To circumvent this problem at least a bit, this patch introduces on
>> demand activation of virtualization. This means, that instead
>> virtualization is enabled on creation of the first virtual machine
>> and disabled on destruction of the last one.
>>
>> So using this, KVM can be easily autoloaded, while keeping other
>> hypervisors usable.
>>
>> +static int hardware_enable_all(void)
>> +{
>> +    int r = 0;
>> +
>> +    spin_lock(&kvm_lock);
>> +
>> +    kvm_usage_count++;
>> +    if (kvm_usage_count == 1) {
>> +        atomic_set(&hardware_enable_failed, 1);
>> +        on_each_cpu(hardware_enable, NULL, 1);
>> +
>> +        if (!atomic_dec_and_test(&hardware_enable_failed))
>> +            r = -EBUSY;
>> +    }
>>    
>
> That's a little obfuscated.  I suggest atomic_set(..., p) and
> atomic_read(...).

Ah, I was more searching for an atomic_test :-).

>>   static int kvm_cpu_hotplug(struct notifier_block *notifier,
>> unsigned long val,
>>                  void *v)
>>   {
>>       int cpu = (long)v;
>>
>> +    if (!kvm_usage_count)
>> +        return NOTIFY_OK;
>> +
>>       val&= ~CPU_TASKS_FROZEN;
>>       switch (val) {
>>       case CPU_DYING:
>> @@ -2513,13 +2571,15 @@ static void kvm_exit_debug(void)
>>
>>   static int kvm_suspend(struct sys_device *dev, pm_message_t state)
>>   {
>> -    hardware_disable(NULL);
>> +    if (kvm_usage_count)
>> +        hardware_disable(NULL);
>>       return 0;
>>   }
>>
>>   static int kvm_resume(struct sys_device *dev)
>>   {
>> -    hardware_enable(NULL);
>> +    if (kvm_usage_count)
>> +        hardware_enable(NULL);
>>       return 0;
>>   }
>>
>>    
> +
>
> Please tell me you tested suspend/resume with/without VMs and cpu
> hotunplug/hotplug.

I tested cpu hotplugging. On the last round I tested suspend/resume, but
this time I couldn't because my machine can't do suspend :-(.
So I'll try hard and find a machine I can test it on for the next round.

Alex

  reply	other threads:[~2009-06-16 14:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-15 11:30 [PATCH] Activate Virtualization On Demand v2 Alexander Graf
2009-06-15 12:17 ` Christoph Hellwig
2009-06-15 12:25   ` Alexander Graf
2009-06-15 12:27     ` Christoph Hellwig
2009-06-16 14:02   ` Avi Kivity
2009-06-16 14:01 ` Avi Kivity
2009-06-16 14:08   ` Alexander Graf [this message]
2009-06-16 15:13     ` Avi Kivity
2009-06-17 21:56       ` Alexander Graf
2009-06-18  8:35         ` Avi Kivity
  -- strict thread matches above, loose matches on Subject: below --
2008-11-05  8:48 Alexander Graf
2008-11-05 10:06 ` Avi Kivity
2008-11-05 10:28   ` Alexander Graf
2008-11-05 10:45     ` Avi Kivity
2008-11-05 10:53       ` Alexander Graf
2008-11-05 11:23       ` Alexander Graf
2008-11-05 10:45 ` Zhang, Xiantao
2008-11-05 10:54   ` Alexander Graf
2008-11-05 10:58 ` Daniel P. Berrange
2008-11-05 11:01   ` Alexander Graf
2008-11-05 13:06 ` Christian Borntraeger
2008-11-05 13:12   ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A37A744.1050705@suse.de \
    --to=agraf@suse.de \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox