kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: MMU: simplify folding of dirty bit into accessed_dirty
@ 2012-12-27 12:44 Gleb Natapov
  2013-01-07 22:31 ` Marcelo Tosatti
  0 siblings, 1 reply; 2+ messages in thread
From: Gleb Natapov @ 2012-12-27 12:44 UTC (permalink / raw)
  To: kvm; +Cc: mtosatti

MMU code tries to avoid if()s HW is not able to predict reliably by using
bitwise operation to streamline code execution, but in case of a dirty bit
folding this gives us nothing since write_fault is checked right before
the folding code. Lets just piggyback onto the if() to make code more clear.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 891eb6d..a7b24cf 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -249,16 +249,12 @@ retry_walk:
 
 	if (!write_fault)
 		protect_clean_gpte(&pte_access, pte);
-
-	/*
-	 * On a write fault, fold the dirty bit into accessed_dirty by shifting it one
-	 * place right.
-	 *
-	 * On a read fault, do nothing.
-	 */
-	shift = write_fault >> ilog2(PFERR_WRITE_MASK);
-	shift *= PT_DIRTY_SHIFT - PT_ACCESSED_SHIFT;
-	accessed_dirty &= pte >> shift;
+	else
+		/*
+		 * On a write fault, fold the dirty bit into accessed_dirty by
+		 * shifting it one place right.
+		 */
+		accessed_dirty &= pte >> (PT_DIRTY_SHIFT - PT_ACCESSED_SHIFT);
 
 	if (unlikely(!accessed_dirty)) {
 		ret = FNAME(update_accessed_dirty_bits)(vcpu, mmu, walker, write_fault);
--
			Gleb.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: MMU: simplify folding of dirty bit into accessed_dirty
  2012-12-27 12:44 [PATCH] KVM: MMU: simplify folding of dirty bit into accessed_dirty Gleb Natapov
@ 2013-01-07 22:31 ` Marcelo Tosatti
  0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2013-01-07 22:31 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm

On Thu, Dec 27, 2012 at 02:44:58PM +0200, Gleb Natapov wrote:
> MMU code tries to avoid if()s HW is not able to predict reliably by using
> bitwise operation to streamline code execution, but in case of a dirty bit
> folding this gives us nothing since write_fault is checked right before
> the folding code. Lets just piggyback onto the if() to make code more clear.
> 
> Signed-off-by: Gleb Natapov <gleb@redhat.com>

Applied, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-07 23:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-27 12:44 [PATCH] KVM: MMU: simplify folding of dirty bit into accessed_dirty Gleb Natapov
2013-01-07 22:31 ` Marcelo Tosatti

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).