From nobody Thu Sep 24 13:41:52 2026 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 54BF9486402 for ; Wed, 23 Sep 2026 15:45:21 +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=1790178322; cv=none; b=IKoadqqDKQqSDvKEwsiz6DEsP+GZ4XBe8XX++Hp7PggUl7roY9T9TGA8rKfsD6RKaGgZO6cbpwLhMbdh0mNxccL+jK47a6WddhtNNUbSkwYDbeuVURXVXLxJCmR1zktf8aMecXuWJpdETURUjm/6qQ1LkTkFpjcBhEKdyvqvVgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790178322; c=relaxed/simple; bh=wZoPIEuWkn7TYj+9Q0L4kReAoZaJyfpaOf5dfei30aM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VAiRUkFt4gmdvyK8l2I18r+5+kLGnXClkd+aa6mrXBkKNPxdLiePwFcRVo3G2J5vOLB/+sbrAw+DbaKyfNq/Dkeur1awpFjJyptBkbL5yFZfHYz1OlSfH0tfhj/zoRgIt2TGIROIc2Is0lVhp3S7vYlD9cIbI2leGiRiyiquWKc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dL4l3eVm; 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="dL4l3eVm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D43B51F00893; Wed, 23 Sep 2026 15:45:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790178321; bh=jL6ru8W93/pghvOJZnQKUsqwn9YkJKVX7X7ctsoiqVk=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=dL4l3eVmaLLT2WHb7zxzZL2hqT7vg3xDyvQA/wb23CpMlcc9AFZx0w8JGwwqTISCc dmqx6m3zKNXzq3GzWqqMD870ysrlqJgLZWWEIb4DsMGf+gjym1JbjwKF55hzfWoPBF 22yCi0okFCzlAHYC72BD8utrXVHzTn6tDdRScJwG9J64xIlYz3P/5wG5+qSzLk6ERH UvxV0+BiYdnwbCx0WM6db7P2tRgyyhxlfwdkd2xDy5Yz4c8SJj8cTh0GCz0UrTDRxL zEE4gZYv/54MnlAomBBeyTMb0gmstI8jSPBpiBKcJaMDR/RHIQiF+ywe1sC17mglgw Kz2oGSIZawwJw== From: "Vlastimil Babka (SUSE)" Date: Wed, 23 Sep 2026 17:45:06 +0200 Subject: [PATCH RFC 1/8] mm, slab: refactor slab_min/max_order handling 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260923-slub_tiny_rework-v1-1-a0e66d536eb5@kernel.org> References: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> In-Reply-To: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> To: Harry Yoo Cc: Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Geert Uytterhoeven , Conor Dooley , Damien Le Moal , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Vlastimil Babka (SUSE)" X-Mailer: b4 0.16.0 Setting slab_min_order and slab_max_order as boot-time parameters currently has several not so great aspects: - slab_min_order is not checked against MAX_PAGE_ORDER - slab_min_order can raise slab_max_order - processing requires custom callbacks, their execution order depends on the order of boot time parameters specified - upcoming SLUB_TINY changes would be more complicated Instead of custom callbacks, introduce __initdata variables that hold the boot-time parameter values (if given). All inputs are then evaluated deterministically in kmem_cache_init(). slab_min_order is always capped at slab_max_order and cannot raise it. debug_guardpage_minorder() still overrides any given boot time params, but it could be changed if there's a use case. While at it, rename the slub_min/max_order variables and slub_min_objects to have a "slab_" prefix instead, as their values determine the sizing of slabs, and the "slub_" prefix already became deprecated also for the boot-time parameters. Signed-off-by: Vlastimil Babka (SUSE) --- mm/slub.c | 84 ++++++++++++++++++++++++-----------------------------------= ---- 1 file changed, 32 insertions(+), 52 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 96dca4846b4e..a107a111c75e 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -7598,10 +7598,17 @@ EXPORT_SYMBOL(kmem_cache_alloc_bulk_noprof); * and increases the number of allocations possible without having to * take the list_lock. */ -static unsigned int slub_min_order; -static unsigned int slub_max_order =3D +static unsigned int slab_min_order; +static unsigned int slab_max_order =3D IS_ENABLED(CONFIG_SLUB_TINY) ? 1 : PAGE_ALLOC_COSTLY_ORDER; -static unsigned int slub_min_objects; +static unsigned int slab_min_objects; + +/* + * Store values set by boot-time parameters, to be evaluated in + * kmem_cache_init(). UINT_MAX means they were not set, as 0 is a valid va= lue. + */ +static unsigned int slab_min_order_param __initdata =3D UINT_MAX; +static unsigned int slab_max_order_param __initdata =3D UINT_MAX; =20 /* * Calculate the order of allocation given an slab object size. @@ -7655,7 +7662,7 @@ static inline int calculate_order(unsigned int size) unsigned int max_objects; unsigned int min_order; =20 - min_objects =3D slub_min_objects; + min_objects =3D slab_min_objects; if (!min_objects) { /* * Some architectures will only update present cpus when @@ -7672,10 +7679,10 @@ static inline int calculate_order(unsigned int size) min_objects =3D 4 * (fls(nr_cpus) + 1); } /* min_objects can't be 0 because get_order(0) is undefined */ - max_objects =3D max(order_objects(slub_max_order, size), 1U); + max_objects =3D max(order_objects(slab_max_order, size), 1U); min_objects =3D min(min_objects, max_objects); =20 - min_order =3D max_t(unsigned int, slub_min_order, + min_order =3D max_t(unsigned int, slab_min_order, get_order(min_objects * size)); if (order_objects(min_order, size) > MAX_OBJS_PER_PAGE) return get_order(size * MAX_OBJS_PER_PAGE) - 1; @@ -7696,9 +7703,9 @@ static inline int calculate_order(unsigned int size) * long as at least single object fits within slab_max_order. */ for (unsigned int fraction =3D 16; fraction > 1; fraction /=3D 2) { - order =3D calc_slab_order(size, min_order, slub_max_order, + order =3D calc_slab_order(size, min_order, slab_max_order, fraction); - if (order <=3D slub_max_order) + if (order <=3D slab_max_order) return order; } =20 @@ -8268,50 +8275,14 @@ void __kmem_obj_info(struct kmem_obj_info *kpp, voi= d *object, struct slab *slab) * Kmalloc subsystem *******************************************************************/ =20 -static int __init setup_slub_min_order(const char *str, const struct kerne= l_param *kp) -{ - int ret; - - ret =3D kstrtouint(str, 0, &slub_min_order); - if (ret) - return ret; +core_param(slab_min_order, slab_min_order_param, uint, 0); +core_param(slub_min_order, slab_min_order_param, uint, 0); =20 - if (slub_min_order > slub_max_order) - slub_max_order =3D slub_min_order; +core_param(slab_max_order, slab_max_order_param, uint, 0); +core_param(slub_max_order, slab_max_order_param, uint, 0); =20 - return 0; -} - -static const struct kernel_param_ops param_ops_slab_min_order __initconst = =3D { - .set =3D setup_slub_min_order, -}; -__core_param_cb(slab_min_order, ¶m_ops_slab_min_order, &slub_min_order= , 0); -__core_param_cb(slub_min_order, ¶m_ops_slab_min_order, &slub_min_order= , 0); - -static int __init setup_slub_max_order(const char *str, const struct kerne= l_param *kp) -{ - int ret; - - ret =3D kstrtouint(str, 0, &slub_max_order); - if (ret) - return ret; - - slub_max_order =3D min_t(unsigned int, slub_max_order, MAX_PAGE_ORDER); - - if (slub_min_order > slub_max_order) - slub_min_order =3D slub_max_order; - - return 0; -} - -static const struct kernel_param_ops param_ops_slab_max_order __initconst = =3D { - .set =3D setup_slub_max_order, -}; -__core_param_cb(slab_max_order, ¶m_ops_slab_max_order, &slub_max_order= , 0); -__core_param_cb(slub_max_order, ¶m_ops_slab_max_order, &slub_max_order= , 0); - -core_param(slab_min_objects, slub_min_objects, uint, 0); -core_param(slub_min_objects, slub_min_objects, uint, 0); +core_param(slab_min_objects, slab_min_objects, uint, 0); +core_param(slub_min_objects, slab_min_objects, uint, 0); =20 #ifdef CONFIG_NUMA static int __init setup_slab_strict_numa(const char *str, const struct ker= nel_param *kp) @@ -8684,8 +8655,17 @@ void __init kmem_cache_init(void) =20 slab_obj_ext_has_codetag_init(); =20 + if (slab_max_order_param <=3D MAX_PAGE_ORDER) + slab_max_order =3D slab_max_order_param; + + if (slab_min_order_param <=3D MAX_PAGE_ORDER) + slab_min_order =3D slab_min_order_param; + if (debug_guardpage_minorder()) - slub_max_order =3D 0; + slab_max_order =3D 0; + + if (slab_min_order > slab_max_order) + slab_min_order =3D slab_max_order; =20 /* Inform pointer hashing choice about slub debugging state. */ hash_pointers_finalize(__slub_debug_enabled()); @@ -8736,7 +8716,7 @@ void __init kmem_cache_init(void) =20 pr_info("SLUB: HWalign=3D%d, Order=3D%u-%u, MinObjects=3D%u, CPUs=3D%u, N= odes=3D%u\n", cache_line_size(), - slub_min_order, slub_max_order, slub_min_objects, + slab_min_order, slab_max_order, slab_min_objects, nr_cpu_ids, nr_node_ids); } =20 --=20 2.55.0 From nobody Thu Sep 24 13:41:52 2026 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 173A14BC00B for ; Wed, 23 Sep 2026 15:45:23 +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=1790178325; cv=none; b=U1aR7TQcxe0AfLtPMHFPrZ0fIpRM4oODWLOiOyENi+WnoP/GKO3uKgoFs5QmJ3/4sVXf6S76JJSFXpWmD3KynPs+iGGGWNNSVA0y2BP6C+Uy8qr7ToREKDkkE5eT863VJ7pPk8VB8yPfYTajicKGfIbliBDk9WzJoVDAdRHsDzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790178325; c=relaxed/simple; bh=oRFd3jSh+Ikq6LFUu0mpRxbLtMKDI7N0YsJgZ5Gkrg4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FhozfHG93c5SDniHXs8DJud65EnI0APvoQtokjVpOSazlhDjZAnLK9I82bLYnUVDHaUMh8QLhXoY7Dn7Ne61y5UbuUOAeXlT9tBfBApEJdUN5CexErIeHLFitVbmvxhLBoUwJ64uxOL0588zb94Nk/bSyO6u/UjR96pHlsoblOc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g3gL/0e+; 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="g3gL/0e+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68ECD1F000FF; Wed, 23 Sep 2026 15:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790178323; bh=YX7Ca9UzhzFLU5oRq22G+Ie5WRxnHJyj2v5cEtZOB2k=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=g3gL/0e+5shDUIHrn2nqmkylPMYc3pgM7ni3CiM2giZYpJMw0yGKkUO0lu2lhJ4CR 48BUlyiTw7uCvCEZS9r5COkM6I2WAL7RGyymiTauq4Px2ljwFwLnujrEr6XcpN7E7P ob1OMdYzoy55f7h2Ts6J6ZkXdXdpo0e0XqGuUeEiiTdZYCAkeI8vCY/T7VLtTD7pKO 5TrlPxHEXgSAe5DcxuUqrIF9ILW+jeoGHO1ppQFfa+I7B0JMd1IyrqXnjFAjO2obeV VAftTKn8j1vREkPZR/8WvfsptJdO9BpY/Rd2FgFsizx0wRD/643CiREh88X5OGeDv8 Oqt7P2DY97ajw== From: "Vlastimil Babka (SUSE)" Date: Wed, 23 Sep 2026 17:45:07 +0200 Subject: [PATCH RFC 2/8] mm, slab: introduce slab_debug=N 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260923-slub_tiny_rework-v1-2-a0e66d536eb5@kernel.org> References: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> In-Reply-To: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> To: Harry Yoo Cc: Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Geert Uytterhoeven , Conor Dooley , Damien Le Moal , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Vlastimil Babka (SUSE)" X-Mailer: b4 0.16.0 Enabling slab_debug has the side-effect of disabling all percpu caching of objects (now via sheaves), which can be sometimes useful for saving memory for e.g. kdump kernels. To make this possible without the overhead (CPU or memory) of actual debugging options such as poisoning, introduce a No-op debug option that only forces the debugging slow paths and zero sheaf capacity. This will also allow reimplementing CONFIG_SLUB_TINY as a boot-time option. While documenting the new N option, remove obsolete SLAB references from the F option description. Signed-off-by: Vlastimil Babka (SUSE) --- Documentation/admin-guide/mm/slab.rst | 13 +++++++++++-- include/linux/slab.h | 5 ++++- mm/slab.h | 2 +- mm/slub.c | 3 +++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/mm/slab.rst b/Documentation/admin-gu= ide/mm/slab.rst index 14429ab90611..0beeae71d472 100644 --- a/Documentation/admin-guide/mm/slab.rst +++ b/Documentation/admin-guide/mm/slab.rst @@ -45,12 +45,12 @@ of the first "select slabs" blocks that matches the sla= b's name are applied. =20 Possible debug options are:: =20 - F Sanity checks on (enables SLAB_DEBUG_CONSISTENCY_CHECKS - Sorry SLAB legacy issues) + F Sanity (slab consistency) checks on alloc and free Z Red zoning P Poisoning (object and padding) U User tracking (free and alloc) T Trace (please only use on single slabs) + N No-op (force debugging slowpaths without any checks) A Enable failslab filter mark for the cache O Switch debugging off for caches that would have caused higher minimum slab orders @@ -85,6 +85,15 @@ in low memory situations or if there's high fragmentatio= n of memory. To =20 slab_debug=3DO =20 +The No-op option can be useful to minimize slab memory overhead by forcing= slab +debugging slowpaths, which disables percpu object caching. This reduces SMP +scalability significantly, but does not impose the extra cpu or memory ove= rhead +of debugging options that actually perform checks. This can be useful for = e.g. +kdump kernels where scalability is not a concern, but memory has to be +pre-reserved from the production kernel. So for a kdump kernel you can use= :: + + slab_debug=3DN + You can apply different options to different list of slab names, using blo= cks of options. This will enable red zoning for dentry and user tracking for kmalloc. All other slabs will not get any debugging enabled:: diff --git a/include/linux/slab.h b/include/linux/slab.h index cda126def67a..ed949e8522be 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -35,6 +35,7 @@ enum _slab_flag_bits { _SLAB_PANIC, _SLAB_TYPESAFE_BY_RCU, _SLAB_TRACE, + _SLAB_DEBUG_NOOP, #ifdef CONFIG_DEBUG_OBJECTS _SLAB_DEBUG_OBJECTS, #endif @@ -166,8 +167,10 @@ enum _slab_flag_bits { * Note that SLAB_TYPESAFE_BY_RCU was originally named SLAB_DESTROY_BY_RCU. */ #define SLAB_TYPESAFE_BY_RCU __SLAB_FLAG_BIT(_SLAB_TYPESAFE_BY_RCU) -/* Trace allocations and frees */ +/* DEBUG: Trace allocations and frees */ #define SLAB_TRACE __SLAB_FLAG_BIT(_SLAB_TRACE) +/* DEBUG: Force the debug slowpaths without actually doing anything */ +#define SLAB_DEBUG_NOOP __SLAB_FLAG_BIT(_SLAB_DEBUG_NOOP) =20 /* Flag to prevent checks on free */ #ifdef CONFIG_DEBUG_OBJECTS diff --git a/mm/slab.h b/mm/slab.h index 8fd6835e4235..77fcbf99b7b4 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -490,7 +490,7 @@ void flush_rcu_sheaves_on_cache(struct kmem_cache *s); SLAB_NO_USER_FLAGS | SLAB_KMALLOC | SLAB_NO_MERGE) =20 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | \ - SLAB_TRACE | SLAB_CONSISTENCY_CHECKS) + SLAB_TRACE | SLAB_DEBUG_NOOP | SLAB_CONSISTENCY_CHECKS) =20 #define SLAB_FLAGS_PERMITTED (SLAB_CORE_FLAGS | SLAB_DEBUG_FLAGS) =20 diff --git a/mm/slub.c b/mm/slub.c index a107a111c75e..bc593f0078c0 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1897,6 +1897,9 @@ parse_slub_debug_flags(const char *str, slab_flags_t = *flags, const char **slabs, case 't': *flags |=3D SLAB_TRACE; break; + case 'n': + *flags |=3D SLAB_DEBUG_NOOP; + break; case 'a': *flags |=3D SLAB_FAILSLAB; break; --=20 2.55.0 From nobody Thu Sep 24 13:41:52 2026 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 71A00522F0F for ; Wed, 23 Sep 2026 15:45:26 +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=1790178327; cv=none; b=tkV0n+fU+kReuvTkwfGCKN/a9UesY0/QdBFa4lUA/c0AqzOPJNaRMSUmlXJrVjbIjiAvX3supJLI48RvJb/kQcPSWFrfpXw1rP7lu2QKHtHIVHl1LPApbgeqZJP4nKTo4irlabi9f+2pl9OKLHIDrxAmrVnV3PPLCfTQu8JmIxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790178327; c=relaxed/simple; bh=cg22F4oWYlEmIpDCazd39kSV82zKWDDN8b6deVus19Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lVAXsnEiE6zy5P5CC7a7dFXgZXAB3/PK6+mnsAYwrGpxzXOkOg8qDqe6xMZR6jy3bSN6iPsX18K7lG7pufpRLF++N5bzUZx9Ko5alr++v5MuMmID53GxQ1IpGEfcs3dlFAy0Jh5X4sBMBlXSZPVVmBio57qJ36OP01TdbV3torw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nLn0rCcZ; 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="nLn0rCcZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F31911F00893; Wed, 23 Sep 2026 15:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790178326; bh=evsrLpPx+3ZMMMhVn053YC5QDyQsoD3UAb1BpOZ7Ewc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=nLn0rCcZWtnRie2FV59JJMs9XVRpY5HnaIUTOb2mC5GCLbmtByEVJcFPQzr9elvM8 lI7cb73x5uSEwwymSaBxb37s11aSIcS/PCCOvn2I2+2Xd6eg6sCZFkyEtnNe/98cXj zQ0htgsmDH9XHPc5RciveYGunT4BNdtXR/2HpWezWP7msphtQVKp0TaBSkyhdE1aUk UonsOUvqZbMcBP3hVMPvECP1mLe0JwOcrHdaHO6ViBL413m3fqCybyrW4hpDPIExOI TgAV5XLcZ6auagicNjbX6D0fNm1/oMh0iWth++pLF4aIg1lQm5U5qRhnrpMTzWSOk5 Pr8hZo37zbYbA== From: "Vlastimil Babka (SUSE)" Date: Wed, 23 Sep 2026 17:45:08 +0200 Subject: [PATCH RFC 3/8] mm, slab: rework KMALLOC_RECLAIM handling of SLUB_TINY 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260923-slub_tiny_rework-v1-3-a0e66d536eb5@kernel.org> References: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> In-Reply-To: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> To: Harry Yoo Cc: Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Geert Uytterhoeven , Conor Dooley , Damien Le Moal , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Vlastimil Babka (SUSE)" X-Mailer: b4 0.16.0 One (relatively minor) aspect of CONFIG_SLUB_TINY is the assumption that letting reclaimable and non-reclaimable caches merge will save more memory, which is more important on small systems than the page allocator level fragmentation (where distinguishing reclaimable slabs should help). For now that has been achieved by #ifdefs that result in making the SLAB_RECLAIM_ACCOUNT no-op and aliasing KMALLOC_RECLAIM to KMALLOC_NORMAL on the enum values level. With the goal of converting CONFIG_SLUB_TINY to a boot-time decision, rework this so that SLAB_RECLAIM_ACCOUNT and KMALLOC_RECLAIM are distinctly defined always. Now, creation of kmalloc-rcl caches is avoided by assigning a pointer to the normal kmalloc cache on the kmalloc_caches array level. To prepare disconnecting of this boot-time decision (and the evaluation of the need for kmalloc_no_objext) from CONFIG_SLUB_TINY, introduce a slub_tiny_enabled variable that's initialized to the CONFIG_SLUB_TINY state. There is one minor functional change for CONFIG_SLUB_TINY: with SLAB_RECLAIM_ACCOUNT not being 0 anymore, caches with and without the flag will stop being mergeable. If that turns out to have a noticeable impact on memory footprint, we can adjust the merging decisions to ignore SLAB_RECLAIM_ACCOUNT when slub_tiny_enabled is true. Signed-off-by: Vlastimil Babka (SUSE) --- include/linux/slab.h | 10 ---------- mm/slab.h | 5 +++-- mm/slab_common.c | 12 ++++++------ mm/slub.c | 2 ++ 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index ed949e8522be..930dd64b9ad6 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -55,9 +55,7 @@ enum _slab_flag_bits { #ifdef CONFIG_KFENCE _SLAB_SKIP_KFENCE, #endif -#ifndef CONFIG_SLUB_TINY _SLAB_RECLAIM_ACCOUNT, -#endif _SLAB_OBJECT_POISON, _SLAB_CMPXCHG_DOUBLE, #ifdef CONFIG_SLAB_OBJ_EXT @@ -241,11 +239,7 @@ enum _slab_flag_bits { * pages are allocated with __GFP_RECLAIMABLE, which affects grouping page= s by * mobility, and are accounted in SReclaimable counter in /proc/meminfo */ -#ifndef CONFIG_SLUB_TINY #define SLAB_RECLAIM_ACCOUNT __SLAB_FLAG_BIT(_SLAB_RECLAIM_ACCOUNT) -#else -#define SLAB_RECLAIM_ACCOUNT __SLAB_FLAG_UNUSED -#endif #define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ =20 /* Slab caches without obj_exts array */ @@ -724,11 +718,7 @@ enum kmalloc_cache_type { #endif KMALLOC_PARTITION_START =3D KMALLOC_NORMAL, KMALLOC_PARTITION_END =3D KMALLOC_PARTITION_START + KMALLOC_PARTITION_CAC= HES_NR, -#ifdef CONFIG_SLUB_TINY - KMALLOC_RECLAIM =3D KMALLOC_NORMAL, -#else KMALLOC_RECLAIM, -#endif #ifdef CONFIG_ZONE_DMA KMALLOC_DMA, #endif diff --git a/mm/slab.h b/mm/slab.h index 77fcbf99b7b4..00d49ac0d93f 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -410,6 +410,8 @@ extern const struct kmalloc_info_struct { unsigned int size; } kmalloc_info[]; =20 +extern bool slab_tiny_enabled; + /* Kmalloc array related functions */ void setup_kmalloc_cache_index_table(void); void create_kmalloc_caches(void); @@ -590,8 +592,7 @@ static inline bool need_kmalloc_no_objext(void) if (!mem_alloc_profiling_permanently_disabled()) return true; =20 - if (!mem_cgroup_kmem_disabled() && - (KMALLOC_NORMAL =3D=3D KMALLOC_RECLAIM)) + if (!mem_cgroup_kmem_disabled() && slab_tiny_enabled) return true; =20 return false; diff --git a/mm/slab_common.c b/mm/slab_common.c index 28bf035a58f3..38de7d50bfa7 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -826,11 +826,7 @@ EXPORT_SYMBOL(kmalloc_size_roundup); #define KMALLOC_CGROUP_NAME(sz) #endif =20 -#ifndef CONFIG_SLUB_TINY #define KMALLOC_RCL_NAME(sz) .name[KMALLOC_RECLAIM] =3D "kmalloc-rcl-" #sz, -#else -#define KMALLOC_RCL_NAME(sz) -#endif =20 #ifdef CONFIG_KMALLOC_PARTITION_CACHES #define __KMALLOC_PARTITION_CONCAT(a, b) a ## b @@ -967,7 +963,11 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type typ= e) unsigned int aligned_size =3D kmalloc_info[idx].size; int aligned_idx =3D idx; =20 - if ((KMALLOC_RECLAIM !=3D KMALLOC_NORMAL) && (type =3D=3D KMALLOC_RECLAIM= )) { + if (type =3D=3D KMALLOC_RECLAIM) { + if (slab_tiny_enabled) { + kmalloc_caches[type][idx] =3D kmalloc_caches[KMALLOC_NORMAL][idx]; + return; + } flags |=3D SLAB_RECLAIM_ACCOUNT; } else if (IS_ENABLED(CONFIG_MEMCG) && (type =3D=3D KMALLOC_CGROUP)) { if (mem_cgroup_kmem_disabled()) { @@ -1000,7 +1000,7 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type ty= pe) * KMALLOC_NO_OBJ_EXT cache. */ if (!mem_cgroup_kmem_disabled()) { - if (type =3D=3D KMALLOC_NORMAL && KMALLOC_RECLAIM !=3D KMALLOC_NORMAL) + if (type =3D=3D KMALLOC_NORMAL && !slab_tiny_enabled) flags |=3D SLAB_NO_MERGE; else if (!(flags & SLAB_NO_OBJ_EXT)) flags |=3D SLAB_MAY_ACCOUNT; diff --git a/mm/slub.c b/mm/slub.c index bc593f0078c0..2a7b3b3b91b5 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -219,6 +219,8 @@ DEFINE_STATIC_KEY_MAYBE(CONFIG_MEM_ALLOC_PROFILING_ENAB= LED_BY_DEFAULT, slab_obj_ext_has_codetag_key); #endif =20 +bool slab_tiny_enabled __read_mostly =3D IS_ENABLED(CONFIG_SLUB_TINY); + /* Structure holding extra parameters for slab allocations */ struct slab_alloc_context { unsigned long caller_addr; --=20 2.55.0 From nobody Thu Sep 24 13:41:52 2026 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 05A625335AA for ; Wed, 23 Sep 2026 15:45:28 +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=1790178330; cv=none; b=QFcvicC+eZ+24dY9D9XlhFl9+ELKJEXkjyXjNrV7fmAxdohPKxxFHhr2n7OhdWEcCwCrSqsKWVU3szzF1d4r+vIUrgMud1krdV59WO/2vhKrYE8Pz4k9/++P9mweUUbmBFFgjlSB4HcCzQNMehnMl+xE0yPO04yyVU5n73qT1aU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790178330; c=relaxed/simple; bh=33FdYS7LcHQOUuVVbB724hi3rHicKValZW5fZAPUwE4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sPpqVLZGEczeIiqMXfOR8EY90JSczlpPOjGP8qjqICIuCR3WbYF3Yeq8eBjfF9BtjA+kw3RiKxTp3ER2CbmNfgckztJeLc8+tMQZECsl8wgxgTy2wU6Md9tMQyg5QlrpLUFPF5zsUMJQRvuRjVveimiejzjMZ4FhpyXebSuKT9E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h7OTHLD4; 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="h7OTHLD4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87F671F000FF; Wed, 23 Sep 2026 15:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790178328; bh=NzT0YNZekEUjP9R0sb5doBa5YOLmVvxQILIsqj1HgT8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=h7OTHLD4zH6KwJ6BLFqpcKrGs3/t4gr+WYAn8O9Bo6UWEIK717FJcpQcPPo6FNOfL As19/HSnO6zPWKxjEbIjEZrAgstc+GM7B+ikA2oa8Q+UYxtlCRBhuca6Lkb5PI7I1g jpH4nyb9ASSYfAcWLvUiaOEM9z/dHG8Inr1gSxHLN13im1WQ4KK9nBgCDT4p960R96 mNcWU+OSWHFlUAjOyCO53HZHLgyLF/GhZALDFdPhq87GITelC3l52X2UEqERId29qn wAGkz6H2+VvUk0NniOL6loNnfSem0f6VeI3P0tGaXVHY2IQRinHG7n23mREDpV4w3V VEPH/eFmvOWgw== From: "Vlastimil Babka (SUSE)" Date: Wed, 23 Sep 2026 17:45:09 +0200 Subject: [PATCH RFC 4/8] mm, slab: make SLUB_TINY handling dynamic for sizing decisions 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260923-slub_tiny_rework-v1-4-a0e66d536eb5@kernel.org> References: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> In-Reply-To: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> To: Harry Yoo Cc: Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Geert Uytterhoeven , Conor Dooley , Damien Le Moal , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Vlastimil Babka (SUSE)" X-Mailer: b4 0.16.0 Enabling CONFIG_SLUB_TINY results in the caches' min partial slabs threshold to be zero, thus every slab where all objects become free is freed immediately. It also sets the default slab_max_order to 1, with the goal of reducing the potential of internal slab fragmentation. Rework both of these decisions to be based on the newly introduced slab_tiny_enabled flag instead of #ifdefs. It's still possible to override the reduced slab_max_order with the boot parameter, as before. Signed-off-by: Vlastimil Babka (SUSE) --- mm/slub.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 2a7b3b3b91b5..2c8477033700 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -272,7 +272,6 @@ void *fixup_red_left(struct kmem_cache *s, void *p) /* Enable to log cmpxchg failures */ #undef SLUB_DEBUG_CMPXCHG =20 -#ifndef CONFIG_SLUB_TINY /* * Minimum number of partial slabs. These will be left on the partial * lists even if they are empty. kmem_cache_shrink may reclaim them. @@ -285,10 +284,6 @@ void *fixup_red_left(struct kmem_cache *s, void *p) * sort the partial list by the number of objects in use. */ #define MAX_PARTIAL 10 -#else -#define MIN_PARTIAL 0 -#define MAX_PARTIAL 0 -#endif =20 #define DEBUG_DEFAULT_FLAGS (SLAB_CONSISTENCY_CHECKS | SLAB_RED_ZONE | \ SLAB_POISON | SLAB_STORE_USER) @@ -7604,8 +7599,7 @@ EXPORT_SYMBOL(kmem_cache_alloc_bulk_noprof); * take the list_lock. */ static unsigned int slab_min_order; -static unsigned int slab_max_order =3D - IS_ENABLED(CONFIG_SLUB_TINY) ? 1 : PAGE_ALLOC_COSTLY_ORDER; +static unsigned int slab_max_order =3D PAGE_ALLOC_COSTLY_ORDER; static unsigned int slab_min_objects; =20 /* @@ -7924,7 +7918,7 @@ static unsigned int calculate_sheaf_capacity(struct k= mem_cache *s, size_t size; =20 =20 - if (IS_ENABLED(CONFIG_SLUB_TINY) || s->flags & SLAB_DEBUG_FLAGS) + if (slab_tiny_enabled || s->flags & SLAB_DEBUG_FLAGS) return 0; =20 /* @@ -8660,6 +8654,9 @@ void __init kmem_cache_init(void) =20 slab_obj_ext_has_codetag_init(); =20 + if (slab_tiny_enabled) + slab_max_order =3D 1; + if (slab_max_order_param <=3D MAX_PAGE_ORDER) slab_max_order =3D slab_max_order_param; =20 @@ -8783,6 +8780,8 @@ int do_kmem_cache_create(struct kmem_cache *s, const = char *name, */ s->min_partial =3D min_t(unsigned long, MAX_PARTIAL, ilog2(s->size) / 2); s->min_partial =3D max_t(unsigned long, MIN_PARTIAL, s->min_partial); + if (slab_tiny_enabled) + s->min_partial =3D 0; =20 s->cpu_sheaves =3D alloc_percpu(struct slub_percpu_sheaves); if (!s->cpu_sheaves) { --=20 2.55.0 From nobody Thu Sep 24 13:41:52 2026 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 901E6538D81 for ; Wed, 23 Sep 2026 15:45:31 +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=1790178332; cv=none; b=C/jqTmb2JOoQuzRLuHl+HmNZXDgLP8OGs0Hjn3xrW9RHBBZSdbCM7LefNI4dA4RClNizsmXu1hXkkisCHPT3y2yreJL7r5CK2LxxAVMFtGhueQS0Io70wZQcEktCokBqf5Qs8YXjwqLq+JYcoq0t071GOcXPRoIuHIJPAGepZO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790178332; c=relaxed/simple; bh=VPi15PsOqWVBx9nDmNt6QjdRuJxbnsvb4+NwLBJjDZ0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PcXP2cBnYEeBfNPBaAUAvvW2b2iHawYKUfHbAA+oT/hJxD6xqUMukwqPohf6bif/AG/fSaJCJMT2q/a3anMufbL7NBn8RwTxrhTlqrXu4LuwrV5rq1s33u/NzGL+YwFO5bYSppPdi6p/oQdItYdUhuYycvp5eDO8ZnMp4qKu5e8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UbAbL/u0; 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="UbAbL/u0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2055D1F00893; Wed, 23 Sep 2026 15:45:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790178331; bh=cf8h14QuICV9AFXO/du43rKQzztTKxLUCWiq2pXLLBo=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=UbAbL/u0JvZsUlgMBthQ9AwH/tO5dqygUtU92S1O4NBxtmdXFyrl3cRipSBmjz6Ye zDtjhRBPD1uZguo51h9n7WpVJVIuqZp5XCWn+6ORbau3BmWymNXUSqSQL4QhipCEBF fSxKkUWh/1Z0tkoC10Mq7lBPNpx3V8pHY+HobR4m1qA2xulcoYXSqox91RmMBCcHGC 3Mk1i4JtKXzx1n4krOIJ0pILM0tegZ3ms3ZSARbUtJ29EUR7DIu9WTo1/8rvHWruA0 X8nvOsDQNsy3tLWbAnLUOxZQmdM9wocYFlvq5NDOYSJ0O3vOWsQtEuycARKu0gJP/v pdKQxOunPuyLg== From: "Vlastimil Babka (SUSE)" Date: Wed, 23 Sep 2026 17:45:10 +0200 Subject: [PATCH RFC 5/8] mm, slab: convert CONFIG_SLUB_TINY checks to kmem_cache_debug() 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260923-slub_tiny_rework-v1-5-a0e66d536eb5@kernel.org> References: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> In-Reply-To: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> To: Harry Yoo Cc: Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Geert Uytterhoeven , Conor Dooley , Damien Le Moal , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Vlastimil Babka (SUSE)" X-Mailer: b4 0.16.0 CONFIG_SLUB_TINY shares several slowpaths with debugging as both of them avoid percpu caching of objects. With the goal of replacing the config with a boot-time decision, extend this sharing by hooking slab_tiny_enabled into kmem_cache_debug() check itself. This is made possible by the new SLAB_DEBUG_NOOP debug flag. Make slub_debug_enabled static key always available (not just with CONFIG_SLUB_DEBUG enabled) and have slab_tiny_enabled add SLAB_DEBUG_NOOP to all caches in kmem_cache_flags(). Do this also in the CONFIG_SLUB_DEBUG variant, which is currently exclusive with CONFIG_SLUB_TINY, but that will be lifted later. Remove the various IS_ENABLED(CONFIG_SLUB_TINY) checks that complement kmem_cache_debug() checks as they are no longer necessary. While removing/adjusting the CONFIG_SLUB_DEBUG #ifdefs, also convert CONFIG_SLUB_DEBUG_ON to *_STATIC_KEY_MAYBE(). Signed-off-by: Vlastimil Babka (SUSE) --- mm/slab.h | 18 ++++++------------ mm/slub.c | 38 ++++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index 00d49ac0d93f..23017a5d10d1 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -520,26 +520,20 @@ struct slabinfo { =20 void get_slabinfo(struct kmem_cache *s, struct slabinfo *sinfo); =20 -#ifdef CONFIG_SLUB_DEBUG -#ifdef CONFIG_SLUB_DEBUG_ON -DECLARE_STATIC_KEY_TRUE(slub_debug_enabled); -#else -DECLARE_STATIC_KEY_FALSE(slub_debug_enabled); -#endif -extern void print_tracking(struct kmem_cache *s, void *object); -long validate_slab_cache(struct kmem_cache *s); +DECLARE_STATIC_KEY_MAYBE(CONFIG_SLUB_DEBUG_ON, slub_debug_enabled); + static inline bool __slub_debug_enabled(void) { return static_branch_unlikely(&slub_debug_enabled); } + +#ifdef CONFIG_SLUB_DEBUG +extern void print_tracking(struct kmem_cache *s, void *object); +long validate_slab_cache(struct kmem_cache *s); #else static inline void print_tracking(struct kmem_cache *s, void *object) { } -static inline bool __slub_debug_enabled(void) -{ - return false; -} #endif =20 /* diff --git a/mm/slub.c b/mm/slub.c index 2c8477033700..c6a0422e055d 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -202,13 +202,7 @@ enum slab_flags { #define __fastpath_inline #endif =20 -#ifdef CONFIG_SLUB_DEBUG -#ifdef CONFIG_SLUB_DEBUG_ON -DEFINE_STATIC_KEY_TRUE(slub_debug_enabled); -#else -DEFINE_STATIC_KEY_FALSE(slub_debug_enabled); -#endif -#endif /* CONFIG_SLUB_DEBUG */ +DEFINE_STATIC_KEY_MAYBE(CONFIG_SLUB_DEBUG_ON, slub_debug_enabled); =20 #ifdef CONFIG_NUMA static DEFINE_STATIC_KEY_FALSE(strict_numa); @@ -1040,11 +1034,7 @@ static inline void *restore_red_left(struct kmem_cac= he *s, void *p) /* * Debug settings: */ -#if defined(CONFIG_SLUB_DEBUG_ON) -static slab_flags_t slub_debug =3D DEBUG_DEFAULT_FLAGS; -#else -static slab_flags_t slub_debug; -#endif +static slab_flags_t slub_debug =3D IS_ENABLED(CONFIG_SLUB_DEBUG_ON) ? DEBU= G_DEFAULT_FLAGS : 0; =20 static const char *slub_debug_string __ro_after_init; static int disable_higher_order_debug; @@ -2017,6 +2007,9 @@ slab_flags_t kmem_cache_flags(slab_flags_t flags, con= st char *name) slab_flags_t block_flags; slab_flags_t slub_debug_local =3D slub_debug; =20 + if (slab_tiny_enabled) + flags |=3D SLAB_DEBUG_NOOP; + if (flags & SLAB_NO_USER_FLAGS) return flags; =20 @@ -2087,6 +2080,9 @@ static inline void remove_full(struct kmem_cache *s, = struct kmem_cache_node *n, struct slab *slab) {} slab_flags_t kmem_cache_flags(slab_flags_t flags, const char *name) { + if (slab_tiny_enabled) + flags |=3D SLAB_DEBUG_NOOP; + return flags; } #define slub_debug 0 @@ -3942,7 +3938,7 @@ static void *get_from_partial_node(struct kmem_cache = *s, if (!pfmemalloc_match(slab, gfp_flags)) continue; =20 - if (IS_ENABLED(CONFIG_SLUB_TINY) || kmem_cache_debug(s)) { + if (kmem_cache_debug(s)) { object =3D alloc_single_from_partial(s, n, slab, ac->orig_size); if (object) @@ -4556,7 +4552,7 @@ static unsigned int alloc_from_new_slab(struct kmem_c= ache *s, struct slab *slab, =20 /* * Slow path. We failed to allocate via percpu sheaves or they are not ava= ilable - * due to bootstrap or debugging enabled or SLUB_TINY. + * due to bootstrap or debugging enabled. * * We try to allocate from partial slab lists and fall back to allocating = a new * slab. @@ -4610,7 +4606,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_= t gfpflags, int node, =20 stat(s, ALLOC_SLAB); =20 - if (IS_ENABLED(CONFIG_SLUB_TINY) || kmem_cache_debug(s)) { + if (kmem_cache_debug(s)) { object =3D alloc_single_from_new_slab(s, slab, ac); =20 if (likely(object)) @@ -5764,7 +5760,7 @@ static void __slab_free(struct kmem_cache *s, struct = slab *slab, unsigned long flags; bool on_node_partial; =20 - if (IS_ENABLED(CONFIG_SLUB_TINY) || kmem_cache_debug(s)) { + if (kmem_cache_debug(s)) { free_to_partial_list(s, slab, head, tail, cnt, addr); return; } @@ -7471,7 +7467,7 @@ static bool __kmem_cache_alloc_bulk(struct kmem_cache= *s, gfp_t flags, { int i; =20 - if (IS_ENABLED(CONFIG_SLUB_TINY) || kmem_cache_debug(s)) { + if (kmem_cache_debug(s)) { const struct slab_alloc_context ac =3D { .caller_addr =3D _RET_IP_, .orig_size =3D s->object_size, @@ -7772,7 +7768,7 @@ static int init_percpu_sheaves(struct kmem_cache *s) * cache. * * We keep bootstrap_sheaf for kmem_cache and kmem_cache_node, - * caches with debug enabled, and all caches with SLUB_TINY. + * and caches with debugging enabled. * For kmalloc caches it's used temporarily during the initial * bootstrap. */ @@ -8588,7 +8584,7 @@ static void __init bootstrap_cache_sheaves(struct kme= m_cache *s) =20 capacity =3D calculate_sheaf_capacity(s, &empty_args); =20 - /* capacity can be 0 due to debugging or SLUB_TINY */ + /* capacity can be 0 due to debugging */ if (!capacity) return; =20 @@ -8654,8 +8650,10 @@ void __init kmem_cache_init(void) =20 slab_obj_ext_has_codetag_init(); =20 - if (slab_tiny_enabled) + if (slab_tiny_enabled) { slab_max_order =3D 1; + static_branch_enable(&slub_debug_enabled); + } =20 if (slab_max_order_param <=3D MAX_PAGE_ORDER) slab_max_order =3D slab_max_order_param; --=20 2.55.0 From nobody Thu Sep 24 13:41:52 2026 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 5AF5C53D0A6 for ; Wed, 23 Sep 2026 15:45:34 +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=1790178336; cv=none; b=Mk4dfTcOHOrgh2hidMHAgohm/vTmQSaEeYCXMz3gYelGTg6pQNvoilv9tfxcawFeUFB8stRFofT8OC2dn0Kgmv2QN8q5MyLczbF78ypewTOH/qZ26qke0C7EsEIP5m7XCEZE7nMM7TQv3WJllAGMof6Sf08mApwSXPJyGJ3YWzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790178336; c=relaxed/simple; bh=vqbRjdBNGswfQFfPyJ+V4zNIV90PXQwfAxpwZB+a1Zs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bwBoE1PXO6XfxqpHPdIVS7b6zoTWXA7mgWYBCPAz83AQyM40lEYOR5zsCRazsx8ZwZSOLHYgmv9ahvwWyrPnYZdgeG98msoJDU5a3/rkFGlc9D3R8X0FHSlQbmr/xGk7rNMjWRMgb6nBda9TlUt1vVqCocihkTOeQIHihIvilho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YRPzTi0t; 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="YRPzTi0t" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A91DE1F000FF; Wed, 23 Sep 2026 15:45:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790178333; bh=EMIQ8REFMb6acQ/FvLPkwRl4y6xpfycLIc9I6w2Z8IA=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=YRPzTi0t/aNV2USi5quM29/LcexoXRiBzJyVHc9Cl1NZCUu6aGOkFA5NIXTzkBGGG 6f44I48FlewUg0O3N6WPXf/un48KDg2WhoHiT5YGYI3jL7Zdgw1ggOaK38pg+wZV9P WaP/ezP/ugqgqP3VGWtVnn9ZSbKDjpdCZEIdxiSRYP/dK6VqS+YKOA8r0vdx2i4XZd 9RTd86EzJ009yfGLrGbMYV/4vqlKryoBdV4OxV9flX+3ALsrKpm9/+k9SUFVTOipfc o3eZdGIFs9qvAqvURHcZsRJNp1r0QF9TLs1bYbzWuW9MfdoMmt2elyJErc4DuDxkXT cKUAZ9xA/yJoA== From: "Vlastimil Babka (SUSE)" Date: Wed, 23 Sep 2026 17:45:11 +0200 Subject: [PATCH RFC 6/8] mm, slab: remove remaining compile-time checks for CONFIG_SLUB_TINY 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260923-slub_tiny_rework-v1-6-a0e66d536eb5@kernel.org> References: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> In-Reply-To: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> To: Harry Yoo Cc: Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Geert Uytterhoeven , Conor Dooley , Damien Le Moal , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Vlastimil Babka (SUSE)" X-Mailer: b4 0.16.0 Remove several minor aspect of CONFIG_SLUB_TINY to allow it to be fully a boot-time decision: - remove check in cache_has_sheaves(), with no change to functionality but only on code elimination - remove SLAB_SUPPORTS_SYSFS dependency on !CONFIG_SLUB_TINY, thus /sys/kernel/slab will exist as long as CONFIG_SYSFS is enabled (for now leave SLAB_SUPPORTS_SYSFS around, can be cleaned up later) - remove the control of __fastpath_inline so it's just a wrapper of __always_inline. Leave it also around for documenting the intent, can be revisited later. - remove a comment for SLAB_NO_MERGE as we don't want new checks for CONFIG_SLUB_TINY This leaves the only usage of CONFIG_SLUB_TINY in slab code to set the value of slab_tiny_enabled around. net/core/skbuff.c keeps using it to control SLAB_NO_MERGE but that can be dealt with independently after the config is deprecated. Signed-off-by: Vlastimil Babka (SUSE) --- include/linux/slab.h | 2 +- mm/slab.h | 7 +++---- mm/slub.c | 4 ---- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 930dd64b9ad6..ad645967a3ee 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -188,7 +188,7 @@ enum _slab_flag_bits { * - general caches created and used by a subsystem, only when a * (subsystem-specific) debug option is enabled * - performance critical caches, should be very rare and consulted with s= lab - * maintainers, and not used together with CONFIG_SLUB_TINY + * maintainers */ #define SLAB_NO_MERGE __SLAB_FLAG_BIT(_SLAB_NO_MERGE) =20 diff --git a/mm/slab.h b/mm/slab.h index 23017a5d10d1..065de2b92586 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -296,16 +296,15 @@ struct kmem_cache { /* * Every cache has !NULL s->cpu_sheaves but they may point to the * bootstrap_sheaf temporarily during init, or permanently for the boot ca= ches - * and caches with debugging enabled, or all caches with CONFIG_SLUB_TINY.= This + * and caches with debugging enabled (or all caches with slab_tiny). This * helper distinguishes whether cache has real non-bootstrap sheaves. */ static inline bool cache_has_sheaves(struct kmem_cache *s) { - /* Test CONFIG_SLUB_TINY for code elimination purposes */ - return !IS_ENABLED(CONFIG_SLUB_TINY) && s->sheaf_capacity; + return s->sheaf_capacity; } =20 -#if defined(CONFIG_SYSFS) && !defined(CONFIG_SLUB_TINY) +#ifdef CONFIG_SYSFS #define SLAB_SUPPORTS_SYSFS 1 void sysfs_slab_unlink(struct kmem_cache *s); void sysfs_slab_release(struct kmem_cache *s); diff --git a/mm/slub.c b/mm/slub.c index c6a0422e055d..4814f025fde5 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -196,11 +196,7 @@ enum slab_flags { SL_pfmemalloc =3D PG_active, /* Historical reasons for this bit */ }; =20 -#ifndef CONFIG_SLUB_TINY #define __fastpath_inline __always_inline -#else -#define __fastpath_inline -#endif =20 DEFINE_STATIC_KEY_MAYBE(CONFIG_SLUB_DEBUG_ON, slub_debug_enabled); =20 --=20 2.55.0 From nobody Thu Sep 24 13:41:52 2026 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 C91E853E31E for ; Wed, 23 Sep 2026 15:45:36 +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=1790178337; cv=none; b=CLA35PZuBVXt6Pw5mTHuoRJRolngBK5+FJHOBYIIIYT77bhOjt2R4fp6uJb8B+Ncsagq8xcGpO5Uvndlww6HJgcWCWtQoxIhQRKw1Z9hOM9MwYD7sxVYnZBOxDMRfYVQO/z9qjDMIGtMxx9xRSaKgYLN3O4Mld4tCg22tVmNzlw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790178337; c=relaxed/simple; bh=hScDQprsw5+sgrdz7qxkFNYcYfaoJi0oQcN1B/bnk+s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A1g6AP6dAimySQACpzxwHL+poX6/IMb5kpZif80jo1FfGW7uH5R1XJIHe85BOln61Uw+x1UU4WfoJR3bzMS1ZaYW2EVQ1wLCg108s8ZaiM7Z6f2E2q7NdqotMzMHB94B9vNJnTSLfpWh7Dx4vnYlAh4AT/xJX2YGcpWGI8zxm5A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MWrqf1sz; 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="MWrqf1sz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DB611F00893; Wed, 23 Sep 2026 15:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790178336; bh=ZH/DiEqRWfRpDNmn9lxvEBbuNmwbYZYpFCH81u3DETY=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=MWrqf1szrP2VTEzbeFhP8yt/m4eHDnd56LMUoI0iQ8NSaD7hoNlznfPH6hGXRwTyC Gmt1XvqQYWyzVpG1evAdvVrx74St4RGjVdHaMRIl35J+oQyRPqc98znaEzqIZJwyBV fJ2K9jJE4R2QxfScBPgnl/Te0Kl484+s2rn48mU/z1A+is6OLmzZARx4Zh6gjT3j3r C3H0Ime1n+jNMwiJy4UNkpVYZxiPPlOZymqaE6MLiro58CLw0OOabHARBQs19ehr5H ydQqa04m1yr9FkphxYMbl68OXnWw78uDT3St/AUf68njsX6IGriQBp4H9AhPjpWfSQ lipCntGlXeAMg== From: "Vlastimil Babka (SUSE)" Date: Wed, 23 Sep 2026 17:45:12 +0200 Subject: [PATCH RFC 7/8] mm, slab: add slab_tiny boot param 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260923-slub_tiny_rework-v1-7-a0e66d536eb5@kernel.org> References: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> In-Reply-To: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> To: Harry Yoo Cc: Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Geert Uytterhoeven , Conor Dooley , Damien Le Moal , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Vlastimil Babka (SUSE)" X-Mailer: b4 0.16.0 In order to deprecate the CONFIG_SLUB_TINY option, introduce an early boot param slab_tiny to control the value of slab_tiny_enabled. As long as CONFIG_SLUB_TINY is still around and enabled, this boot param can also override it to be disabled. Signed-off-by: Vlastimil Babka (SUSE) --- Documentation/admin-guide/kernel-parameters.txt | 4 ++++ Documentation/admin-guide/mm/slab.rst | 5 +++++ mm/slub.c | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 33cd30996e47..0100ab00388a 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -7031,6 +7031,10 @@ Kernel parameters NUMA kernel object placement which helps with slow interconnects in NUMA systems. =20 + slab_tiny=3D [MM, EARLY] + Minimize the slab allocator memory footprint at the + expense of SMP scalability. + slram=3D [HW,MTD] =20 smart2=3D [HW] diff --git a/Documentation/admin-guide/mm/slab.rst b/Documentation/admin-gu= ide/mm/slab.rst index 0beeae71d472..6c005d3de0b2 100644 --- a/Documentation/admin-guide/mm/slab.rst +++ b/Documentation/admin-guide/mm/slab.rst @@ -94,6 +94,11 @@ kdump kernels where scalability is not a concern, but me= mory has to be =20 slab_debug=3DN =20 +Note that for this purpose you can instead use an option that can achieve +slightly better memory savings (by not creating separate kmalloc-rcl cache= s):: + + slab_tiny=3D1 + You can apply different options to different list of slab names, using blo= cks of options. This will enable red zoning for dentry and user tracking for kmalloc. All other slabs will not get any debugging enabled:: diff --git a/mm/slub.c b/mm/slub.c index 4814f025fde5..d672809fa2f6 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -8726,6 +8726,13 @@ void __init kmem_cache_init_late(void) #endif } =20 +static int __init early_slab_tiny(char *buf) +{ + return kstrtobool(buf, &slub_tiny_enabled); +} + +early_param("slab_tiny", early_slab_tiny); + int do_kmem_cache_create(struct kmem_cache *s, const char *name, unsigned int size, struct kmem_cache_args *args, slab_flags_t flags) --=20 2.55.0 From nobody Thu Sep 24 13:41:52 2026 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 6E16953F6A3 for ; Wed, 23 Sep 2026 15:45:39 +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=1790178341; cv=none; b=jZ3g/8lqoC3QvH1euP7ruFKT8tQdsZTxpCRzHa78fRycJHK9CaMSpQzIKaaEwDF6YR3OkwxpFgy4mPNSETpUg/yrHx/qExrbPhNoI576MTO8113jTSqxgwItey7mP0i6MMZ18m9JXjQpA0sBBCbiyaYJ2wq1RGEswDDTpqDfFHo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790178341; c=relaxed/simple; bh=2Dc5Bfk0Rj9RNVBdjgldw7t9gZvHixfkRyh1nIxHxVw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oCtiT6wguxAUej3B3iPc77vv4n4EaRQKMJUdKjLTz8Uo7OVgdKOplj/xRcu7/rlVr2m6FUfxkt7zveIMt0MQikc6mntEQFSndMu5jkm20Rl5J/U+hhhOlTe3AJd7ta84fdZsObhDdbmv5DM75CRw2o0MKtlDtRT20wTPxIc0BSg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c5lR8OKn; 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="c5lR8OKn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6D4C1F0089E; Wed, 23 Sep 2026 15:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790178338; bh=ndf5eV8Fv81ukOHNfSKozUzjOHGtJEUSne1n2V5ZgcI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=c5lR8OKnJT4jmtwR73IkOvXqTMfO1KzNkUM0tHa0jX4ycvfPBwCUgK9uiWPRQcIlR fP/+/vp9BrmECh988I7fFDMTg2DNRJ9zhLyhplQR2sP38LLBE6fdGkwz3CXrmFNRTl EtNHSLdvAEd3dbt4Ztv4Wo7BgGilRRiKZyxaELSoCe5r+PLoU8qcc7H2Y5maZ2mIV3 EyJD0jN7vMAdbMr0UoAmv0GOOnk3ZyJKIzsrv0G8btzYPPBy2FeHkItFUqD1uCQr+8 DtGS5HCypt6vSzLr4abeVSTy2eGQYnPQMi/qDqNi5ameOhv6UxDDR4OW3YoedW1ueT Lguuzn69uHV3Q== From: "Vlastimil Babka (SUSE)" Date: Wed, 23 Sep 2026 17:45:13 +0200 Subject: [PATCH RFC 8/8] mm, slab: deprecate CONFIG_SLUB_TINY and reduce its Kconfig effects 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260923-slub_tiny_rework-v1-8-a0e66d536eb5@kernel.org> References: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> In-Reply-To: <20260923-slub_tiny_rework-v1-0-a0e66d536eb5@kernel.org> To: Harry Yoo Cc: Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Geert Uytterhoeven , Conor Dooley , Damien Le Moal , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Vlastimil Babka (SUSE)" X-Mailer: b4 0.16.0 At this point CONFIG_SLUB_TINY only affects the default value of slab_tiny_enabled which has a boot-time parameter. Thus deprecate it in the Kconfig description. Also remove its interactions with other Kconfig option, as they are not necessary: - KASAN, SLUB_DEBUG or SLUB_STATS support does not need !SLUB_TINY - KVFREE_RCU_BATCHED can simply depend on !TINY_RCU - various hardening options do not need to be excluded, although it's unlikely that somebody would enable those with extra memory overhead together with slab_tiny - SLAB_MERGE_DEFAULT does not need to be selected, although it's likely to be used together Keep the "depends on EXPERT && !COMPILE_TEST" as there's no point making the deprecated option more visible. Signed-off-by: Vlastimil Babka (SUSE) --- lib/Kconfig.kasan | 2 +- mm/Kconfig | 16 +++++++--------- mm/Kconfig.debug | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan index a4bb610a7a6f..f20b574f6653 100644 --- a/lib/Kconfig.kasan +++ b/lib/Kconfig.kasan @@ -49,7 +49,7 @@ menuconfig KASAN (HAVE_ARCH_KASAN_SW_TAGS && CC_HAS_KASAN_SW_TAGS)) && \ CC_HAS_WORKING_NOSANITIZE_ADDRESS) || \ HAVE_ARCH_KASAN_HW_TAGS - depends on SYSFS && !SLUB_TINY + depends on SYSFS select STACKDEPOT_ALWAYS_INIT help Enables KASAN (Kernel Address Sanitizer) - a dynamic memory safety diff --git a/mm/Kconfig b/mm/Kconfig index 604c58199acb..a1b1ff7db59f 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -167,16 +167,18 @@ config SLUB =20 config KVFREE_RCU_BATCHED def_bool y - depends on !SLUB_TINY && !TINY_RCU + depends on !TINY_RCU depends on !RCU_STRICT_GRACE_PERIOD =20 config SLUB_TINY - bool "Configure for minimal memory footprint" + bool "Enable slab_tiny by default" depends on EXPERT && !COMPILE_TEST - select SLAB_MERGE_DEFAULT help + Deprecated option that enables the slab_tiny boot parameter by + default, and can be overridden by booting with slab_tiny=3D0. + Configures the slab allocator in a way to achieve minimal memory - footprint, sacrificing scalability, debugging and other features. + footprint, sacrificing scalability. This is intended only for the smallest system that had used the SLOB allocator and is not recommended for systems with more than 16MB RAM. @@ -199,7 +201,6 @@ config SLAB_MERGE_DEFAULT =20 config SLAB_FREELIST_RANDOM bool "Randomize slab freelist" - depends on !SLUB_TINY help Randomizes the freelist order used on creating new pages. This security feature reduces the predictability of the kernel slab @@ -207,7 +208,6 @@ config SLAB_FREELIST_RANDOM =20 config SLAB_FREELIST_HARDENED bool "Harden slab freelist metadata" - depends on !SLUB_TINY help Many kernel heap attacks try to target slab cache metadata and other infrastructure. This options makes minor performance @@ -216,7 +216,6 @@ config SLAB_FREELIST_HARDENED =20 config SLAB_BUCKETS bool "Support allocation from separate kmalloc buckets" - depends on !SLUB_TINY default SLAB_FREELIST_HARDENED help Kernel heap attacks frequently depend on being able to create @@ -234,7 +233,7 @@ config SLAB_BUCKETS config SLUB_STATS default n bool "Enable performance statistics" - depends on SYSFS && !SLUB_TINY + depends on SYSFS help The statistics are useful to debug slab allocation behavior in order find ways to optimize the allocator. This should never be @@ -245,7 +244,6 @@ config SLUB_STATS Try running: slabinfo -DA =20 config KMALLOC_PARTITION_CACHES - depends on !SLUB_TINY bool "Partitioned slab caches for normal kmalloc" default RANDOM_KMALLOC_CACHES help diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug index 15dca19dd07d..7fa01e48c9f0 100644 --- a/mm/Kconfig.debug +++ b/mm/Kconfig.debug @@ -48,7 +48,7 @@ config DEBUG_PAGEALLOC_ENABLE_DEFAULT config SLUB_DEBUG default y bool "Enable SLUB debugging support" if EXPERT - depends on SYSFS && !SLUB_TINY + depends on SYSFS select STACKDEPOT if STACKTRACE_SUPPORT help SLUB has extensive debug support features. Disabling these can --=20 2.55.0