KVM: x86: use list_last_entry
authorGeliang Tang <geliangtang@163.com>
Fri, 1 Jan 2016 11:47:14 +0000 (19:47 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 23 Feb 2016 14:40:54 +0000 (15:40 +0100)
To make the intention clearer, use list_last_entry instead of
list_entry.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu.c
arch/x86/kvm/vmx.c

index 2ce389245bd8ca8f50de873e7c505d378bc9817b..07f4c26a10d3b14dfa75625f05b69bf68172a91a 100644 (file)
@@ -2354,8 +2354,8 @@ static bool prepare_zap_oldest_mmu_page(struct kvm *kvm,
        if (list_empty(&kvm->arch.active_mmu_pages))
                return false;
 
-       sp = list_entry(kvm->arch.active_mmu_pages.prev,
-                       struct kvm_mmu_page, link);
+       sp = list_last_entry(&kvm->arch.active_mmu_pages,
+                            struct kvm_mmu_page, link);
        kvm_mmu_prepare_zap_page(kvm, sp, invalid_list);
 
        return true;
index 9f08037ef14be3f372c40349f2570c42e8eb2a9c..aa16d5874fe672c5533c86862ab46201aee4e82e 100644 (file)
@@ -6445,8 +6445,8 @@ static struct loaded_vmcs *nested_get_current_vmcs02(struct vcpu_vmx *vmx)
 
        if (vmx->nested.vmcs02_num >= max(VMCS02_POOL_SIZE, 1)) {
                /* Recycle the least recently used VMCS. */
-               item = list_entry(vmx->nested.vmcs02_pool.prev,
-                       struct vmcs02_list, list);
+               item = list_last_entry(&vmx->nested.vmcs02_pool,
+                                      struct vmcs02_list, list);
                item->vmptr = vmx->nested.current_vmptr;
                list_move(&item->list, &vmx->nested.vmcs02_pool);
                return &item->vmcs02;