Skip to content

Commit

Permalink
mm-prepare-page_referenced-and-page_idle-to-new-thp-refcounting-fix
Browse files Browse the repository at this point in the history
x86_64 allnoconfig:

In file included from mm/rmap.c:47:
include/linux/mm.h: In function 'page_referenced':
include/linux/mm.h:448: error: call to '__compiletime_assert_448' declared with attribute error: BUILD_BUG failed
make[1]: *** [mm/rmap.o] Error 1
make: *** [mm/rmap.o] Error 2

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
kiryl authored and sfrothwell committed Nov 18, 2015
1 parent 61b5451 commit b3ebc51
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
20 changes: 5 additions & 15 deletions include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,24 +433,14 @@ static inline int page_mapcount(struct page *page)
return ret;
}

#ifdef CONFIG_TRANSPARENT_HUGEPAGE
int total_mapcount(struct page *page);
#else
static inline int total_mapcount(struct page *page)
{
int i, ret;

VM_BUG_ON_PAGE(PageTail(page), page);

if (likely(!PageCompound(page)))
return atomic_read(&page->_mapcount) + 1;

ret = compound_mapcount(page);
if (PageHuge(page))
return ret;
for (i = 0; i < HPAGE_PMD_NR; i++)
ret += atomic_read(&page[i]._mapcount) + 1;
if (PageDoubleMap(page))
ret -= HPAGE_PMD_NR;
return ret;
return page_mapcount(page);
}
#endif

static inline int page_count(struct page *page)
{
Expand Down
19 changes: 19 additions & 0 deletions mm/huge_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -3223,6 +3223,25 @@ static void __split_huge_page(struct page *page, struct list_head *list)
}
}

int total_mapcount(struct page *page)
{
int i, ret;

VM_BUG_ON_PAGE(PageTail(page), page);

if (likely(!PageCompound(page)))
return atomic_read(&page->_mapcount) + 1;

ret = compound_mapcount(page);
if (PageHuge(page))
return ret;
for (i = 0; i < HPAGE_PMD_NR; i++)
ret += atomic_read(&page[i]._mapcount) + 1;
if (PageDoubleMap(page))
ret -= HPAGE_PMD_NR;
return ret;
}

/*
* This function splits huge page into normal pages. @page can point to any
* subpage of huge page to split. Split doesn't change the position of @page.
Expand Down

0 comments on commit b3ebc51

Please sign in to comment.