Skip to content

Commit 79049bb

Browse files
Gavin Shanakpm00
authored andcommitted
mm/debug: fix parameter passed to page_mapcount_is_type()
As the comments of page_mapcount_is_type() indicate, the parameter passed to the function should be one more than page->_mapcount. However, page->_mapcount is passed to the function by commit 4ffca5a ("mm: support only one page_type per page") where page_type_has_type() is replaced by page_mapcount_is_type(), but the parameter isn't adjusted. Fix the parameter for page_mapcount_is_type() to be (page->__mapcount + 1). Note that the issue doesn't cause any visible impacts due to the safety gap introduced by PGTY_mapcount_underflow limit. [[email protected]: simplify __dump_folio(), per David] Link: https://lkml.kernel.org/r/[email protected] Fixes: 4ffca5a ("mm: support only one page_type per page") Signed-off-by: Gavin Shan <[email protected]> Acked-by: David Hildenbrand <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: gehao <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Miaohe Lin <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 979f3ef commit 79049bb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mm/debug.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ static void __dump_folio(struct folio *folio, struct page *page,
7171
unsigned long pfn, unsigned long idx)
7272
{
7373
struct address_space *mapping = folio_mapping(folio);
74-
int mapcount = atomic_read(&page->_mapcount);
74+
int mapcount = atomic_read(&page->_mapcount) + 1;
7575
char *type = "";
7676

77-
mapcount = page_mapcount_is_type(mapcount) ? 0 : mapcount + 1;
77+
if (page_mapcount_is_type(mapcount))
78+
mapcount = 0;
79+
7880
pr_warn("page: refcount:%d mapcount:%d mapping:%p index:%#lx pfn:%#lx\n",
7981
folio_ref_count(folio), mapcount, mapping,
8082
folio->index + idx, pfn);

0 commit comments

Comments
 (0)