Skip to content

Commit

Permalink
mm: cma: improve pr_debug log in cma_release()
Browse files Browse the repository at this point in the history
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.

[[email protected]: fix printk warning]

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Charan Teja Reddy <[email protected]>
Reviewed-by: Souptick Joarder <[email protected]>
Reviewed-by: David Hildenbrand <[email protected]>
Acked-by: Vlastimil Babka <[email protected]>
Cc: Vinayak Menon <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Charan Teja Reddy authored and torvalds committed Dec 15, 2020
1 parent a4efc17 commit b8ca396
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,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 %u)\n", __func__, (void *)pages, count);

pfn = page_to_pfn(pages);

Expand Down

0 comments on commit b8ca396

Please sign in to comment.