kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Cc: mtosatti@redhat.com, kvm@vger.kernel.org, takuya.yoshikawa@gmail.com
Subject: Re: [PATCH 3/3] KVM: MMU: Make drop_large_spte() more generic
Date: Mon, 26 Dec 2011 15:15:48 +0200	[thread overview]
Message-ID: <4EF87384.1090006@redhat.com> (raw)
In-Reply-To: <20111129140427.9279689f.yoshikawa.takuya@oss.ntt.co.jp>

On 11/29/2011 07:04 AM, Takuya Yoshikawa wrote:
> There are many places where we drop large spte and we are always doing
> much the same as drop_large_spte().
>
> To avoid these duplications, this patch makes drop_large_spte() more
> generically usable: it now takes an argument to know if it must flush
> the remote tlbs and returns true or false depending on is_large_pte()
> check result.

> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 5e761ff..2db12b3 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -1023,6 +1023,19 @@ static void drop_spte(struct kvm *kvm, u64 *sptep)
>  		rmap_remove(kvm, sptep);
>  }
>  
> +static bool drop_large_spte(struct kvm *kvm, u64 *sptep, bool flush_now)
> +{
> +	if (!is_large_pte(*sptep))
> +		return false;
> +
> +	drop_spte(kvm, sptep);
> +	--kvm->stat.lpages;
> +
> +	if (flush_now)
> +		kvm_flush_remote_tlbs(kvm);
> +	return true;
> +}

I don't really like the pattern of adding more bools and conditionals
all over the place.  It makes the code harder to read and to execute.

I prefer separate functions like drop_large_spte() and
drop_large_spte_flush().

But it may be better to just drop kvm->stat, and open-code everything,
something like

   if (is_large_pte(*sptep))
       drop_spte(sptep)

is just as clear as drop_large_spte().

> @@ -1839,9 +1842,8 @@ static bool mmu_page_zap_pte(struct kvm *kvm, struct kvm_mmu_page *sp,
>  	pte = *spte;
>  	if (is_shadow_present_pte(pte)) {
>  		if (is_last_spte(pte, sp->role.level)) {
> -			drop_spte(kvm, spte);
> -			if (is_large_pte(pte))
> -				--kvm->stat.lpages;
> +			if (!drop_large_spte(kvm, spte, false))
> +				drop_spte(kvm, spte);

Now this is just confusing.


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


  reply	other threads:[~2011-12-26 13:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-29  5:01 [PATCH 0/3] KVM: MMU: Trivial fix and cleanups Takuya Yoshikawa
2011-11-29  5:02 ` [PATCH 1/3] KVM: MMU: Remove for_each_unsync_children() macro Takuya Yoshikawa
2011-11-29  5:03 ` [PATCH 2/3] KVM: MMU: Add missing large page accounting to drop_large_spte() Takuya Yoshikawa
2011-12-20  4:37   ` Takuya Yoshikawa
2011-12-26 13:11     ` Avi Kivity
2011-11-29  5:04 ` [PATCH 3/3] KVM: MMU: Make drop_large_spte() more generic Takuya Yoshikawa
2011-12-26 13:15   ` Avi Kivity [this message]
2011-12-26 13:17 ` [PATCH 0/3] KVM: MMU: Trivial fix and cleanups 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=4EF87384.1090006@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=takuya.yoshikawa@gmail.com \
    --cc=yoshikawa.takuya@oss.ntt.co.jp \
    /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).