From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 54B92217F27; Wed, 17 Jun 2026 14:40:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781707246; cv=none; b=kUxbenQiBOjpCGFsYuMLDaM1lyYrmJ1NQj8ElFeUwPAIvR5TD6Y7bhzN80J4dkGTt2sx0wXr+/euVmoLDPXQQKh2gMUjfqjqRJ3+gX9/u9v0L27ScF4IRzOWucIPF2tr0pnQ3VTK5WFThPzg19rbPVhSXMNXPq9BGjLBiSPUtwc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781707246; c=relaxed/simple; bh=nbIei5LQuFojnG61oo9TKFoyCWfciPusCPgoFw/p6i4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=OSjekzgWXPzsaN41DMht36Air21OtitoIMf9/3+KoKFhHaYaN245gwScWWFbZflr3h+nrvbKU8QIxvvWzNg4r9aCwnot7ctSL7ggk1CJ42Hgf1jv1tJYpRGQ4DfXi7YHPcpz1dE8Sn+XTPS/l0mnh8mgw3SV2TX2jV3GNGbTNCs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jZ3DSq6l; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jZ3DSq6l" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7565F1F000E9; Wed, 17 Jun 2026 14:40:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781707245; bh=nbIei5LQuFojnG61oo9TKFoyCWfciPusCPgoFw/p6i4=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=jZ3DSq6l+QsHgbvMKTv3EZBc/yQZkW1DWZudDzczG0ToiC/FZhcJcb10b5j0pCQSs v8E6T26mo+I5raG2Luz57wasV+M16uL1T1+p0zZ8UVhuiPT98nv41MW/9QGWvuwsHj fLoCTYDnWfuYvmYOc+GYRVGVHbkQDd0aAkFWbTwKIhonIWFvPC7ekmQfWkqCKtaLWo rTjJ4HNqRsBTEyUPvO+Zxk5I+fgdrp//kizFou1k46AcHc10Pf73nKgZgqKUX0Marf 4gAzFwLRYE+8GoedamHKn3j5hp+440s4kut6/nVmL1FiCaxP6VIHzJzv9uyjdhFiU1 m4ZOa7/7LFnyg== Message-ID: <02f9c426-b568-4ddc-882f-aab8c7f31976@kernel.org> Date: Wed, 17 Jun 2026 23:40:39 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 14/15] mm/slab: remove __GFP_NO_OBJ_EXT usage from alloc_slab_obj_exts() To: "Vlastimil Babka (SUSE)" Cc: Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Suren Baghdasaryan , Alexei Starovoitov , Andrew Morton , Johannes Weiner , Michal Hocko , Shakeel Butt , Alexander Potapenko , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org References: <20260615-slab_alloc_flags-v3-0-ce1146d140fb@kernel.org> <20260615-slab_alloc_flags-v3-14-ce1146d140fb@kernel.org> <78b67a9b-44e5-4649-957a-9d42bfaa098e@kernel.org> <26c29e4b-09b1-424a-b4e4-3358aac20115@kernel.org> Content-Language: en-US From: Harry Yoo In-Reply-To: <26c29e4b-09b1-424a-b4e4-3358aac20115@kernel.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------GV0qWTMYBB1AKSMm3bfNfef6" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------GV0qWTMYBB1AKSMm3bfNfef6 Content-Type: multipart/mixed; boundary="------------oVz7MBau50V4H9MeL0byYqJq"; protected-headers="v1" From: Harry Yoo To: "Vlastimil Babka (SUSE)" Cc: Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Suren Baghdasaryan , Alexei Starovoitov , Andrew Morton , Johannes Weiner , Michal Hocko , Shakeel Butt , Alexander Potapenko , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Message-ID: <02f9c426-b568-4ddc-882f-aab8c7f31976@kernel.org> Subject: Re: [PATCH v3 14/15] mm/slab: remove __GFP_NO_OBJ_EXT usage from alloc_slab_obj_exts() References: <20260615-slab_alloc_flags-v3-0-ce1146d140fb@kernel.org> <20260615-slab_alloc_flags-v3-14-ce1146d140fb@kernel.org> <78b67a9b-44e5-4649-957a-9d42bfaa098e@kernel.org> <26c29e4b-09b1-424a-b4e4-3358aac20115@kernel.org> In-Reply-To: <26c29e4b-09b1-424a-b4e4-3358aac20115@kernel.org> --------------oVz7MBau50V4H9MeL0byYqJq Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 6/17/26 11:36 PM, Vlastimil Babka (SUSE) wrote: > On 6/17/26 15:56, Harry Yoo wrote: >> On 6/15/26 8:54 PM, Vlastimil Babka (SUSE) wrote: >>> __GFP_NO_OBJ_EXT has limited scope within the slab allocator itself a= nd >>> gfp flags are a scarce resource, unlike slab's alloc_flags. >>> >>> Introduce SLAB_ALLOC_NO_RECURSE alloc flag that has the same intent a= s >>> __GFP_NO_OBJ_EXT but a more generic name, meaning that a kmalloc() >>> family function should not recurse into another kmalloc*() for the >>> purposes of allocating auxiliary structures (obj_ext arrays or sheave= s). >>> >>> First, replace the __GFP_NO_OBJ_EXT for allocating obj_ext arrays in >>> alloc_slab_obj_exts(). Make use of the newly added kmalloc_flags() >>> function, where we can pass alloc_flags with SLAB_ALLOC_NO_RECURSE >>> added. This will also pass through SLAB_ALLOC_NOLOCK so we don't need= >>> to special case kmalloc_nolock() anymore. >>> >>> Note that until now the kmalloc_nolock() ignored the incoming gfp fla= gs >>> and hardcoded __GFP_ZERO | __GFP_NO_OBJ_EXT. But it's correct to pass= on >>> the incoming gfp flags (only augmented with __GFP_ZERO), because if >>> alloc_flags contain SLAB_ALLOC_NOLOCK, the incoming gfp flags have to= >>> be also compatible with it. However, we might have added __GFP_THISNO= DE >>> for opportunistic slab allocation, as pointed out by Hao Li, and >>> __GFP_COMP by allocate_slab() as pointed out by Shengming Hu. Solve t= his >>> by adding both flags to OBJCGS_CLEAR_MASK as it makes sense to strip >>> them anyway for non-kmalloc_nolock() allocations of sheaves or obj_ex= t >>> arrays as well. >>> >>> To avoid recursion of sheaf -> obj_ext -> sheaf -> ... allocations at= >>> this patch, until the next patch converts sheaves to >>> SLAB_ALLOC_NO_RECURSE, use both gfp and alloc_flags for obj_ext. The >>> next patch will remove the gfp part. >>> >>> Link: https://patch.msgid.link/20260610-slab_alloc_flags-v2-15-719090= 9db118@kernel.org >>> Signed-off-by: Vlastimil Babka (SUSE) >>> --- >> >> Looks good to me, >> Reviewed-by: Harry Yoo (Oracle) >=20 > Thanks! > =20 >> With some comments below. >> >> I was worried that perhaps replacing SLAB_ALLOC_NO_RECURSE with >> __GFP_NO_OBJ_EXT will create a cycle of >> >> alloc_slab_obj_exts(SLAB_ALLOC_DEFAULT) >> -> kmalloc_flags(SLAB_ALLOC_NO_RECURSE) >> -> alloc_from_pcs(SLAB_ALLOC_NO_RECURSE) >> -> refill_objects(SLAB_ALLOC_DEFAULT) >> -> new_slab(SLAB_ALLOC_DEFAULT) >> -> account_slab(SLAB_ALLOC_DEFAULT) >> -> alloc_slab_obj_exts(SLAB_ALLOC_DEFAULT) >> >> with __GFP_NO_OBJ_EXT, it would have been passed to refill_objects(), >> but SLAB_ALLOC_NO_RECURSE is not. However this cycle does not exist >> because alloc_slab_obj_exts() clears __GFP_ACCOUNT (as part of >> OBJCG_CLEAR_MASK) and memory profiling itself does not invoke >> alloc_slab_obj_exts() when allocating new slabs if SLAB_ACCOUNT is not= >> set (which is interesting, by the way). >=20 > Hm yeah I think we should propagate alloc_flags to refill_objects() etc= , to=20 > avoid later surprise. But can be done as a later cleanup. Ack. >> Also alloc_slab_obj_exts() propagating SLAB_ALLOC_NEW_SLAB to >> kmalloc_flags() is little bit confusing because it does not have any >> effect due to SLAB_ALLOC_NO_RECURSE. >=20 > OK let's address this one by this fixup: The fixup looks good to me, thanks! --=20 Cheers, Harry / Hyeonggon --------------oVz7MBau50V4H9MeL0byYqJq-- --------------GV0qWTMYBB1AKSMm3bfNfef6 Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQQ1ub6gR5ogjaKRmOGXBN6rc5S1gUCajKx5wAKCRCGXBN6rc5S 1t9iAQDiPXLnO6zy942RtBt/uX/MTobE+4pvYi/Tod2EIOc7ZgEAm+SvzDRW2ab1 rNcaW/zRWDP59NB8KIsOmgrG6w6qBAg= =zqiN -----END PGP SIGNATURE----- --------------GV0qWTMYBB1AKSMm3bfNfef6--