From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796472386; b=VwjrERhjoHkJ/eIQawlM3MvJiXsMDFum5IkHkrgR8rvVpYsFxqJp5G573c6R1rm48Tv4 0d5qoOW9ZIlkMSfPqkYUOI9KBx55h5AVYScj5qtWbBXvYSq64GaGi8mDahFucVrKZ6ySX 2lITnsvCXfUpQDLhSK7wcwt12HfWIT4b+t8vp+J/6kQTxXt01MNtCtnxmfJopLTT15hRy cS85Bdjyc7quo0E2fPX4zl1Fwf2KOeC9trPVwj0K5K9mdkvinpvwPdDQnAdMm+lPHltjS 3psljhlIwbCfrEn+Vf6auEkg9s3ChQpCeaD7C0RWLmcbsqdwh3+ZcdCGmqu9+JOCm8w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796472386; h=DMARC-Filter:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=b192qnDDK6l+BdXz+7wRzL/7clU9tRORT1+GrIjxVRY=; b=fS+NblXBKhxGABwcOlpMHHTf7V4eMWNigqjQsXlJmySBNmRHLdJfA2DvBEMKxp7cPKpI ICAE486Gn15BLdFoox6K351SLJ+oR6h5E+tYOQeQtvRsISwCANGqzSmdjnXPOUe6Lwl4Z AQPHfGwsXE1zzJE+MYU0AnuHo/umknHhp6arKxa3rdAHfbkiodztRuYAPlrSAxZI+r2qW v5jM3llksMXOlkwrMbplAeKsn0Tu2eTBsqZIf/uSblfVzivrBVJFeqtOrJls5/ozDtNCG Mf9IKSQUxhwEpWL73a5quV1T7g6Y5lxKgV3bqBF/rJd3OgdIBc+zUNU44wKQ8OGxVWw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=YXCAo4y6; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C706606A32F for ; Sat, 5 Dec 2026 12:06:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5C706606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=YXCAo4y6 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A2E9914BF; Sat, 5 Dec 2026 04:06:22 -0800 (PST) Received: from arm.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5FC6B3F632; Sat, 5 Dec 2026 04:06:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796472385; bh=oRff1DfyaVLw9FqfUqLTbd0Lv4jqbAKGojbBapYzCZs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YXCAo4y6y6jJJ5AhUsKqC/rS3nS6xpupPXNrXi9FX84zzitsEU1HyyI4tQFrVHJCk 7q6HDNvteDcxrX591PU+lrqqOW6SpH1HEDkm+VSQQjE58MDxbkW/gguCmWRERZ60JK 0LipHlwLdzg6GRKhZ5t8BxnupJIprBrkxiirSZ4w= Date: Sat, 5 Dec 2026 12:06:19 +0000 From: Catalin Marinas To: Harry Yoo 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 01:04:42PM +0000, Harry Yoo wrote: > 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? [...] > 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 I think v2 is fine to queue. The remaining !allow_spin case only affects objects queued in a sheaf allocated with kmalloc_nolock(). IIUC only the slub kunit test_nolock() can create one. There is no other caller of kfree_rcu_nolock() yet. If we want to cover the kfree_rcu_nolock() case as well, I guess we can do a separate patch with the !allow_spin fallback. Moving kmemleak_ignore() wouldn't help since it can't be called on the nolock path, so I dropped that suggestion. -- Catalin