[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20131218192001.GA8333@redhat.com>
Date: Wed, 18 Dec 2013 20:20:01 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Andrea Arcangeli <aarcange@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Dave Jones <davej@...hat.com>,
Darren Hart <dvhart@...ux.intel.com>,
Peter Zijlstra <peterz@...radead.org>,
Mel Gorman <mgorman@...e.de>, linux-kernel@...r.kernel.org
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@...hat.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists