public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	KVM list <kvm@vger.kernel.org>
Subject: [PATCH 2/3] KVM: MMU: move bits lost judgement into a separate function
Date: Tue, 27 Jul 2010 11:33:02 +0800	[thread overview]
Message-ID: <4C4E536E.7030109@cn.fujitsu.com> (raw)
In-Reply-To: <4C4E5313.1080308@cn.fujitsu.com>

Introduce spte_bits_lost() function to judge whether spte bits will
miss, it's more readable and can help us to cleanup code later

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
 arch/x86/kvm/mmu.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index e10f2bd..dd6c192 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -303,6 +303,20 @@ static u64 __xchg_spte(u64 *sptep, u64 new_spte)
 #endif
 }
 
+static bool spte_bits_lost(u64 spte)
+{
+	if (!shadow_accessed_mask)
+		return false;
+
+	if (!is_shadow_present_pte(spte))
+		return false;
+
+	if (spte & shadow_accessed_mask)
+		return false;
+
+	return true;
+}
+
 static void update_spte(u64 *sptep, u64 new_spte)
 {
 	u64 old_spte;
@@ -683,14 +697,14 @@ static void set_spte_track_bits(u64 *sptep, u64 new_spte)
 	pfn_t pfn;
 	u64 old_spte = *sptep;
 
-	if (!shadow_accessed_mask || !is_shadow_present_pte(old_spte) ||
-	      old_spte & shadow_accessed_mask) {
+	if (!spte_bits_lost(old_spte))
 		__set_spte(sptep, new_spte);
-	} else
+	else
 		old_spte = __xchg_spte(sptep, new_spte);
 
 	if (!is_rmap_spte(old_spte))
 		return;
+
 	pfn = spte_to_pfn(old_spte);
 	if (!shadow_accessed_mask || old_spte & shadow_accessed_mask)
 		kvm_set_pfn_accessed(pfn);
-- 
1.6.1.2



  reply	other threads:[~2010-07-27  3:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-27  3:31 [PATCH 1/3] KVM: MMU: using kvm_set_pfn_accessed() instead of mark_page_accessed() Xiao Guangrong
2010-07-27  3:33 ` Xiao Guangrong [this message]
2010-07-27  3:35   ` [PATCH 3/3] KVM: MMU: mark page dirty only when page is really written Xiao Guangrong
2010-08-02  7:50     ` Avi Kivity
2010-08-02  7:51       ` Xiao Guangrong
2010-08-02  8:15     ` [PATCH v2 " Xiao Guangrong
2010-08-02  7:41   ` [PATCH 2/3] KVM: MMU: move bits lost judgement into a separate function Avi Kivity
2010-08-02  7:50     ` Xiao Guangrong
2010-08-02  8:14   ` [PATCH v2 " Xiao Guangrong
2010-08-02  8:12 ` [PATCH v2 1/3] KVM: MMU: using kvm_set_pfn_accessed() instead of mark_page_accessed() Xiao Guangrong
2010-08-02  9: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=4C4E536E.7030109@cn.fujitsu.com \
    --to=xiaoguangrong@cn.fujitsu.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.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