提交 908e7d79 编写于 作者: G Gleb Natapov 提交者: Marcelo Tosatti

KVM: MMU: simplify folding of dirty bit into accessed_dirty

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: NGleb Natapov <gleb@redhat.com>
Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
上级 ee04e0ce
...@@ -249,16 +249,12 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, ...@@ -249,16 +249,12 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
if (!write_fault) if (!write_fault)
protect_clean_gpte(&pte_access, pte); protect_clean_gpte(&pte_access, pte);
else
/* /*
* On a write fault, fold the dirty bit into accessed_dirty by shifting it one * On a write fault, fold the dirty bit into accessed_dirty by
* place right. * shifting it one place right.
* */
* On a read fault, do nothing. accessed_dirty &= pte >> (PT_DIRTY_SHIFT - PT_ACCESSED_SHIFT);
*/
shift = write_fault >> ilog2(PFERR_WRITE_MASK);
shift *= PT_DIRTY_SHIFT - PT_ACCESSED_SHIFT;
accessed_dirty &= pte >> shift;
if (unlikely(!accessed_dirty)) { if (unlikely(!accessed_dirty)) {
ret = FNAME(update_accessed_dirty_bits)(vcpu, mmu, walker, write_fault); ret = FNAME(update_accessed_dirty_bits)(vcpu, mmu, walker, write_fault);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册