linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] kvm: simplify kvm_vm_ioctl_set_memory_alias
@ 2010-04-17  9:20 Lai Jiangshan
  2010-04-21  8:49 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Lai Jiangshan @ 2010-04-17  9:20 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti, LKML, kvm


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;


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] kvm: simplify kvm_vm_ioctl_set_memory_alias
  2010-04-17  9:20 [PATCH 1/2] kvm: simplify kvm_vm_ioctl_set_memory_alias Lai Jiangshan
@ 2010-04-21  8:49 ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2010-04-21  8:49 UTC (permalink / raw)
  To: Lai Jiangshan; +Cc: Marcelo Tosatti, LKML, kvm

On 04/17/2010 12:20 PM, Lai Jiangshan wrote:
> It's just time waste if we free a object and allocate it immediately.
>    

The alias code is scheduled to be killed off soon, (see 
Documentation/feature-removal-schedule.txt), so there's not much point 
in optimizing it.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-21  8:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-17  9:20 [PATCH 1/2] kvm: simplify kvm_vm_ioctl_set_memory_alias Lai Jiangshan
2010-04-21  8:49 ` Avi Kivity

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).