From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796389485; b=Cj0AmsVmnTePSi4JqlXqErQqaLOrFD0ieylxVjrHQvm/XDGCRVvPruqVVPnBkcOdZ6Ot UMjfQjxgEyw4lLXaeqcj1n7KpEiFIYx2tT/wf4ZiCIrLo15q87lAjxTbyS+Qc4ABVQfbx ay5x1+Slng5COX0ZneNJyOHBxRSu7oGEDEiFotlJw67alhI7Jk3MQb9XF8lppkWhYFPI3 nkG77uq+rQrMVDc2UuR/aj2LQWcM1dqPF+bldxiroGJS3W6q3N/DD6xWoXYvvagqeJ2wU x0nFfVoihky6Mbeliw1cVT9x6pL2ccbcMFQffrSlRw+x7b2kDF3YdIwttfKIG7DggMQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389485; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=psDK/e5SOhHJirAU7kO5xrbB19S9rQ8RuHWfpcs3Azk=; b=Q9/iHXUlYPFik3R2o48H869RSqraTsseQZ7qoN3F8J9BhUm9Mmqdmmp+LkYz8PxZkcTR LJZJb+lN09F70Y+3kwdGbt6iD52CFFqEe9rIvlmdwgYOzB6Bjm/v2cYIiBEkXGPmqZKbF xsOpdarpz02qOoO1qOYL2vPm46pELg43r98L8WifTH8T+5K6/t5G8K8nsn75EuFfWMHKx Gqvc2PJjqEk6A6QELDv+MirlA54vVR4YfWeUAnFPB+9Q5mPUOQLCLpQLeFcnuvhIzwWbj +oYVa694Unmwl99hVUekDirz4aHxXaVBpIWmqgU/AulAC7wHdADZ0bk0Po1IB23U9yA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PKwVIrpo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E84D0606A322 for ; Fri, 4 Dec 2026 13:04:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PKwVIrpo Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CF381F000CE; Fri, 4 Dec 2026 13:04:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796389484; bh=psDK/e5SOhHJirAU7kO5xrbB19S9rQ8RuHWfpcs3Azk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=PKwVIrpoNTz4d9HGLjS9oaX9CgGo2PXRsHKEuiT9HNwi4/FM2MNCuUPfJ7cR1Owd0 WkEc/S+XOjDy5GJAvHsh6N6nQPAQmoqXBzwhmx3Lwmp69vMaxI108Wyxr0XShGAOP+ ZDzsHbrRTGekHYOYu/hSOHbUpEeDI57amEB5XXrvvyFTwQJkWJodxibtSSwCZveoCL KbxSH7BbtZcZye27D/UQBhf2kAhfuf60SDReVe9YNmHwMe0RuBuF0N4QEqS9MYsJ4p TEcVXZ6hNnXnTcX9+C93KxlU3V1jX1zBT/3hULd5lcPwp7OuarzettX93VbCleRztO SmgY07JfivBzQ== Date: Fri, 4 Dec 2026 13:04:42 +0000 From: Harry Yoo To: Catalin Marinas Cc: "Vlastimil Babka (SUSE)" , Nguyen Ngoc Thang , Andrew Morton , Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Suren Baghdasaryan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, syzbot+527fed49e5b988882c9a@syzkaller.appspotmail.com, Breno Leitao Subject: Re: [PATCH] mm/slub: don't let kmemleak report rcu sheaves Message-ID: References: <20261113151837.123795-1-ngocthang2710.1999@gmail.com> <0e626675-c6f9-40d7-a4ae-de069154ada2@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Dec 04, 2026 at 10:43:27AM +0000, Catalin Marinas wrote: > On Wed, Nov 25, 2026 at 02:10:45PM +0000, Harry Yoo wrote: > > On Wed, Nov 18, 2026 at 04:06:29PM +0000, Catalin Marinas wrote: > > > On Tue, Nov 17, 2026 at 11:05:28PM +0000, Catalin Marinas wrote: > > > > diff --git a/mm/slub.c b/mm/slub.c > > > > index 45e077c7526c..13b8e57d6dae 100644 > > > > --- a/mm/slub.c > > > > +++ b/mm/slub.c > > > > @@ -6278,6 +6278,14 @@ bool __kfree_rcu_sheaf(struct kmem_cache *s, void *obj, unsigned int free_flags) > > > > > > > > local_unlock(&s->cpu_sheaves->lock); > > > > > > > > + /* > > > > + * A sheaf allocated with kmalloc_nolock() is not tracked by > > > > + * kmemleak, so neither its objects nor the rcu callback queued > > > > + * after it would be scanned. Fall back to defer_kfree_rcu(). > > > > + */ > > > > + if (IS_ENABLED(CONFIG_DEBUG_KMEMLEAK) && !allow_spin) > > > > + goto fail; > > > > + > > > > /* Don't wake up kswapd, it will cause deadlock under pi_lock */ > > > > empty = alloc_empty_sheaf(s, __GFP_NOWARN, alloc_flags); > > > > > > > > > > For the objects queued in a sheaf, rather than the !allow_spin fallback > > > above, it's simpler to move the kmemleak_ignore() call in > > > kvfree_call_rcu() before kfree_rcu_sheaf(), so they are treated the same > > > as on the non-sheaf path. > > > > No strong opinion on this but kmemleak_not_leak() would let kmemleak > > track objects queued in a sheaf? > > > > Wondering it'd make sense to mark bnodes with kmemleak_not_leak() as > > well instead of calling kmemleak_ignore() on all objects. > > bnodes are allocated with __get_free_page() and these objects are not > tracked by kmemleak. Ouch, right :) > Instead we'd need kmalloc_alloc/free() on bnodes > but I think the existing kmemleak_ignore() is simpler, it covers other > cases as well. Agreed. I'm kinda debating whether v2 is ready to be queued to slab tree as it doesn't handle a sheaf allocated with !allow_spin and you suggested: > For the objects queued in a sheaf, rather than the !allow_spin > fallback above, it's simpler to move the kmemleak_ignore() call in > kvfree_call_rcu() before kfree_rcu_sheaf(), so they are treated the > same as on the non-sheaf path. https://lore.kernel.org/linux-mm/av3NBYxYXyYk_tjS@arm.com Thoughts? -- Cheers, Harry / Hyeonggon