]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mm, thp: use list_first_entry_or_null()
authorGeliang Tang <geliangtang@163.com>
Thu, 14 Jan 2016 23:19:32 +0000 (15:19 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 15 Jan 2016 00:00:49 +0000 (16:00 -0800)
Simplify the code with list_first_entry_or_null().

Signed-off-by: Geliang Tang <geliangtang@163.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/pgtable-generic.c

index 7d3db0247983b22b121290c2203ba2c2fb544ec0..4c681baff3632aafc7ed16bb16543cc1c7b7f596 100644 (file)
@@ -176,13 +176,10 @@ pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp)
 
        /* FIFO */
        pgtable = pmd_huge_pte(mm, pmdp);
-       if (list_empty(&pgtable->lru))
-               pmd_huge_pte(mm, pmdp) = NULL;
-       else {
-               pmd_huge_pte(mm, pmdp) = list_entry(pgtable->lru.next,
-                                             struct page, lru);
+       pmd_huge_pte(mm, pmdp) = list_first_entry_or_null(&pgtable->lru,
+                                                         struct page, lru);
+       if (pmd_huge_pte(mm, pmdp))
                list_del(&pgtable->lru);
-       }
        return pgtable;
 }
 #endif