public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Pontus Fuchs <pontus.fuchs@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	mingo@redhat.com,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	gleb@kernel.org
Subject: Re: [PATCH] sched,kvm: Fix KVM preempt_notifier usage
Date: Fri, 3 Jul 2015 14:31:25 +0200	[thread overview]
Message-ID: <5596809D.4000905@redhat.com> (raw)
In-Reply-To: <20150703121907.GH19282@twins.programming.kicks-ass.net>



On 03/07/2015 14:19, Peter Zijlstra wrote:
> On Fri, Jul 03, 2015 at 01:12:11PM +0200, Paolo Bonzini wrote:
>> In fact you shouldn't have just tested the patch on a case _without_
>> preemption notifiers, you should have also benchmarked the impact that
>> static keys have _with_ preemption notifiers.  In a
>> not-really-artificial case (one single-processor guest running on the
>> host), the static key patch adds a static_key_slow_inc on a relatively
>> hot path for KVM, which is not acceptable.
> 
> Spawning the first vcpu is a hot path?

This is not *spawning* the first VCPU.  Basically any critical section
for vcpu->mutex includes a preempt_notifier_register/unregister pair:

/*
 * Switches to specified vcpu, until a matching vcpu_put()
 */
int vcpu_load(struct kvm_vcpu *vcpu)
{
        int cpu;

        if (mutex_lock_killable(&vcpu->mutex))
                return -EINTR;
        cpu = get_cpu();
        preempt_notifier_register(&vcpu->preempt_notifier);
        kvm_arch_vcpu_load(vcpu, cpu);
        put_cpu();
        return 0;
}

void vcpu_put(struct kvm_vcpu *vcpu)
{
        preempt_disable();
        kvm_arch_vcpu_put(vcpu);
        preempt_notifier_unregister(&vcpu->preempt_notifier);
        preempt_enable();
        mutex_unlock(&vcpu->mutex);
}

So basically you're adding at least one static_key_slow_inc/dec pair to
every userspace exit.

Paolo

  reply	other threads:[~2015-07-03 12:31 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-25 12:00 Regression: sched/preempt: Add static_key() to preempt_notifiers breaks my KVM Pontus Fuchs
2015-06-25 12:09 ` Peter Zijlstra
2015-06-25 12:15   ` Pontus Fuchs
2015-06-25 12:55     ` [PATCH] sched,kvm: Fix KVM preempt_notifier usage Peter Zijlstra
2015-06-30 11:10       ` [tip:sched/urgent] sched/preempt, kvm: " tip-bot for Peter Zijlstra
2015-07-03 11:23         ` Paolo Bonzini
2015-07-03 11:12       ` [PATCH] sched,kvm: " Paolo Bonzini
2015-07-03 12:19         ` Peter Zijlstra
2015-07-03 12:31           ` Paolo Bonzini [this message]
2015-07-03 13:17             ` Peter Zijlstra
2015-07-03 15:16               ` Peter Zijlstra
2015-07-03 15:26                 ` Paolo Bonzini
2015-07-03 15:38                   ` Paolo Bonzini
2015-07-03 15:42                     ` Peter Zijlstra
2015-07-03 15:46                       ` Paolo Bonzini
2015-07-03 15:57                         ` Takashi Iwai
2015-06-30 13:47     ` Regression: sched/preempt: Add static_key() to preempt_notifiers breaks my KVM Josh Boyer
2015-07-01  6:55       ` Ingo Molnar
2015-07-03 13:15         ` Takashi Iwai

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=5596809D.4000905@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=gleb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pontus.fuchs@gmail.com \
    --cc=torvalds@linux-foundation.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