Skip to content

Commit a317ebc

Browse files
Patrick Wangakpm00
authored andcommitted
mm: percpu: use kmemleak_ignore_phys() instead of kmemleak_free()
Kmemleak recently added a rbtree to store the objects allocted with physical address. Those objects can't be freed with kmemleak_free(). According to the comments, percpu allocations are tracked by kmemleak separately. Kmemleak_free() was used to avoid the unnecessary tracking. If kmemleak_free() fails, those objects would be scanned by kmemleak, which is unnecessary but shouldn't lead to other effects. Use kmemleak_ignore_phys() instead of kmemleak_free() for those objects. Link: https://lkml.kernel.org/r/[email protected] Fixes: 0c24e06 ("mm: kmemleak: add rbtree and store physical address for objects allocated with PA") Signed-off-by: Patrick Wang <[email protected]> Cc: Dennis Zhou <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Catalin Marinas <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 48725bb commit a317ebc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mm/percpu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3104,7 +3104,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
31043104
goto out_free_areas;
31053105
}
31063106
/* kmemleak tracks the percpu allocations separately */
3107-
kmemleak_free(ptr);
3107+
kmemleak_ignore_phys(__pa(ptr));
31083108
areas[group] = ptr;
31093109

31103110
base = min(ptr, base);
@@ -3304,7 +3304,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size, pcpu_fc_cpu_to_node_fn_t
33043304
goto enomem;
33053305
}
33063306
/* kmemleak tracks the percpu allocations separately */
3307-
kmemleak_free(ptr);
3307+
kmemleak_ignore_phys(__pa(ptr));
33083308
pages[j++] = virt_to_page(ptr);
33093309
}
33103310
}
@@ -3417,7 +3417,7 @@ void __init setup_per_cpu_areas(void)
34173417
if (!ai || !fc)
34183418
panic("Failed to allocate memory for percpu areas.");
34193419
/* kmemleak tracks the percpu allocations separately */
3420-
kmemleak_free(fc);
3420+
kmemleak_ignore_phys(__pa(fc));
34213421

34223422
ai->dyn_size = unit_size;
34233423
ai->unit_size = unit_size;

0 commit comments

Comments
 (0)