Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1272187 > unrolled thread

[PATCH] mm, thp: use list_first_entry_or_null()

Started byGeliang Tang <geliangtang@163.com>
First post2015-11-18 15:00 +0100
Last post2015-11-18 15:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mm, thp: use list_first_entry_or_null() Geliang Tang <geliangtang@163.com> - 2015-11-18 15:00 +0100
    Re: [PATCH] mm, thp: use list_first_entry_or_null() "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-18 15:20 +0100

#1272187 — [PATCH] mm, thp: use list_first_entry_or_null()

FromGeliang Tang <geliangtang@163.com>
Date2015-11-18 15:00 +0100
Subject[PATCH] mm, thp: use list_first_entry_or_null()
Message-ID<qwbrb-3Dk-1@gated-at.bofh.it>
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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1272206

From"Kirill A. Shutemov" <kirill@shutemov.name>
Date2015-11-18 15:20 +0100
Message-ID<qwbKx-3ZJ-1@gated-at.bofh.it>
In reply to#1272187
On Wed, Nov 18, 2015 at 09:52:29PM +0800, Geliang Tang wrote:
> Simplify the code with list_first_entry_or_null().
> 
> Signed-off-by: Geliang Tang <geliangtang@163.com>

Looks good to me.

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

-- 
 Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web