lkml.org 
[lkml]   [2013]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH -mm 5/7] mm: thp: reorganize out_put_single code in __put_page_tail()
The patch looks complicated but it is not. It simply moves the
out_put_single label at the end of the function and changes the
!__compound_tail_refcounted() block to save a tab stop.

This cleanups the code layout a bit, and this is the preparation
for the next change.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
mm/swap.c | 70 ++++++++++++++++++++++++------------------------------------
1 files changed, 28 insertions(+), 42 deletions(-)

diff --git a/mm/swap.c b/mm/swap.c
index 0400f3b..5f3dda6 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -125,42 +125,29 @@ static void __put_page_tail(struct page *page)
* can be freed and reallocated.
*/
smp_rmb();
- if (likely(PageTail(page))) {
- /*
- * __split_huge_page_refcount cannot race
- * here.
- */
- VM_BUG_ON(!PageHead(page_head));
- VM_BUG_ON(page_mapcount(page) != 0);
- if (put_page_testzero(page_head)) {
- /*
- * If this is the tail of a slab
- * compound page, the tail pin must
- * not be the last reference held on
- * the page, because the PG_slab
- * cannot be cleared before all tail
- * pins (which skips the _mapcount
- * tail refcounting) have been
- * released. For hugetlbfs the tail
- * pin may be the last reference on
- * the page instead, because
- * PageHeadHuge will not go away until
- * the compound page enters the buddy
- * allocator.
- */
- VM_BUG_ON(PageSlab(page_head));
- __put_compound_page(page_head);
- }
- return;
- } else
+ if (unlikely(!PageTail(page)))
+ goto out_put_single;
+
+ /*
+ * __split_huge_page_refcount cannot race here.
+ */
+ VM_BUG_ON(!PageHead(page_head));
+ VM_BUG_ON(page_mapcount(page) != 0);
+ if (put_page_testzero(page_head)) {
/*
- * __split_huge_page_refcount run before us,
- * "page" was a THP tail. The split page_head
- * has been freed and reallocated as slab or
- * hugetlbfs page of smaller order (only
- * possible if reallocated as slab on x86).
+ * If this is the tail of a slab compound page, the
+ * tail pin must not be the last reference held on
+ * the page, because the PG_slab cannot be cleared
+ * before all tail pins (which skips the _mapcount
+ * tail refcounting) have been released. For hugetlbfs
+ * the tail pin may be the last reference on the page
+ * instead, because PageHeadHuge will not go away until
+ * the compound page enters the buddy allocator.
*/
- goto out_put_single;
+ VM_BUG_ON(PageSlab(page_head));
+ __put_compound_page(page_head);
+ }
+ return;
}

if (likely(page != page_head && get_page_unless_zero(page_head))) {
@@ -186,10 +173,7 @@ static void __put_page_tail(struct page *page)
* before the split.
*/
__put_nontail_page(page_head);
-out_put_single:
- if (put_page_testzero(page))
- __put_single_page(page);
- return;
+ goto out_put_single;
}
VM_BUG_ON(page_head != page->first_page);
/*
@@ -208,11 +192,13 @@ out_put_single:
compound_unlock_irqrestore(page_head, flags);

__put_nontail_page(page_head);
- } else {
- /* page_head is a dangling pointer */
- VM_BUG_ON(PageTail(page));
- goto out_put_single;
+ return;
}
+
+out_put_single:
+ VM_BUG_ON(PageTail(page));
+ if (put_page_testzero(page))
+ __put_single_page(page);
}

void put_page(struct page *page)
--
1.5.5.1


\
 
 \ /
  Last update: 2013-12-19 05:41    [W:0.224 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site