On Tue, Jan 24, 2023 at 03:48:57PM +0000, Catalin Marinas wrote: > Thanks for digging this out. This patch shouldn't have ended up upstream > (commit 972fa3a7c17c "mm: kmemleak: alloc gray object for reserved > region with direct map"). I thought both Calvin Zhang and I agreed that > it's not the correct approach (not even sure there was a real problem to > fix). > > Do you still get the any faults with the above commit reverted? I'd > prefer this if it works rather than adding unnecessary > kmemleak_alloc/free callbacks that pretty much cancel each-other. Yes, I still see the same problem after reverting that commit. The problem still persists because there are CMA areas that are allocated through memblock_phys_alloc_range(), which invokes kmemleak_alloc_phys(). The allocation call stack is along the lines of: kmemleak_alloc_phys() memblock_alloc_range_nid() memblock_phys_alloc_range() __reserved_mem_alloc_size() fdt_init_reserved_mem() I also followed up on my suggestion about adding a flags parameter to the memblock allocation functions to be able to use MEMBLOCK_ALLOC_NOLEAKTRACE in this particular scenario, but that would involve changing many call-sites, which doesn't make much sense given that there are only 4 call-sites that actually use this flag. Maybe adding a new memblock allocation function that allows this flag to be passed as just a flag can be used to avoid creating these kmemleak objects for CMA allocations? --Isaac