Skip to contentSkip to conversation

mm: cma: improve pr_debug log in cma_release()

PATCH Applied Charan Teja Reddy 4 participants 4 messages Nov 25, 2020 – Nov 27, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: cma: improve pr_debug log in cma_release()

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.

---
 mm/cma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/cma.c +1 -1
index 7f415d7..07c904b 100644
@@ -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);
 
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Charan Teja Reddy

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.

Quoted 8 lines

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.

Quoted 22 lines
---
 mm/cma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/cma.c +1 -2
index 7f415d7..07c904b 100644
@@ -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

Reviewed-by on v1 1/1
#2 lore raw
In reply to Charan Teja Reddy
Quoted 29 lines · Charan Teja Reddy

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.

---
 mm/cma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/cma.c +0 -0
index 7f415d7..07c904b 100644

mm/cma.c bool cma_release(struct cma *cma, const struct page *pages, unsigned int count) · line 518

Quoted 8 lines
mm/cma.c +1 -1
@@ -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);
 
Signature · 3 lines
Thanks,

David / dhildenb
Acked-by on v1 1/1
#3 lore raw
In reply to Charan Teja Reddy
Quoted 11 lines · Charan Teja Reddy

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.

Quoted 8 lines

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.

Quoted 18 lines
---
  mm/cma.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/cma.c +1 -1
index 7f415d7..07c904b 100644
@@ -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);