From: Avi Kivity <avi@qumranet.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Andrew Morton <akpm@osdl.org>,
kvm-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/5] KVM: cpu hotplug support
Date: Wed, 31 Jan 2007 13:04:36 +0200 [thread overview]
Message-ID: <45C077C4.3070607@qumranet.com> (raw)
In-Reply-To: <20070131085039.GA17141@elte.hu>
Ingo Molnar wrote:
> * Andrew Morton <akpm@osdl.org> wrote:
>
>
>> On Tue, 30 Jan 2007 14:56:16 -0000
>> Avi Kivity <avi@qumranet.com> wrote:
>>
>>
>>> +static void decache_vcpus_on_cpu(int cpu)
>>> +{
>>> + struct kvm *vm;
>>> + struct kvm_vcpu *vcpu;
>>> + int i;
>>> +
>>> + spin_lock(&kvm_lock);
>>> + list_for_each_entry(vm, &vm_list, vm_list)
>>> + for (i = 0; i < KVM_MAX_VCPUS; ++i) {
>>> + vcpu = &vm->vcpus[i];
>>> + /*
>>> + * If the vcpu is locked, then it is running on some
>>> + * other cpu and therefore it is not cached on the
>>> + * cpu in question.
>>> + *
>>> + * If it's not locked, check the last cpu it executed
>>> + * on.
>>> + */
>>> + if (mutex_trylock(&vcpu->mutex)) {
>>> + if (vcpu->cpu == cpu) {
>>> + kvm_arch_ops->vcpu_decache(vcpu);
>>> + vcpu->cpu = -1;
>>> + }
>>> + mutex_unlock(&vcpu->mutex);
>>> + }
>>> + }
>>> + spin_unlock(&kvm_lock);
>>> +}
>>>
>> The trylock is unpleasing. Perhaps kvm_lock should be a mutex or
>> something?
>>
>
> this is a special case. The vcpu->mutex acts as a 'this vcpu is running
> right now' flag as well - hence the trylock signals: is it running right
> now or not - if it's not running we do not have to 'decache' it. But i
> agree and i already suggested to Avi to change kvm_lock to be a mutex -
> but this wont change the trylock.
>
To elaborate a little: replacing mutex_trylock() with mutex_lock() will
cause unbounded latency as we wait for the vcpu to be descheduled. In
this case, we're only interested in descheduled vcpus, so there's no
need to wait.
kvm is a bit funny in how it likes to pin cpus.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2007-01-31 11:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-30 14:52 [PATCH 0/5] KVM: suspend/resume support Avi Kivity
2007-01-30 14:52 ` Avi Kivity
2007-01-30 14:53 ` [PATCH 1/5] hotplug: Allow modules to use the cpu hotplug notifiers even if !CONFIG_HOTPLUG_CPU Avi Kivity
2007-01-30 14:54 ` [PATCH 2/5] KVM: Add a global list of all virtual machines Avi Kivity
2007-01-30 14:55 ` [PATCH 3/5] KVM: VMX: add vcpu_clear() Avi Kivity
2007-01-30 14:56 ` [PATCH 4/5] KVM: cpu hotplug support Avi Kivity
2007-01-31 0:48 ` Andrew Morton
2007-01-31 0:48 ` Andrew Morton
2007-01-31 8:50 ` Ingo Molnar
2007-01-31 8:50 ` Ingo Molnar
2007-01-31 11:04 ` Avi Kivity [this message]
2007-01-30 14:57 ` [PATCH 5/5] KVM: Host suspend/resume support Avi Kivity
2007-01-30 14:57 ` Avi Kivity
2007-01-30 21:20 ` Nigel Cunningham
2007-01-30 22:19 ` Rafael J. Wysocki
2007-01-30 22:19 ` Rafael J. Wysocki
2007-01-31 0:42 ` Nigel Cunningham
2007-01-31 0:42 ` Nigel Cunningham
2007-01-31 9:07 ` Avi Kivity
2007-01-31 9:07 ` 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=45C077C4.3070607@qumranet.com \
--to=avi@qumranet.com \
--cc=akpm@osdl.org \
--cc=kvm-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.