Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 7bc1aec5e287 ("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>

authored by

Kalesh Singh and committed by
Andrew Morton
51ae3f4a 2597c994

+4 -4
+4 -4
mm/cma.c
··· 436 436 unsigned long i; 437 437 struct page *page = NULL; 438 438 int ret = -ENOMEM; 439 + const char *name = cma ? cma->name : NULL; 440 + 441 + trace_cma_alloc_start(name, count, align); 439 442 440 443 if (!cma || !cma->count || !cma->bitmap) 441 444 goto out; ··· 448 445 449 446 if (!count) 450 447 goto out; 451 - 452 - trace_cma_alloc_start(cma->name, count, align); 453 448 454 449 mask = cma_bitmap_aligned_mask(cma, align); 455 450 offset = cma_bitmap_aligned_offset(cma, align); ··· 497 496 start = bitmap_no + mask + 1; 498 497 } 499 498 500 - trace_cma_alloc_finish(cma->name, pfn, page, count, align, ret); 501 - 502 499 /* 503 500 * CMA can allocate multiple page blocks, which results in different 504 501 * blocks being marked with different tags. Reset the tags to ignore ··· 515 516 516 517 pr_debug("%s(): returned %p\n", __func__, page); 517 518 out: 519 + trace_cma_alloc_finish(name, pfn, page, count, align, ret); 518 520 if (page) { 519 521 count_vm_event(CMA_ALLOC_SUCCESS); 520 522 cma_sysfs_account_success_pages(cma, count);