From 99eef1bd4a4f1d9a1351e68d54cebe86a38afe7c Mon Sep 17 00:00:00 2001 From: Charan Teja Reddy Date: Mon, 14 Dec 2020 19:13:26 -0800 Subject: [PATCH] mm: cma: improve pr_debug log in cma_release() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. [akpm@linux-foundation.org: fix printk warning] Link: https://lkml.kernel.org/r/1606318341-29521-1-git-send-email-charante@codeaurora.org Signed-off-by: Charan Teja Reddy Reviewed-by: Souptick Joarder Reviewed-by: David Hildenbrand Acked-by: Vlastimil Babka Cc: Vinayak Menon Cc: Joonsoo Kim Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Origin: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=b8ca396f984295ba09f25f6982f9abd0bb7f5a29 Signed-off-by: Łukasz Stelmach Change-Id: Ic44cb49df247f690145a2d9dc8279aa94de4205f --- mm/cma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/cma.c b/mm/cma.c index 7f415d7..a751ed4 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 %u)\n", __func__, (void *)pages, count); pfn = page_to_pfn(pages); -- 2.7.4