diff mbox series

mm: cma: improve pr_debug log in cma_release()

Message ID 1606318341-29521-1-git-send-email-charante@codeaurora.org (mailing list archive)
State New, archived
Headers show
Series mm: cma: improve pr_debug log in cma_release() | expand

Commit Message

Charan Teja Kalla Nov. 25, 2020, 3:32 p.m. UTC
It is required to print 'count' of pages, along with the pages, passed
to cma_release to debug the cases of mismatched count value passed
between cma_alloc() and cma_release() from a code path.

As an example, consider the below scenario:
1) CMA pool size is 4MB and
2) User doing the erroneous step of allocating 2 pages but freeing 1
page in a loop from this CMA pool.
The step 2 causes cma_alloc() to return NULL at one point of time
because of -ENOMEM condition.

And the current pr_debug logs is not giving the info about these types
of allocation patterns because of count value not being printed in
cma_release().

We are printing the count value in the trace logs, just extend the same
to pr_debug logs too.

Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
---
 mm/cma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Souptick Joarder Nov. 25, 2020, 3:49 p.m. UTC | #1
On Wed, Nov 25, 2020 at 9:02 PM Charan Teja Reddy
<charante@codeaurora.org> wrote:
>
> It is required to print 'count' of pages, along with the pages, passed
> to cma_release to debug the cases of mismatched count value passed
> between cma_alloc() and cma_release() from a code path.
>
> As an example, consider the below scenario:
> 1) CMA pool size is 4MB and
> 2) User doing the erroneous step of allocating 2 pages but freeing 1
> page in a loop from this CMA pool.
> The step 2 causes cma_alloc() to return NULL at one point of time
> because of -ENOMEM condition.
>
> And the current pr_debug logs is not giving the info about these types
> of allocation patterns because of count value not being printed in
> cma_release().
>
> We are printing the count value in the trace logs, just extend the same
> to pr_debug logs too.
>
> Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>

Reviewed-by: Souptick Joarder <jrdr.linux@gmail.com>

> ---
>  mm/cma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/cma.c b/mm/cma.c
> index 7f415d7..07c904b 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -512,7 +512,7 @@ bool cma_release(struct cma *cma, const struct page *pages, unsigned int count)
>         if (!cma || !pages)
>                 return false;
>
> -       pr_debug("%s(page %p)\n", __func__, (void *)pages);
> +       pr_debug("%s(page %p, count %zu)\n", __func__, (void *)pages, count);
>
>         pfn = page_to_pfn(pages);
>
> --
> QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
> member of the Code Aurora Forum, hosted by The Linux Foundation
>
>
David Hildenbrand Nov. 25, 2020, 4:39 p.m. UTC | #2
On 25.11.20 16:32, Charan Teja Reddy wrote:
> It is required to print 'count' of pages, along with the pages, passed
> to cma_release to debug the cases of mismatched count value passed
> between cma_alloc() and cma_release() from a code path.
> 
> As an example, consider the below scenario:
> 1) CMA pool size is 4MB and
> 2) User doing the erroneous step of allocating 2 pages but freeing 1
> page in a loop from this CMA pool.
> The step 2 causes cma_alloc() to return NULL at one point of time
> because of -ENOMEM condition.
> 
> And the current pr_debug logs is not giving the info about these types
> of allocation patterns because of count value not being printed in
> cma_release().
> 
> We are printing the count value in the trace logs, just extend the same
> to pr_debug logs too.
> 
> Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
> ---
>  mm/cma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/cma.c b/mm/cma.c
> index 7f415d7..07c904b 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -512,7 +512,7 @@ bool cma_release(struct cma *cma, const struct page *pages, unsigned int count)
>  	if (!cma || !pages)
>  		return false;
>  
> -	pr_debug("%s(page %p)\n", __func__, (void *)pages);
> +	pr_debug("%s(page %p, count %zu)\n", __func__, (void *)pages, count);
>  
>  	pfn = page_to_pfn(pages);
>  
> 

Reviewed-by: David Hildenbrand <david@redhat.com>
Vlastimil Babka Nov. 27, 2020, 3:49 p.m. UTC | #3
On 11/25/20 4:32 PM, Charan Teja Reddy wrote:
> It is required to print 'count' of pages, along with the pages, passed
> to cma_release to debug the cases of mismatched count value passed
> between cma_alloc() and cma_release() from a code path.
> 
> As an example, consider the below scenario:
> 1) CMA pool size is 4MB and
> 2) User doing the erroneous step of allocating 2 pages but freeing 1
> page in a loop from this CMA pool.
> The step 2 causes cma_alloc() to return NULL at one point of time
> because of -ENOMEM condition.
> 
> And the current pr_debug logs is not giving the info about these types
> of allocation patterns because of count value not being printed in
> cma_release().
> 
> We are printing the count value in the trace logs, just extend the same
> to pr_debug logs too.
> 
> Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>   mm/cma.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/cma.c b/mm/cma.c
> index 7f415d7..07c904b 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -512,7 +512,7 @@ bool cma_release(struct cma *cma, const struct page *pages, unsigned int count)
>   	if (!cma || !pages)
>   		return false;
>   
> -	pr_debug("%s(page %p)\n", __func__, (void *)pages);
> +	pr_debug("%s(page %p, count %zu)\n", __func__, (void *)pages, count);
>   
>   	pfn = page_to_pfn(pages);
>   
>
diff mbox series

Patch

diff --git a/mm/cma.c b/mm/cma.c
index 7f415d7..07c904b 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -512,7 +512,7 @@  bool cma_release(struct cma *cma, const struct page *pages, unsigned int count)
 	if (!cma || !pages)
 		return false;
 
-	pr_debug("%s(page %p)\n", __func__, (void *)pages);
+	pr_debug("%s(page %p, count %zu)\n", __func__, (void *)pages, count);
 
 	pfn = page_to_pfn(pages);