From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.194 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796307709; b=Xdo+GXS33RgSs0nF0EmXjBYXnZR96oaEzV8ivKc0OcWweCGMEqN3qVSfsOwckfGrzlMT gfZ8sXfmPmV0ijy2CRLyZhyUxWUuoKfss0WuEo8h09o6FInU0m+cmOJZPVX1yD6SE1vCk yxsoPt18Db97jpEA3MLzHG/iMbz5++HUGfLbKe6QsDyyj/U5FHrV5yfhNf75JJu+poWqF 0C2bMWjv/pDExArfjWD7y4zqOhY9VTsqn4asDALF/O5s0jkp8aAtK9HY/MjuJOgZXv5HB 1R/bwvN93rKWyMErGVJPatvzEg0aG6PCQGmZcvRQEH7DCXSrF1KNMQ8ckSnVI6HTsjA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796307709; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=NQ6Bf3IqVk23A8Rl2YbWxLunbsPV8/gtBhqHBsRkwzY=; b=Ejxgvbqqp4wFR+nI1hQFYz9wH6X4esBR1Ac/7t0js8FcleEwaLAbYfz0O6Eys5RxZxm9 KpqLTJLKHJ8q6PtxQzl4MEKJdw7m9xIqpzZjxO8SeMijYAIURpB7ajEKyfxjj98VTtI03 wB9o4YNLcZUvEWFdnmfZWp54YMJAQiN17RiJeEo/v10TJpaw5rXGgVcPAn6H/lXKyGzj6 cb4Bc4Fu41D1ocC2uKcxi+Jep7rbI5gFzvPOfmQpwoHodSu/wUkZRxWiFslhfyXoEuXBN NYLJoLFDZcTORNWsi0y+GxICNffirg4Lca4QupRvlM9ZMdySk1c+14cp5uZPMzLwTEA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="YGJ/SXkz"; arc=none smtp.remote-ip=91.218.175.194 Received: from mta0.migadu.com (out-194.mta0.migadu.com [91.218.175.194]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68CA5606A33D for ; Thu, 3 Dec 2026 14:21:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 68CA5606A33D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=YGJ/SXkz X-Envelope-To: cgroups@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=emgn/yDVRMTecepzvFuRi0o4KdC5NKjw2dERziCK4gM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796307706; v=1; x=1796912506; b=YGJ/SXkzHiGOMHqplM1+9OOugLWS1znrsPxNKOiiW+dJXf19nGBF5WMRiRJN3uF0xjtoSpPW FU5wcEnfPQkQR8bi/8uufLd8w0aDUL2BuCyRHXxVTY5x9ECgaVMpARYJowCJH/He9725H9ooVpO bGoPdadGENl5gooXM9axywBU= X-Envelope-To: cgroups@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 28e63dcba7c177ba; Thu, 03 Dec 2026 14:21:46 +0000 X-Mizu-Trace-ID: 28e63dcba7c177ba X-Migadu-Flow: FLOW_OUT Date: Thu, 3 Dec 2026 14:21:00 +0000 From: Hao Li To: "Harry Yoo (Meta)" Cc: Vlastimil Babka , Andrew Morton , Suren Baghdasaryan , Johannes Weiner , Michal Hocko , Shakeel Butt , Roman Gushchin , Christoph Lameter , David Rientjes , Muchun Song , Hao Ge , Pedro Falcato , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, "Liam R. Howlett" , Alice Ryhl , Andrew Ballance , Matthew Wilcox , linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Jan Kara , "David S. Miller" , Jakub Kicinski , Sebastian Andrzej Siewior , Jiayuan Chen , netdev@vger.kernel.org, Kees Cook , David Hildenbrand , Lorenzo Stoakes , Catalin Marinas , Will Deacon , Mark Rutland , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Robin Murphy , "Joerg Roedel (AMD)" , Amir Goldstein , Casey Schaufler , Paul Moore , James Morris , "Serge E. Hallyn" , linux-security-module@vger.kernel.org, Richard Weinberger , Anton Ivanov , Johannes Berg , Eric Dumazet , cgroups@vger.kernel.org Subject: Re: [PATCH slab/for-next v2 13/14] mm/memcontrol: do not allow charging objects without SLAB_MAY_ACCOUNT Message-ID: References: <20261125-memalloc-prof-dont-waste-slabobj-ext-metadata-v2-0-7c680f02a734@kernel.org> <20261125-memalloc-prof-dont-waste-slabobj-ext-metadata-v2-13-7c680f02a734@kernel.org> X-Mailing-List: cgroups@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: <20261125-memalloc-prof-dont-waste-slabobj-ext-metadata-v2-13-7c680f02a734@kernel.org> On Wed, Nov 25, 2026 at 09:37:14PM +0000, Harry Yoo (Meta) wrote: > Objects of a cache without SLAB_MAY_ACCOUNT cannot store the objcg > pointer once slabobj_ext space is no longer reserved for every cache. > Skip charging when __GFP_ACCOUNT hits such a cache, and warn once under > CONFIG_DEBUG_VM to catch callers that did not opt in. > > Refusing the charge here is sufficient for correctness: an object that > is never charged does not access the objcg slot again, and the free > path already skips such caches via slab_needs_objcg(). > > Cc: Johannes Weiner > Cc: Michal Hocko > Cc: Shakeel Butt > Cc: Muchun Song > Cc: cgroups@vger.kernel.org > Signed-off-by: Harry Yoo (Meta) > --- > mm/memcontrol.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index a07cc73acfc7..0eddb16173fd 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -3707,6 +3707,12 @@ bool __memcg_slab_post_alloc_hook(struct kmem_cache *s, struct list_lru *lru, > if (unlikely(*p == NULL)) > return true; > > + /* Do not allow __GFP_ACCOUNT without SLAB_MAY_ACCOUNT */ > + if (unlikely(!cache_needs_objcg(s))) { > + VM_WARN_ON_ONCE(1); > + return true; > + } > + Would it be better to put this check before `if (!objcg || obj_cgroup_is_root(objcg))`, so we can catch abnormal cases more aggressively? > flags &= gfp_allowed_mask; > > if (lru) { > > -- > 2.54.0 > -- Thanks, Hao