Skip to content

Commit 74e8ee4

Browse files
author
Matthew Wilcox (Oracle)
committed
mm: Turn head_compound_mapcount() into folio_entire_mapcount()
Adjust documentation to be more clear. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent e20c41b commit 74e8ee4

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

include/linux/mm.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -776,21 +776,26 @@ static inline int is_vmalloc_or_module_addr(const void *x)
776776
}
777777
#endif
778778

779-
static inline int head_compound_mapcount(struct page *head)
779+
/*
780+
* How many times the entire folio is mapped as a single unit (eg by a
781+
* PMD or PUD entry). This is probably not what you want, except for
782+
* debugging purposes; look at folio_mapcount() or page_mapcount()
783+
* instead.
784+
*/
785+
static inline int folio_entire_mapcount(struct folio *folio)
780786
{
781-
return atomic_read(compound_mapcount_ptr(head)) + 1;
787+
VM_BUG_ON_FOLIO(!folio_test_large(folio), folio);
788+
return atomic_read(folio_mapcount_ptr(folio)) + 1;
782789
}
783790

784791
/*
785792
* Mapcount of compound page as a whole, does not include mapped sub-pages.
786793
*
787-
* Must be called only for compound pages or any their tail sub-pages.
794+
* Must be called only for compound pages.
788795
*/
789796
static inline int compound_mapcount(struct page *page)
790797
{
791-
VM_BUG_ON_PAGE(!PageCompound(page), page);
792-
page = compound_head(page);
793-
return head_compound_mapcount(page);
798+
return folio_entire_mapcount(page_folio(page));
794799
}
795800

796801
/*

mm/debug.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ const struct trace_print_flags vmaflag_names[] = {
4848

4949
static void __dump_page(struct page *page)
5050
{
51-
struct page *head = compound_head(page);
51+
struct folio *folio = page_folio(page);
52+
struct page *head = &folio->page;
5253
struct address_space *mapping;
5354
bool compound = PageCompound(page);
5455
/*
@@ -76,6 +77,7 @@ static void __dump_page(struct page *page)
7677
else
7778
mapping = (void *)(tmp & ~PAGE_MAPPING_FLAGS);
7879
head = page;
80+
folio = (struct folio *)page;
7981
compound = false;
8082
} else {
8183
mapping = page_mapping(page);
@@ -94,7 +96,7 @@ static void __dump_page(struct page *page)
9496
if (compound) {
9597
pr_warn("head:%p order:%u compound_mapcount:%d compound_pincount:%d\n",
9698
head, compound_order(head),
97-
head_compound_mapcount(head),
99+
folio_entire_mapcount(folio),
98100
head_compound_pincount(head));
99101
}
100102

0 commit comments

Comments
 (0)