mm: kmemleak: Ignore kmemleak scanning on CMA regions
Subsystems (2)
PATCH 1/1 mm: kmemleak: Ignore kmemleak scanning on CMA regions
Just like this:
commit 620951e27457 ("mm/cma: make kmemleak ignore CMA regions").
Add kmemleak_ignore_phys() for CMA created from of reserved node.
--- kernel/dma/contiguous.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/dma/contiguous.c +4 -0
@@ -50,6 +50,7 @@#include <linux/sizes.h> #include <linux/dma-map-ops.h> #include <linux/cma.h> +#include <linux/kmemleak.h> #ifdef CONFIG_CMA_SIZE_MBYTES #define CMA_SIZE_MBYTES CONFIG_CMA_SIZE_MBYTES
@@ -426,6 +427,9 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)pr_err ("Reserved memory: unable to setup CMA region\n" );return err; } + +kmemleak_ignore_phys (rmem->base); +/* Architecture specific contiguous memory fixup. */ dma_contiguous_early_fixup (rmem->base, rmem->size);
Signature · 1 line
2.30.2
Andrew Morton
maintainerQuoted 4 lines · On Fri, 26 Nov 2021 10:47:11 +0800 Calvin Zhang <[email protected]>…
Just like this:
commit620951e27457("mm/cma: make kmemleak ignore CMA regions").Add
kmemleak_ignore_phys()for CMA created from of reserved node.
Could we please have a full, standalone changelog for this patch?
The 620951e27457 changelog says "Without this, the kernel crashes...". Does your patch also fix a crash? If so under what circumstances and should we backport this fix into -stable kernels?
Etcetera.
Quoted 8 lines · Andrew Morton
Quoted 4 lines · On Fri, 26 Nov 2021 10:47:11 +0800 Calvin Zhang <[email protected]>…
Just like this:
commit620951e27457("mm/cma: make kmemleak ignore CMA regions").Add
kmemleak_ignore_phys()for CMA created from of reserved node.Could we please have a full, standalone changelog for this patch?
Yes, I will add.
Quoted 4 lines
The
620951e27457changelog says "Without this, the kernel crashes...". Does your patch also fix a crash? If so under what circumstances and should we backport this fix into -stable kernels?
No crash occurred. 620951e27457 avoids crashes caused by accessing highmem and it was fixed later. Now kmemleak_alloc_phys() and kmemleak_ignore_phys() skip highmem. This patch is based on the point that CMA regions don't contain pointers to other kmemleak objects, and ignores CMA regions from reserved memory as what 620951e27457 did.
--
Thanks
Calvin
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 6 lines · Calvin Zhang
Quoted 5 lines · Andrew Morton
Quoted 4 lines · On Fri, 26 Nov 2021 10:47:11 +0800 Calvin Zhang <[email protected]>…
Just like this:
commit620951e27457("mm/cma: make kmemleak ignore CMA regions").Add
kmemleak_ignore_phys()for CMA created from of reserved node.
[...]
Quoted 10 lines
Quoted 3 lines
The
620951e27457changelog says "Without this, the kernel crashes...". Does your patch also fix a crash? If so under what circumstances and should we backport this fix into -stable kernels?No crash occurred.
620951e27457avoids crashes caused by accessing highmem and it was fixed later. Nowkmemleak_alloc_phys()andkmemleak_ignore_phys()skip highmem. This patch is based on the point that CMA regions don't contain pointers to other kmemleak objects, and ignores CMA regions from reserved memory as what620951e27457did.
Note that kmemleak_ignore() only works if there was a prior kmemleak_alloc() on that address range. With the previous commit we get this via the memblock_alloc_range() but I fail to see one on the rmem_cma_setup() path.
Signature · 1 line
Catalin
Quoted 19 lines · Catalin Marinas
Quoted 6 lines · Calvin Zhang
Quoted 5 lines · Andrew Morton
Quoted 4 lines · On Fri, 26 Nov 2021 10:47:11 +0800 Calvin Zhang <[email protected]>…
Just like this:
commit620951e27457("mm/cma: make kmemleak ignore CMA regions").Add
kmemleak_ignore_phys()for CMA created from of reserved node.[...]
Quoted 10 lines
Quoted 3 lines
The
620951e27457changelog says "Without this, the kernel crashes...". Does your patch also fix a crash? If so under what circumstances and should we backport this fix into -stable kernels?No crash occurred.
620951e27457avoids crashes caused by accessing highmem and it was fixed later. Nowkmemleak_alloc_phys()andkmemleak_ignore_phys()skip highmem. This patch is based on the point that CMA regions don't contain pointers to other kmemleak objects, and ignores CMA regions from reserved memory as what620951e27457did.
Quoted 4 lines
Note that
kmemleak_ignore()only works if there was a priorkmemleak_alloc()on that address range. With the previous commit we get this via thememblock_alloc_range()but I fail to see one on thermem_cma_setup()path.
rmem is from memblock_reserve() or early_init_dt_alloc_reserved_memory_arch() kmemleak_alloc() is not called in the first case. And It's bad to add one.
I think all the reserved regions should be allocated from memblock without kmemleak_alloc() and let rmem handler choose to add it as kmemleak object by kmemleak_alloc(). Because MEMBLOCK_ALLOC_NOLEAKTRACE conflicts with range parameter in memlbock_alloc_* series, all reserved regions and default CMA region are allocated with kmemleak_alloc().
I think it's better to add memblock_alloc_* series a spearate flag paramter (like "NOLEAKTRACE") instead of encoding MEMBLOCK_ALLOC_NOLEAKTRACE in end parameter.
--
Calvin