KVM: MMU: cleanup for function unaccount_shadowed()
authorWei Yongjun <yjwei@cn.fujitsu.com>
Fri, 16 Apr 2010 08:21:42 +0000 (16:21 +0800)
committerAvi Kivity <avi@redhat.com>
Mon, 17 May 2010 09:18:12 +0000 (12:18 +0300)
Since gfn is not changed in the for loop, we do not need to call
gfn_to_memslot_unaliased() under the loop, and it is safe to move
it out.

Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/mmu.c

index d2a110e870fabfbce8bd152c435f5f7055414fa0..ddfa8658fb6d3ad74f9752607c28786d01ac91ac 100644 (file)
@@ -431,9 +431,9 @@ static void unaccount_shadowed(struct kvm *kvm, gfn_t gfn)
        int i;
 
        gfn = unalias_gfn(kvm, gfn);
+       slot = gfn_to_memslot_unaliased(kvm, gfn);
        for (i = PT_DIRECTORY_LEVEL;
             i < PT_PAGE_TABLE_LEVEL + KVM_NR_PAGE_SIZES; ++i) {
-               slot          = gfn_to_memslot_unaliased(kvm, gfn);
                write_count   = slot_largepage_idx(gfn, slot, i);
                *write_count -= 1;
                WARN_ON(*write_count < 0);