From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9024282F1D for ; Fri, 24 Jul 2026 09:57:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784887072; cv=none; b=O0DazSFonL4Hg7dgg6/F90IzcKEBRFKMeN0e4ScFkKmxLcTNjJUsNiP29kMlvwBUWII4UOW30ltruNPAp1rwwkAgSnZcB0Cr03eTvcJy2N2NKTHRciPRvHh6QCsd3noKIdpUU5BchiUnzB955uAgoHQrat5w1UMXniIBtFyrMXs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784887072; c=relaxed/simple; bh=InTNhT79oMdWXK6U8e+Z+Kxfc/R0U5F36Sd80JvQvzw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sgytDl6yPfFNXVn4jCttRfn9VQh3OtWHE/omuojDoo1b5agxd9DAEEh12npvjqNQ/JTiaGXc7T210kUHvERQbC/eSg7tniXKLwoFWUz9Lo3bGUEiLqLY3EyW6nWTE1UckLHFp2rFD6auChDaQW/1qpKUFyiSFJZhrR5Dfe3TeCk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=LxqBLyNF; arc=none smtp.client-ip=95.215.58.183 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) header.d=linux.dev header.i=@linux.dev header.b="LxqBLyNF" Date: Fri, 24 Jul 2026 17:57:15 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1784887056; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gtzI0WrHpPQ8NxhzSfdbFVkPslhXcvXb+1WfK67Ct6A=; b=LxqBLyNFCuRzvSTEZvQ+k7G4esSrSkIg3NL0E6nP9CWPApkKEhtzDaDQM/QTeJLcnFBqVl oHxoQs49THjbvWSHHm3yBfJq52vZKB1Sr2HHwBpnppRGMGUcmb7Xm6Swk5s6TktpmIskll agvkNhLDpxuI1IL7m2PtL80iYRQxKYM= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Hao Li To: "Vlastimil Babka (SUSE)" Cc: Harry Yoo , Suren Baghdasaryan , Shakeel Butt , Alexander Potapenko , Marco Elver , Andrew Morton , Christoph Lameter , David Rientjes , Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: Re: [PATCH v2 13/13] mm/slab: stop allocating objcg pointers when unnecessary Message-ID: References: <20260720-b4-objext_split-v2-0-2fa7c6f60dbe@kernel.org> <20260720-b4-objext_split-v2-13-2fa7c6f60dbe@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260720-b4-objext_split-v2-13-2fa7c6f60dbe@kernel.org> X-Migadu-Flow: FLOW_OUT On Mon, Jul 20, 2026 at 04:16:27PM +0200, Vlastimil Babka (SUSE) wrote: > Start using the slab_needs_objcg() helper to calculate slabobj_ext size. > Caches that we know to never need objcg pointers (currently > KMALLOC_NORMAL caches) will thus stop wasting memory on them when memory > allocation profiling is enabled. > > For things to work properly, we need to also add slab_needs_objcg() > checks to mem_cgroup_from_obj_slab() and memcg_slab_free_hook(), because > when obj_exts array exists for a slab only due to mem_alloc profiling, > we would otherwise attempt to access a non-existing objcg pointer in > that slab. > > The function __memcg_slab_post_alloc_hook() should not be possible to > call for a slab where slab_needs_objcg() is false, but add a DEBUG_VM > check there to prevent breaking this assumption accidentally. > > Signed-off-by: Vlastimil Babka (SUSE) Looks good to me. Reviewed-by: Hao Li -- Thanks, Hao