From: Avi Kivity <avi@redhat.com>
To: kvm@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>,
Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Subject: [PATCH 2/2] KVM: MMU: Recover space used by rcu_head in struct kvm_mmu_page
Date: Thu, 19 Apr 2012 19:26:37 +0300 [thread overview]
Message-ID: <1334852797-28167-3-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1334852797-28167-1-git-send-email-avi@redhat.com>
By overlaying the field with 'link', we reduce the structure size by
16 bytes.
Changing call_rcu() to be per-page is not strictly necessary, but it
can help RCU estimate the amount of work pending.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
arch/x86/include/asm/kvm_host.h | 7 ++++---
arch/x86/kvm/mmu.c | 26 +++++++++-----------------
2 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index b885445..ae02ff8 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -208,7 +208,10 @@ union kvm_mmu_page_role {
};
struct kvm_mmu_page {
- struct list_head link;
+ union {
+ struct list_head link;
+ struct rcu_head rcu;
+ };
struct hlist_node hash_link;
/*
@@ -237,8 +240,6 @@ struct kvm_mmu_page {
#endif
int write_flooding_count;
-
- struct rcu_head rcu;
};
struct kvm_pio_request {
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index c10f60b..26257d7 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1338,7 +1338,6 @@ static void kvm_mmu_isolate_page(struct kvm_mmu_page *sp)
*/
static void kvm_mmu_free_page(struct kvm_mmu_page *sp)
{
- list_del(&sp->link);
free_page((unsigned long)sp->spt);
kmem_cache_free(mmu_page_header_cache, sp);
}
@@ -1980,20 +1979,12 @@ static void kvm_mmu_isolate_pages(struct list_head *invalid_list)
kvm_mmu_isolate_page(sp);
}
-static void free_pages_rcu(struct rcu_head *head)
+static void free_page_rcu(struct rcu_head *head)
{
- struct kvm_mmu_page *next, *sp;
+ struct kvm_mmu_page *sp;
sp = container_of(head, struct kvm_mmu_page, rcu);
- while (sp) {
- if (!list_empty(&sp->link))
- next = list_first_entry(&sp->link,
- struct kvm_mmu_page, link);
- else
- next = NULL;
- kvm_mmu_free_page(sp);
- sp = next;
- }
+ kvm_mmu_free_page(sp);
}
static void kvm_mmu_commit_zap_page(struct kvm *kvm,
@@ -2007,11 +1998,12 @@ static void kvm_mmu_commit_zap_page(struct kvm *kvm,
kvm_flush_remote_tlbs(kvm);
kvm_mmu_isolate_pages(invalid_list);
- sp = list_first_entry(invalid_list, struct kvm_mmu_page, link);
- list_del_init(invalid_list);
-
- trace_kvm_mmu_delay_free_pages(sp);
- call_rcu(&sp->rcu, free_pages_rcu);
+ while (!list_empty(invalid_list)) {
+ sp = list_first_entry(invalid_list, struct kvm_mmu_page, link);
+ list_del(&sp->link);
+ trace_kvm_mmu_delay_free_pages(sp);
+ call_rcu(&sp->rcu, free_page_rcu);
+ }
}
/*
--
1.7.10
next prev parent reply other threads:[~2012-04-19 16:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-19 16:26 [PATCH 0/2] Simplify RCU freeing of shadow pages Avi Kivity
2012-04-19 16:26 ` [PATCH 1/2] KVM: MMU: Always free shadow pages using RCU Avi Kivity
2012-04-19 16:26 ` Avi Kivity [this message]
2012-04-20 4:05 ` [PATCH 0/2] Simplify RCU freeing of shadow pages Xiao Guangrong
2012-04-22 13:24 ` Avi Kivity
2012-04-23 7:28 ` Xiao Guangrong
2012-04-21 2:31 ` Marcelo Tosatti
2012-04-22 11:39 ` Avi Kivity
2012-04-23 7:39 ` Xiao Guangrong
2012-04-23 8:53 ` 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=1334852797-28167-3-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=xiaoguangrong@linux.vnet.ibm.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