diff mbox series

[v3,09/12] mm: dump_page(): better diagnostics for huge pinned pages

Message ID 20200201034029.4063170-10-jhubbard@nvidia.com (mailing list archive)
State Superseded
Headers show
Series mm/gup: track FOLL_PIN pages | expand

Commit Message

John Hubbard Feb. 1, 2020, 3:40 a.m. UTC
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>
---
 Documentation/core-api/pin_user_pages.rst |  7 +++++
 mm/debug.c                                | 34 +++++++++++++++++------
 2 files changed, 33 insertions(+), 8 deletions(-)

Comments

Kirill A. Shutemov Feb. 3, 2020, 1:46 p.m. UTC | #1
On Fri, Jan 31, 2020 at 07:40:26PM -0800, John Hubbard wrote:
> 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>

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Jan Kara Feb. 3, 2020, 2:44 p.m. UTC | #2
On Fri 31-01-20 19:40:26, John Hubbard wrote:
> 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>

Looks good to me. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

									Honza

> ---
>  Documentation/core-api/pin_user_pages.rst |  7 +++++
>  mm/debug.c                                | 34 +++++++++++++++++------
>  2 files changed, 33 insertions(+), 8 deletions(-)
> 
> diff --git a/Documentation/core-api/pin_user_pages.rst b/Documentation/core-api/pin_user_pages.rst
> index 3f72b1ea1104..dd21ea140ef4 100644
> --- a/Documentation/core-api/pin_user_pages.rst
> +++ b/Documentation/core-api/pin_user_pages.rst
> @@ -215,6 +215,13 @@ Those are both going to show zero, unless CONFIG_DEBUG_VM is set. This is
>  because there is a noticeable performance drop in unpin_user_page(), when they
>  are activated.
>  
> +Other diagnostics
> +=================
> +
> +dump_page() has been enhanced slightly, to handle these new counting fields, and
> +to better report on compound pages in general. Specifically, for compound pages
> +with order > 1, the exact (hpage_pinned_refcount) pincount is reported.
> +
>  References
>  ==========
>  
> diff --git a/mm/debug.c b/mm/debug.c
> index beb1c59d784b..db81b11345be 100644
> --- a/mm/debug.c
> +++ b/mm/debug.c
> @@ -57,10 +57,20 @@ static void __dump_tail_page(struct page *page, int mapcount)
>  			page, page_ref_count(page), mapcount, page->mapping,
>  			page_to_pgoff(page));
>  	} else {
> -		pr_warn("page:%px compound refcount:%d mapcount:%d mapping:%px "
> -			"index:%#lx compound_mapcount:%d\n",
> -			page, page_ref_count(head), mapcount, head->mapping,
> -			page_to_pgoff(head), compound_mapcount(page));
> +		if (hpage_pincount_available(page))
> +			pr_warn("page:%px compound refcount:%d mapcount:%d "
> +				"mapping:%px index:%#lx compound_mapcount:%d "
> +				"compound_pincount:%d\n",
> +				page, page_ref_count(head), mapcount,
> +				head->mapping, page_to_pgoff(head),
> +				compound_mapcount(page),
> +				compound_pincount(page));
> +		else
> +			pr_warn("page:%px compound refcount:%d mapcount:%d "
> +				"mapping:%px index:%#lx compound_mapcount:%d\n",
> +				page, page_ref_count(head), mapcount,
> +				head->mapping, page_to_pgoff(head),
> +				compound_mapcount(page));
>  	}
>  
>  	if (page_ref_count(page) != 0)
> @@ -103,10 +113,18 @@ void __dump_page(struct page *page, const char *reason)
>  
>  	if (PageTail(page))
>  		__dump_tail_page(page, mapcount);
> -	else
> -		pr_warn("page:%px refcount:%d mapcount:%d mapping:%px index:%#lx\n",
> -			page, page_ref_count(page), mapcount,
> -			page->mapping, page_to_pgoff(page));
> +	else {
> +		if (hpage_pincount_available(page))
> +			pr_warn("page:%px refcount:%d mapcount:%d mapping:%px "
> +				"index:%#lx compound pincount: %d\n",
> +				page, page_ref_count(page), mapcount,
> +				page->mapping, page_to_pgoff(page),
> +				compound_pincount(page));
> +		else
> +			pr_warn("page:%px refcount:%d mapcount:%d mapping:%px "
> +				"index:%#lx\n", page, page_ref_count(page),
> +				mapcount, page->mapping, page_to_pgoff(page));
> +	}
>  	if (PageKsm(page))
>  		type = "ksm ";
>  	else if (PageAnon(page))
> -- 
> 2.25.0
>
diff mbox series

Patch

diff --git a/Documentation/core-api/pin_user_pages.rst b/Documentation/core-api/pin_user_pages.rst
index 3f72b1ea1104..dd21ea140ef4 100644
--- a/Documentation/core-api/pin_user_pages.rst
+++ b/Documentation/core-api/pin_user_pages.rst
@@ -215,6 +215,13 @@  Those are both going to show zero, unless CONFIG_DEBUG_VM is set. This is
 because there is a noticeable performance drop in unpin_user_page(), when they
 are activated.
 
+Other diagnostics
+=================
+
+dump_page() has been enhanced slightly, to handle these new counting fields, and
+to better report on compound pages in general. Specifically, for compound pages
+with order > 1, the exact (hpage_pinned_refcount) pincount is reported.
+
 References
 ==========
 
diff --git a/mm/debug.c b/mm/debug.c
index beb1c59d784b..db81b11345be 100644
--- a/mm/debug.c
+++ b/mm/debug.c
@@ -57,10 +57,20 @@  static void __dump_tail_page(struct page *page, int mapcount)
 			page, page_ref_count(page), mapcount, page->mapping,
 			page_to_pgoff(page));
 	} else {
-		pr_warn("page:%px compound refcount:%d mapcount:%d mapping:%px "
-			"index:%#lx compound_mapcount:%d\n",
-			page, page_ref_count(head), mapcount, head->mapping,
-			page_to_pgoff(head), compound_mapcount(page));
+		if (hpage_pincount_available(page))
+			pr_warn("page:%px compound refcount:%d mapcount:%d "
+				"mapping:%px index:%#lx compound_mapcount:%d "
+				"compound_pincount:%d\n",
+				page, page_ref_count(head), mapcount,
+				head->mapping, page_to_pgoff(head),
+				compound_mapcount(page),
+				compound_pincount(page));
+		else
+			pr_warn("page:%px compound refcount:%d mapcount:%d "
+				"mapping:%px index:%#lx compound_mapcount:%d\n",
+				page, page_ref_count(head), mapcount,
+				head->mapping, page_to_pgoff(head),
+				compound_mapcount(page));
 	}
 
 	if (page_ref_count(page) != 0)
@@ -103,10 +113,18 @@  void __dump_page(struct page *page, const char *reason)
 
 	if (PageTail(page))
 		__dump_tail_page(page, mapcount);
-	else
-		pr_warn("page:%px refcount:%d mapcount:%d mapping:%px index:%#lx\n",
-			page, page_ref_count(page), mapcount,
-			page->mapping, page_to_pgoff(page));
+	else {
+		if (hpage_pincount_available(page))
+			pr_warn("page:%px refcount:%d mapcount:%d mapping:%px "
+				"index:%#lx compound pincount: %d\n",
+				page, page_ref_count(page), mapcount,
+				page->mapping, page_to_pgoff(page),
+				compound_pincount(page));
+		else
+			pr_warn("page:%px refcount:%d mapcount:%d mapping:%px "
+				"index:%#lx\n", page, page_ref_count(page),
+				mapcount, page->mapping, page_to_pgoff(page));
+	}
 	if (PageKsm(page))
 		type = "ksm ";
 	else if (PageAnon(page))