Skip to content

Commit

Permalink
thp: cleanup split_huge_page()
Browse files Browse the repository at this point in the history
After one of bugfixes to freeze_page(), we don't have freezed pages in
rmap, therefore mapcount of all subpages of freezed THP is zero.  And we
have assert for that.

Let's drop code which deal with non-zero mapcount of subpages.

Signed-off-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>
  • Loading branch information
kiryl authored and torvalds committed Mar 15, 2016
1 parent 88193f7 commit 8df651c
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions mm/huge_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -3220,28 +3220,26 @@ static void unfreeze_page(struct anon_vma *anon_vma, struct page *page)
}
}

static int __split_huge_page_tail(struct page *head, int tail,
static void __split_huge_page_tail(struct page *head, int tail,
struct lruvec *lruvec, struct list_head *list)
{
int mapcount;
struct page *page_tail = head + tail;

mapcount = atomic_read(&page_tail->_mapcount) + 1;
VM_BUG_ON_PAGE(atomic_read(&page_tail->_mapcount) != -1, page_tail);
VM_BUG_ON_PAGE(atomic_read(&page_tail->_count) != 0, page_tail);

/*
* tail_page->_count is zero and not changing from under us. But
* get_page_unless_zero() may be running from under us on the
* tail_page. If we used atomic_set() below instead of atomic_add(), we
* tail_page. If we used atomic_set() below instead of atomic_inc(), we
* would then run atomic_set() concurrently with
* get_page_unless_zero(), and atomic_set() is implemented in C not
* using locked ops. spin_unlock on x86 sometime uses locked ops
* because of PPro errata 66, 92, so unless somebody can guarantee
* atomic_set() here would be safe on all archs (and not only on x86),
* it's safer to use atomic_add().
* it's safer to use atomic_inc().
*/
atomic_add(mapcount + 1, &page_tail->_count);

atomic_inc(&page_tail->_count);

page_tail->flags &= ~PAGE_FLAGS_CHECK_AT_PREP;
page_tail->flags |= (head->flags &
Expand Down Expand Up @@ -3275,16 +3273,14 @@ static int __split_huge_page_tail(struct page *head, int tail,
page_tail->index = head->index + tail;
page_cpupid_xchg_last(page_tail, page_cpupid_last(head));
lru_add_page_tail(head, page_tail, lruvec, list);

return mapcount;
}

static void __split_huge_page(struct page *page, struct list_head *list)
{
struct page *head = compound_head(page);
struct zone *zone = page_zone(head);
struct lruvec *lruvec;
int i, tail_mapcount;
int i;

/* prevent PageLRU to go away from under us, and freeze lru stats */
spin_lock_irq(&zone->lru_lock);
Expand All @@ -3293,10 +3289,8 @@ static void __split_huge_page(struct page *page, struct list_head *list)
/* complete memcg works before add pages to LRU */
mem_cgroup_split_huge_fixup(head);

tail_mapcount = 0;
for (i = HPAGE_PMD_NR - 1; i >= 1; i--)
tail_mapcount += __split_huge_page_tail(head, i, lruvec, list);
atomic_sub(tail_mapcount, &head->_count);
__split_huge_page_tail(head, i, lruvec, list);

ClearPageCompound(head);
spin_unlock_irq(&zone->lru_lock);
Expand Down

0 comments on commit 8df651c

Please sign in to comment.