linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	kvm@vger.kernel.org
Subject: [PATCH 1/2] kvm: simplify kvm_vm_ioctl_set_memory_alias
Date: Sat, 17 Apr 2010 17:20:34 +0800	[thread overview]
Message-ID: <4BC97D62.2090908@cn.fujitsu.com> (raw)


It's just time waste if we free a object and allocate it immediately.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 24cd0ee..db8d7fe 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2479,15 +2479,8 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm,
 	rcu_assign_pointer(kvm->arch.aliases, aliases);
 	synchronize_srcu_expedited(&kvm->srcu);
 	kvm_mmu_zap_all(kvm);
-	kfree(old_aliases);
-
-	r = -ENOMEM;
-	aliases = kzalloc(sizeof(struct kvm_mem_aliases), GFP_KERNEL);
-	if (!aliases)
-		goto out_unlock;
-
-	memcpy(aliases, kvm->arch.aliases, sizeof(struct kvm_mem_aliases));
 
+	aliases = old_aliases;
 	p = &aliases->aliases[alias->slot];
 	p->base_gfn = alias->guest_phys_addr >> PAGE_SHIFT;
 	p->npages = alias->memory_size >> PAGE_SHIFT;
@@ -2505,7 +2498,6 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm,
 	kfree(old_aliases);
 	r = 0;
 
-out_unlock:
 	mutex_unlock(&kvm->slots_lock);
 out:
 	return r;


             reply	other threads:[~2010-04-17  9:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-17  9:20 Lai Jiangshan [this message]
2010-04-21  8:49 ` [PATCH 1/2] kvm: simplify kvm_vm_ioctl_set_memory_alias 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=4BC97D62.2090908@cn.fujitsu.com \
    --to=laijs@cn.fujitsu.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@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;
as well as URLs for NNTP newsgroup(s).