From: Marcelo Tosatti <mtosatti@redhat.com>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Avi Kivity <avi@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
kvm@vger.kernel.org
Subject: Re: [PATCH] kvm x86 mmu: simplify kvm_mmu_unlink_parents()
Date: Mon, 19 Apr 2010 21:59:37 -0300 [thread overview]
Message-ID: <20100420005937.GA17981@amt.cnet> (raw)
In-Reply-To: <4BC97645.8050009@cn.fujitsu.com>
On Sat, Apr 17, 2010 at 04:50:13PM +0800, Lai Jiangshan wrote:
>
> mmu_page_remove_parent_pte() does much maintenance works,
> but kvm_mmu_unlink_parents() unlink all parents, so
> such maintenance works are not need.
>
> This patch simplifies the works of kvm_mmu_unlink_parents()
> by unlinking parents without so many maintenance works.
>
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> ---
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 90f666e..71faa04 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -1453,22 +1453,33 @@ static void kvm_mmu_reset_last_pte_updated(struct kvm *kvm)
>
> static void kvm_mmu_unlink_parents(struct kvm *kvm, struct kvm_mmu_page *sp)
> {
> - u64 *parent_pte;
> + if (!sp->multimapped) {
> + if (!sp->parent_pte)
> + return;
>
> - while (sp->multimapped || sp->parent_pte) {
> - if (!sp->multimapped)
> - parent_pte = sp->parent_pte;
> - else {
> - struct kvm_pte_chain *chain;
> + __set_spte(sp->parent_pte, shadow_trap_nonpresent_pte);
> + sp->parent_pte = NULL;
> + return;
> + }
>
> - chain = container_of(sp->parent_ptes.first,
> - struct kvm_pte_chain, link);
> - parent_pte = chain->parent_ptes[0];
> + while (!hlist_empty(&sp->parent_ptes)) {
> + struct kvm_pte_chain *chain;
> + u64 *parent_pte;
> + int i;
> +
> + chain = hlist_entry(sp->parent_ptes.first,
> + struct kvm_pte_chain, link);
> + for (i = 0; i < NR_PTE_CHAIN_ENTRIES; ++i) {
> + parent_pte = chain->parent_ptes[i];
> + if (!parent_pte)
> + break;
> + __set_spte(parent_pte, shadow_trap_nonpresent_pte);
> }
> - BUG_ON(!parent_pte);
> - kvm_mmu_put_page(sp, parent_pte);
> - __set_spte(parent_pte, shadow_trap_nonpresent_pte);
> + hlist_del(&chain->link);
> + mmu_free_pte_chain(chain);
> }
> + sp->multimapped = 0;
> + sp->parent_pte = NULL;
> }
>
> static int mmu_zap_unsync_children(struct kvm *kvm,
>
Personally i don't see why this is any better than the previous code.
prev parent reply other threads:[~2010-04-20 1:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-17 8:50 [PATCH] kvm x86 mmu: simplify kvm_mmu_unlink_parents() Lai Jiangshan
2010-04-20 0:59 ` Marcelo Tosatti [this message]
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=20100420005937.GA17981@amt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
/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 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.