Thread (5 messages) 5 messages, 3 authors, 2021-12-03

Re: [PATCH] mm: kmemleak: Ignore kmemleak scanning on CMA regions

From: Calvin Zhang <hidden>
Date: 2021-12-03 00:52:32
Also in: linux-iommu, linux-mm, lkml

On Thu, Dec 02, 2021 at 06:11:12PM +0000, Catalin Marinas wrote:
On Sun, Nov 28, 2021 at 09:50:53AM +0800, Calvin Zhang wrote:
quoted
On Sat, Nov 27, 2021 at 04:07:18PM -0800, Andrew Morton wrote:
quoted
On Fri, 26 Nov 2021 10:47:11 +0800 Calvin Zhang [off-list ref] wrote:
quoted
Just like this:
commit 620951e27457 ("mm/cma: make kmemleak ignore CMA regions").

Add kmemleak_ignore_phys() for CMA created from of reserved node.
[...]
quoted
quoted
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?
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.
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.
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help