Skip to content

Commit dc8fb2f

Browse files
johnhubbardtorvalds
authored andcommitted
mm: dump_page(): additional diagnostics for huge pinned pages
As part of pin_user_pages() and related API calls, pages are "dma-pinned". For the case of compound pages of order > 1, the per-page accounting of dma pins is accomplished via the 3rd struct page in the compound page. In order to support debugging of any pin_user_pages()- related problems, enhance dump_page() so as to report the pin count in that case. Documentation/core-api/pin_user_pages.rst is also updated accordingly. Signed-off-by: John Hubbard <jhubbard@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Jan Kara <jack@suse.cz> Cc: Matthew Wilcox <willy@infradead.org> Cc: Ira Weiny <ira.weiny@intel.com> Cc: Jérôme Glisse <jglisse@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Christoph Hellwig <hch@infradead.org> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Dave Chinner <david@fromorbit.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Kravetz <mike.kravetz@oracle.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Vlastimil Babka <vbabka@suse.cz> Link: http://lkml.kernel.org/r/20200211001536.1027652-13-jhubbard@nvidia.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6197ab9 commit dc8fb2f

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

‎Documentation/core-api/pin_user_pages.rst‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ long-term [R]DMA pins in place, or during pin/unpin transitions.
238238
(...unless it was already out of balance due to a long-term RDMA pin being in
239239
place.)
240240

241+
Other diagnostics
242+
=================
243+
244+
dump_page() has been enhanced slightly, to handle these new counting fields, and
245+
to better report on compound pages in general. Specifically, for compound pages
246+
with order > 1, the exact (hpage_pinned_refcount) pincount is reported.
247+
241248
References
242249
==========
243250

‎mm/debug.c‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,22 @@ void __dump_page(struct page *page, const char *reason)
8585
mapcount = PageSlab(head) ? 0 : page_mapcount(page);
8686

8787
if (compound)
88-
pr_warn("page:%px refcount:%d mapcount:%d mapping:%p "
89-
"index:%#lx head:%px order:%u compound_mapcount:%d\n",
90-
page, page_ref_count(head), mapcount,
91-
mapping, page_to_pgoff(page), head,
92-
compound_order(head), compound_mapcount(page));
88+
if (hpage_pincount_available(page)) {
89+
pr_warn("page:%px refcount:%d mapcount:%d mapping:%p "
90+
"index:%#lx head:%px order:%u "
91+
"compound_mapcount:%d compound_pincount:%d\n",
92+
page, page_ref_count(head), mapcount,
93+
mapping, page_to_pgoff(page), head,
94+
compound_order(head), compound_mapcount(page),
95+
compound_pincount(page));
96+
} else {
97+
pr_warn("page:%px refcount:%d mapcount:%d mapping:%p "
98+
"index:%#lx head:%px order:%u "
99+
"compound_mapcount:%d\n",
100+
page, page_ref_count(head), mapcount,
101+
mapping, page_to_pgoff(page), head,
102+
compound_order(head), compound_mapcount(page));
103+
}
93104
else
94105
pr_warn("page:%px refcount:%d mapcount:%d mapping:%p index:%#lx\n",
95106
page, page_ref_count(page), mapcount,

0 commit comments

Comments
 (0)