Skip to content

Commit 51ae3f4

Browse files
Kalesh Singhakpm00
authored andcommitted
mm/cma: fix placement of trace_cma_alloc_start/finish
The current placement of trace_cma_alloc_start/finish misses the fail cases: !cma || !cma->count || !cma->bitmap. trace_cma_alloc_finish is also not emitted for the failure case where bitmap_count > bitmap_maxno. Fix these missed cases by moving the start event before the failure checks and moving the finish event to the out label. Link: https://lkml.kernel.org/r/20240110012234.3793639-1-kaleshsingh@google.com Fixes: 7bc1aec ("mm: cma: add trace events for CMA alloc perf testing") Signed-off-by: Kalesh Singh <kaleshsingh@google.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Liam Mark <lmark@codeaurora.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 2597c99 commit 51ae3f4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mm/cma.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,9 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
436436
unsigned long i;
437437
struct page *page = NULL;
438438
int ret = -ENOMEM;
439+
const char *name = cma ? cma->name : NULL;
440+
441+
trace_cma_alloc_start(name, count, align);
439442

440443
if (!cma || !cma->count || !cma->bitmap)
441444
goto out;
@@ -446,8 +449,6 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
446449
if (!count)
447450
goto out;
448451

449-
trace_cma_alloc_start(cma->name, count, align);
450-
451452
mask = cma_bitmap_aligned_mask(cma, align);
452453
offset = cma_bitmap_aligned_offset(cma, align);
453454
bitmap_maxno = cma_bitmap_maxno(cma);
@@ -496,8 +497,6 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
496497
start = bitmap_no + mask + 1;
497498
}
498499

499-
trace_cma_alloc_finish(cma->name, pfn, page, count, align, ret);
500-
501500
/*
502501
* CMA can allocate multiple page blocks, which results in different
503502
* blocks being marked with different tags. Reset the tags to ignore
@@ -516,6 +515,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
516515

517516
pr_debug("%s(): returned %p\n", __func__, page);
518517
out:
518+
trace_cma_alloc_finish(name, pfn, page, count, align, ret);
519519
if (page) {
520520
count_vm_event(CMA_ALLOC_SUCCESS);
521521
cma_sysfs_account_success_pages(cma, count);

0 commit comments

Comments
 (0)