All of
 help / color / mirror / Atom feed
From: Marcelo Tosatti <>
Cc: Avi Kivity <>
Subject: KVM: MMU: zero caches before entering mmu_lock protected section
Date: Thu, 8 Jan 2009 16:26:17 -0200	[thread overview]
Message-ID: <20090108182617.GA7250@amt.cnet> (raw)

Clean the pre-allocated cache pages before entering mmu_lock region.
This is safe since the caches are per-vcpu.

Smaller chunks are already zeroed by kmem_cache_zalloc.

~= 0.90% reduction in system time with AIM7 on RHEL3 / 4-vcpu.

Signed-off-by: Marcelo Tosatti <>

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 10bdb2a..823d0cd 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -301,7 +301,7 @@ static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache,
 	if (cache->nobjs >= min)
 		return 0;
 	while (cache->nobjs < ARRAY_SIZE(cache->objects)) {
-		page = alloc_page(GFP_KERNEL);
+		page = alloc_page(GFP_KERNEL|__GFP_ZERO);
 		if (!page)
 			return -ENOMEM;
 		set_page_private(page, 0);
@@ -352,7 +352,6 @@ static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc,
 	p = mc->objects[--mc->nobjs];
-	memset(p, 0, size);
 	return p;

             reply	other threads:[~2009-01-08 18:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-08 18:26 Marcelo Tosatti [this message]
2009-01-08 18:35 ` KVM: MMU: zero caches before entering mmu_lock protected section 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090108182617.GA7250@amt.cnet \ \ \ \

* 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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.