Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1699953
| From | David Hildenbrand <david@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC] KVM: optimize the kvm_vcpu_on_spin |
| Date | 2017-07-31 13:40 +0200 |
| Message-ID | <u9hdf-5GQ-3@gated-at.bofh.it> (permalink) |
| References | <u8tqa-6KR-23@gated-at.bofh.it> |
| Organization | Red Hat GmbH |
[no idea if this change makes sense (and especially if it has any bad
side effects), do you have performance numbers? I'll just have a look at
the general structure of the patch in the meanwhile]
> +bool kvm_arch_vcpu_spin_kernmode(struct kvm_vcpu *vcpu)
kvm_arch_vcpu_in_kernel() ?
> +{
> + return kvm_x86_ops->get_cpl(vcpu) == 0;
> +}
> +
> int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
> {
> return kvm_vcpu_exiting_guest_mode(vcpu) == IN_GUEST_MODE;
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index 648b34c..f8f0d74 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -272,6 +272,9 @@ struct kvm_vcpu {
> } spin_loop;
> #endif
> bool preempted;
> + /* If vcpu is in kernel-mode when preempted */
> + bool in_kernmode;
> +
Why do you have to store that ...
[...]> + me->in_kernmode = kvm_arch_vcpu_spin_kernmode(me);
> kvm_vcpu_set_in_spin_loop(me, true);
> /*
> * We boost the priority of a VCPU that is runnable but not
> @@ -2351,6 +2353,8 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me)
> continue;
> if (swait_active(&vcpu->wq) && !kvm_arch_vcpu_runnable(vcpu))
> continue;
> + if (me->in_kernmode && !vcpu->in_kernmode)
Wouldn't it be easier to simply have
in_kernel = kvm_arch_vcpu_in_kernel(me);
...
if (in_kernel && !kvm_arch_vcpu_in_kernel(vcpu))
...
> + continue;
> if (!kvm_vcpu_eligible_for_directed_yield(vcpu))
> continue;
>
> @@ -4009,8 +4013,11 @@ static void kvm_sched_out(struct preempt_notifier *pn,
> {
> struct kvm_vcpu *vcpu = preempt_notifier_to_vcpu(pn);
>
> - if (current->state == TASK_RUNNING)
> + if (current->state == TASK_RUNNING) {
> vcpu->preempted = true;
> + vcpu->in_kernmode = kvm_arch_vcpu_spin_kernmode(vcpu);
> + }
> +
so you don't have to do this change, too.
> kvm_arch_vcpu_put(vcpu);
> }
>
>
--
Thanks,
David
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC] KVM: optimize the kvm_vcpu_on_spin "Longpeng(Mike)" <longpeng2@huawei.com> - 2017-07-29 08:30 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin David Hildenbrand <david@redhat.com> - 2017-07-31 13:40 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin "Longpeng (Mike)" <longpeng2@huawei.com> - 2017-07-31 14:20 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin David Hildenbrand <david@redhat.com> - 2017-07-31 14:30 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin Paolo Bonzini <pbonzini@redhat.com> - 2017-07-31 15:30 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin "Longpeng (Mike)" <longpeng2@huawei.com> - 2017-08-01 05:30 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin Paolo Bonzini <pbonzini@redhat.com> - 2017-08-01 10:40 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin Cornelia Huck <cohuck@redhat.com> - 2017-07-31 14:40 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin "Longpeng (Mike)" <longpeng2@huawei.com> - 2017-07-31 15:10 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin Christoffer Dall <cdall@linaro.org> - 2017-07-31 15:30 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin David Hildenbrand <david@redhat.com> - 2017-07-31 19:40 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin Cornelia Huck <cohuck@redhat.com> - 2017-08-01 09:00 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin "Longpeng (Mike)" <longpeng2@huawei.com> - 2017-08-01 04:30 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin Marc Zyngier <marc.zyngier@arm.com> - 2017-07-31 15:50 +0200
Re: [RFC] KVM: optimize the kvm_vcpu_on_spin Paolo Bonzini <pbonzini@redhat.com> - 2017-07-31 16:30 +0200
csiph-web