From: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
To: Liu Ping Fan <kernelfans@gmail.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
avi@redhat.com, aliguori@us.ibm.com, gleb@redhat.com,
mtosatti@redhat.com, xiaoguangrong.eric@gmail.com,
jan.kiszka@web.de
Subject: Re: [PATCH v8] kvm: make vcpu life cycle separated from kvm instance
Date: Tue, 07 Feb 2012 13:37:18 +0900 [thread overview]
Message-ID: <4F30AA7E.3020803@oss.ntt.co.jp> (raw)
In-Reply-To: <1328582057-31549-1-git-send-email-kernelfans@gmail.com>
(2012/02/07 11:34), Liu Ping Fan wrote:
> static int kvm_vcpu_release(struct inode *inode, struct file *filp)
Is this a hot path?
If no, do you really need to pre-allocate the space for the next vcpus?
> {
> + int i;
> struct kvm_vcpu *vcpu = filp->private_data;
> + struct kvm *kvm = vcpu->kvm;
> + struct kvm_vcpu *vcpus_next;
> + filp->private_data = NULL;
> +
> + for (i = 0; i< atomic_read(&kvm->online_vcpus); i++) {
> + if (vcpu == kvm->vcpus+i)
> + break;
> + }
> + mutex_lock(&kvm->lock);
> + vcpus_next = kvm->vcpus_array +
> + ((kvm->vcpus - kvm->vcpus_array) ? 0 : KVM_MAX_VCPUS);
> +
> + memset(vcpus_next, 0, KVM_MAX_VCPUS*sizeof(struct kvm_vcpu *));
> + memcpy(vcpus_next, kvm->vcpus, i*sizeof(struct kvm_vcpu *));
> + memcpy(vcpus_next+i, kvm->vcpus+i+1,
> + (atomic_read(&kvm->online_vcpus)-i)*sizeof(struct kvm_vcpu *));
> + atomic_dec(&kvm->online_vcpus);
> + /* Removed vcpu can not be seen from vcpus[] */
This comment is confusing.
> + rcu_assign_pointer(kvm->vcpus, vcpus_next);
> + mutex_unlock(&kvm->lock);
> +
> + synchronize_rcu();
>
> - kvm_put_kvm(vcpu->kvm);
> + /* vcpu is out of list,drop it safely */
Ditto.
Do you mean something like
"now that there is no reader of it we can safely free this" ?
(Please do not trust me: I am not a native English speaker as you know.)
> + kvm_vcpu_destruct(vcpu);
> return 0;
> }
Takuya
next prev parent reply other threads:[~2012-02-07 4:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-07 2:34 Liu Ping Fan
2012-02-07 4:37 ` Takuya Yoshikawa [this message]
2012-02-07 6:13 ` Liu ping fan
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=4F30AA7E.3020803@oss.ntt.co.jp \
--to=yoshikawa.takuya@oss.ntt.co.jp \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=gleb@redhat.com \
--cc=jan.kiszka@web.de \
--cc=kernelfans@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=xiaoguangrong.eric@gmail.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
all inboxes | Powered by JetHome®