summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@163.com>2016-01-14 23:19:32 (GMT)
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-15 00:00:49 (GMT)
commit146693471f1df44115cf4aaf13c33618619ad855 (patch)
tree3bcdc95d68d963b87582faf937999d28f954e269
parent8cee852ec53fb530f10ccabf1596734209ae336b (diff)
downloadlinux-146693471f1df44115cf4aaf13c33618619ad855.tar.xz
mm, thp: use list_first_entry_or_null()
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>
-rw-r--r--mm/pgtable-generic.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index 7d3db02..4c681ba 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -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