public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Wanpeng Li <wanpeng.li@linux.intel.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, KVM <kvm@vger.kernel.org>,
	Gleb Natapov <gleb@kernel.org>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Rik van Riel <riel@redhat.com>,
	Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>,
	Michael Mueller <mimu@linux.vnet.ibm.com>
Subject: Re: [PATCH/RFC] KVM: track pid for VCPU only on KVM_RUN ioctl
Date: Mon, 18 Aug 2014 13:02:45 +0800	[thread overview]
Message-ID: <20140818050245.GA3407@kernel> (raw)
In-Reply-To: <1407249854-2953-1-git-send-email-borntraeger@de.ibm.com>

Hi Christian,
On Tue, Aug 05, 2014 at 04:44:14PM +0200, Christian Borntraeger wrote:
>We currently track the pid of the task that runs the VCPU in
>vcpu_load. Since we call vcpu_load for all kind of ioctls on a
>CPU, this causes hickups due to synchronize_rcu if one CPU is
>modified by another CPU or the main thread (e.g. initialization,
>reset). We track the pid only for the purpose of yielding, so
>let's update the pid only in the KVM_RUN ioctl.
>
>In addition, don't do a synchronize_rcu on startup (pid == 0).
>
>This speeds up guest boot time on s390 noticably for some configs, e.g.
>HZ=100, no full state tracking, 64 guest cpus 32 host cpus.
>
>Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
>CC: Rik van Riel <riel@redhat.com>
>CC: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
>CC: Michael Mueller <mimu@linux.vnet.ibm.com>
>---
> virt/kvm/kvm_main.c | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
>diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>index 9ae9135..ebc8f54 100644
>--- a/virt/kvm/kvm_main.c
>+++ b/virt/kvm/kvm_main.c
>@@ -124,14 +124,6 @@ int vcpu_load(struct kvm_vcpu *vcpu)
> 
> 	if (mutex_lock_killable(&vcpu->mutex))
> 		return -EINTR;

One question: 

>-	if (unlikely(vcpu->pid != current->pids[PIDTYPE_PID].pid)) {

When vcpu->pid and current->pids[PIDTYPE_PID].pid will be different?

Regards,
Wanpeng Li 

>-		/* The thread running this VCPU changed. */
>-		struct pid *oldpid = vcpu->pid;
>-		struct pid *newpid = get_task_pid(current, PIDTYPE_PID);
>-		rcu_assign_pointer(vcpu->pid, newpid);
>-		synchronize_rcu();
>-		put_pid(oldpid);
>-	}
> 	cpu = get_cpu();
> 	preempt_notifier_register(&vcpu->preempt_notifier);
> 	kvm_arch_vcpu_load(vcpu, cpu);
>@@ -1991,6 +1983,15 @@ static long kvm_vcpu_ioctl(struct file *filp,
> 		r = -EINVAL;
> 		if (arg)
> 			goto out;
>+		if (unlikely(vcpu->pid != current->pids[PIDTYPE_PID].pid)) {
>+			/* The thread running this VCPU changed. */
>+			struct pid *oldpid = vcpu->pid;
>+			struct pid *newpid = get_task_pid(current, PIDTYPE_PID);
>+			rcu_assign_pointer(vcpu->pid, newpid);
>+			if (oldpid)
>+				synchronize_rcu();
>+			put_pid(oldpid);
>+		}
> 		r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run);
> 		trace_kvm_userspace_exit(vcpu->run->exit_reason, r);
> 		break;
>-- 
>1.8.4.2
>
>--
>To unsubscribe from this list: send the line "unsubscribe kvm" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-08-18  5:01 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-05 14:44 [PATCH/RFC] KVM: track pid for VCPU only on KVM_RUN ioctl Christian Borntraeger
2014-08-07  8:21 ` Raghavendra K T
2014-08-07  9:59   ` Christian Borntraeger
2014-08-07 13:40     ` Paolo Bonzini
2014-08-19  8:38       ` Christian Borntraeger
2014-08-07 13:39 ` Paolo Bonzini
2014-08-19  8:38   ` Christian Borntraeger
2014-08-19  9:27     ` Paolo Bonzini
2014-08-19  9:47       ` Christian Borntraeger
2014-08-19  9:53         ` Paolo Bonzini
2014-08-19  9:59           ` Christian Borntraeger
2014-08-19 10:03             ` Paolo Bonzini
2014-08-19 10:09               ` Christian Borntraeger
2014-08-19 10:31                 ` Paolo Bonzini
2014-08-19 10:48                   ` Christian Borntraeger
2014-08-19 10:50                     ` Paolo Bonzini
2014-08-19 11:28       ` David Hildenbrand
2014-08-19 12:06         ` Paolo Bonzini
2014-08-19 12:14           ` David Hildenbrand
2014-08-19 14:10             ` Christian Borntraeger
2014-08-19 14:23               ` David Hildenbrand
2014-08-19 14:46                 ` Christian Borntraeger
2014-08-19 14:52                   ` David Hildenbrand
2014-08-18  5:02 ` Wanpeng Li [this message]
2014-08-19 14:04   ` Christian Borntraeger
2014-08-19 23:22     ` Wanpeng Li
2014-08-20  7:01       ` Christian Borntraeger
2014-12-03 13:20 ` Paolo Bonzini

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=20140818050245.GA3407@kernel \
    --to=wanpeng.li@linux.intel.com \
    --cc=borntraeger@de.ibm.com \
    --cc=gleb@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=mimu@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=raghavendra.kt@linux.vnet.ibm.com \
    --cc=riel@redhat.com \
    /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