]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm: percpu: use kmemleak_ignore_phys() instead of kmemleak_free()
authorPatrick Wang <patrick.wang.shcn@gmail.com>
Tue, 5 Jul 2022 11:31:58 +0000 (19:31 +0800)
committerakpm <akpm@linux-foundation.org>
Mon, 18 Jul 2022 00:14:47 +0000 (17:14 -0700)
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/20220705113158.127600-1-patrick.wang.shcn@gmail.com
Fixes: ae2a1f131a41 ("mm: kmemleak: add rbtree and store physical address for objects allocated with PA")
Signed-off-by: Patrick Wang <patrick.wang.shcn@gmail.com>
Cc: Dennis Zhou <dennis@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/percpu.c

index 3633eeefaa0db28aa1b1677027891ea787a475e4..27697b2429c2e174f60cf0136739b5da26bc6039 100644 (file)
@@ -3104,7 +3104,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
                        goto out_free_areas;
                }
                /* kmemleak tracks the percpu allocations separately */
-               kmemleak_free(ptr);
+               kmemleak_ignore_phys(__pa(ptr));
                areas[group] = ptr;
 
                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
                                goto enomem;
                        }
                        /* kmemleak tracks the percpu allocations separately */
-                       kmemleak_free(ptr);
+                       kmemleak_ignore_phys(__pa(ptr));
                        pages[j++] = virt_to_page(ptr);
                }
        }
@@ -3417,7 +3417,7 @@ void __init setup_per_cpu_areas(void)
        if (!ai || !fc)
                panic("Failed to allocate memory for percpu areas.");
        /* kmemleak tracks the percpu allocations separately */
-       kmemleak_free(fc);
+       kmemleak_ignore_phys(__pa(fc));
 
        ai->dyn_size = unit_size;
        ai->unit_size = unit_size;