linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm, thp: use list_first_entry_or_null()
@ 2015-11-18 13:52 Geliang Tang
  2015-11-18 14:17 ` Kirill A. Shutemov
  0 siblings, 1 reply; 2+ messages in thread
From: Geliang Tang @ 2015-11-18 13:52 UTC (permalink / raw)
  To: Andrew Morton, Kirill A. Shutemov, Aneesh Kumar K.V,
	Vineet Gupta, Mel Gorman
  Cc: Geliang Tang, linux-mm, linux-kernel

Simplify the code with list_first_entry_or_null().

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 mm/pgtable-generic.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index 69261d4..c311a2e 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -164,13 +164,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
-- 
2.5.0


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-18 14:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-18 13:52 [PATCH] mm, thp: use list_first_entry_or_null() Geliang Tang
2015-11-18 14:17 ` Kirill A. Shutemov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox