From patchwork Fri Dec 1 03:15:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiongwei Song X-Patchwork-Id: 13475300 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 067BDC4167B for ; Fri, 1 Dec 2023 03:16:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97DAA8D0067; Thu, 30 Nov 2023 22:16:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 92EAF8D0001; Thu, 30 Nov 2023 22:16:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CF098D0067; Thu, 30 Nov 2023 22:16:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 68B258D0001 for ; Thu, 30 Nov 2023 22:16:06 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 44B061C01BC for ; Fri, 1 Dec 2023 03:16:06 +0000 (UTC) X-FDA: 81516785532.14.FAF4BEE Received: from pv50p00im-ztdg10012101.me.com (pv50p00im-ztdg10012101.me.com [17.58.6.49]) by imf09.hostedemail.com (Postfix) with ESMTP id 517DA140005 for ; Fri, 1 Dec 2023 03:16:04 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=me.com header.s=1a1hai header.b=Jgc3w9y7; dmarc=pass (policy=quarantine) header.from=me.com; spf=pass (imf09.hostedemail.com: domain of sxwjean@me.com designates 17.58.6.49 as permitted sender) smtp.mailfrom=sxwjean@me.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701400564; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=upp3f1b2uYPe5zjNm3g55BP6GkibG6wweQbsbezgvNQ=; b=2NKnZHnDY0lnF2cI/Wxq6z62tsQBKqO18Pap9ZeTiDJOnq43OGyx61TzshQwS6WyEtz5Yq t9yLLHFLgh8TvC4oicyayhdMAM6M1i4UDsNxX2pqckVdU2PIf95QaTqA5QNxmBI+9wYu81 7B3f1GeBshaDLR3Qgp8exhqVWy78vcI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=me.com header.s=1a1hai header.b=Jgc3w9y7; dmarc=pass (policy=quarantine) header.from=me.com; spf=pass (imf09.hostedemail.com: domain of sxwjean@me.com designates 17.58.6.49 as permitted sender) smtp.mailfrom=sxwjean@me.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701400564; a=rsa-sha256; cv=none; b=DuDF8mDaUh4Dc4M4G1I/6Rlm/PguzDf7lj3GQo04s9qWxR+5QjLHnIhVHGF/DY8eKl57mZ FKsote3iO5Zwh11lk35u35iodWUtr5vF5Jvbjzu/p2AULC1Ux+EVjHfRiqqJiY4uYGYKlU uBGkTX6QiplJOxjXRZY4t6Sauxn9EiU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1701400563; bh=upp3f1b2uYPe5zjNm3g55BP6GkibG6wweQbsbezgvNQ=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=Jgc3w9y7dmv0nMqzq0D/vFa6G0vU7e2faTX58VdD7X2QmVwWAzX50N5+9MMsVv4LB KtNjeYCg1eTpjs98PXaxJMqd/apUBPgoiE/3xNZZ9t3chwyJrQzaLVELvG+lrnXt5k PRmGu1h8UAzwIqPueCTmAsVplLBwKrNwPx6Nu17plLihnFNXD5lB5nyCozJLa9c1bP bOlxFwuqAmggjjFVjQv1x/i6ndCPnWmI8dnx/DMUJPB/VXaFiX27p51VB9clHGT5Lh 7pkWf5LyYSrfQo/I5U0wnnd+wvoCt3xf60YpTtANGo0dICKBgje2usK0gYCVyyXWBT DB7hHOyKzMLQw== Received: from xiongwei.. (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10012101.me.com (Postfix) with ESMTPSA id 4B251740137; Fri, 1 Dec 2023 03:15:56 +0000 (UTC) From: sxwjean@me.com To: vbabka@suse.cz, 42.hyeyoo@gmail.com, cl@linux.com, linux-mm@kvack.org Cc: penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, roman.gushchin@linux.dev, corbet@lwn.net, keescook@chromium.org, arnd@arndb.de, akpm@linux-foundation.org, gregkh@linuxfoundation.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Xiongwei Song Subject: [RFC PATCH 2/3] mm/slub: unify all sl[au]b parameters with "slab_$param" Date: Fri, 1 Dec 2023 11:15:04 +0800 Message-Id: <20231201031505.286117-3-sxwjean@me.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231201031505.286117-1-sxwjean@me.com> References: <20231201031505.286117-1-sxwjean@me.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: buFJpuDYznbo62q3rfaCAvT4_c2kIyhB X-Proofpoint-GUID: buFJpuDYznbo62q3rfaCAvT4_c2kIyhB X-Proofpoint-Virus-Version: =?utf-8?q?vendor=3Dfsecure_engine=3D1=2E1=2E170-?= =?utf-8?q?22c6f66c430a71ce266a39bfe25bc2903e8d5c8f=3A6=2E0=2E517=2C18=2E0?= =?utf-8?q?=2E572=2C17=2E11=2E64=2E514=2E0000000_definitions=3D2022-06-21=5F?= =?utf-8?q?01=3A2022-06-21=5F01=2C2020-02-14=5F11=2C2022-02-23=5F01_signatur?= =?utf-8?q?es=3D0?= X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 clxscore=1015 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2312010018 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 517DA140005 X-Stat-Signature: 6j9deneb46oahaysdizfbqwouh66k4ib X-Rspam-User: X-HE-Tag: 1701400564-199148 X-HE-Meta: U2FsdGVkX1+FkWYZpGCM3WvEu1ecgeX1Civ5FgbW1boNGrOJtvNU6I5vcVCA0PlZTQELlxKsjfT2H2bykj9DYXG8mWrCOFJFfHJlet3C9Szm7MJbPHsPrZ8KsD3Rkgg7HO6WSucvcBzkG3iHeI1NbVu0HHowyFWCF6qahY8rt8r+l51E/ElsKaFqkq4+BrIQUZztmui86VB7P6fovZaPMsIA+vok946nsPm7TA1N2/k6sHinIkyCRnRC6y+PRb4I0us79MEd1rX/AhpcJwBiO7HTVWEiDjCePRUaDxl9juFkBcvcC1m6wdLW0CoIsB/T9LK8RFT4vNGeDtdLWk8HDtKE+Wq0XOummvdWYyYcDu2y9SHD40onWEMFlet1clTrD3DEJQ0uvd/+UJj77g4WXNIlje5+/zR0ROwI2Tb91ArRYHQB5v86teoL11wmyn031x6OBHEvoaVhHJZV1i7wMQ7bss2vC0pt4RQi4bWhwqqwdhs731Ed8K3n5Ea7kTYYn++SfTS1eDqQi+TI2hn8JeTqMRU/vtRxXb0uGsb5WoReIjdcff3HjcXXL8Dtx9xy6iNXCu1Cz/78VSaJEpeDCV48WVv104OGlg1185MRVaRR2yGL9xqQViJ8giHZLcb7rkQqPDbiLlGNdJBmf+QBYPZe7Dfg26OpHqCOoU39DdHcFE2FHtSlIwCEe4qxAIK+yDzV24V8BHfCA0N64DQ3h9anew+rY6dqjeQzp+iiqtwxY8hj2knEox9m9RY58oJ7wZ7ngWskF8mdPtI7YcWP5QUHNybi87qazrt4CbVqVdAQNVNapM1RYgpcMd4aY9L6eVb0pNDQQZI88W0zOQszThoWVwlYrzVULY3rzW5jApK5PBG9cldR93bKf31JN5ZO9G9M0a0CVzBjW4EtpCfyDalqmbILJqqkfzdD39kw4C3JTz+jEd6N9M9vIvGpInq77/SEBogjMTFVlnYqFPP K82R5iJ9 x6BDnHOA42hTETJ9Yh0uHUacwKhZ1glMrU+mp3vR222FMxtabGQsKIGUzhpUeWqeGjkL75cj2OkY782kEOBt2rrRcGqaX3tHKtzRlSgAdtK42JD5tQzQmRehGrVJN7wm9betYWEz+2gNZatGkLdGbmRqyuZHyH51QKfp/vdVSAWN58v8/yC2dGlegVLJBzoZA+KYu/7U8x0wTRjmVeYgHwD02RGNWiYWab5dwpdGDnJuIIYc9GHhifZRehy6Ef6zRm31LDDaKpGWEvsvyYCF2cbDn/6Zu7QgzBu3Yh9aXI0XNiABSB2YhHmmhl3OObXv3aSRU9SXCJ/zOj1Q/lWK36k8bVV2dv9XYUgnrcqP4lptQT7GV5nnN7rz6LIhiIzE4C6RWHMnYu3r0XybqmEQPRNUfnl3PKaXQESkKWhqba95/3MKjHjNqzQ2XczF+oyiLr7DpKr1zPngCLt5EOoR29sPg1Y6e8Pbaglj4QLVoUcqX6r4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Xiongwei Song Since the SLAB allocator has been removed, so we need to clean up the sl[au]b_$params. However, the "slab/SLAB" terms should be keep for long-term rather than "slub/SLUB". Hence, we should use "slab_$param" as the primary prefix, which is pointed out by Vlastimil Babka. For more information please see [1]. This patch is changing the following slab parameters - slub_max_order - slub_min_order - slub_min_objects - slub_debug to - slab_max_order - slab_min_order - slab_min_objects - slab_debug as the primary slab parameters in Documentation/admin-guide/kernel-parameters.txt and source, and rename all setup functions of them too. Meanwhile, "slub_$params" can also be passed by command line, which is to keep backward compatibility. Also mark all "slub_$params" as legacy. The function static int __init setup_slub_debug(char *str); , which is to setup debug flags inside a slab during kernel init, is changed to setup_slab_debug_flags(), which is to prevent the name conflict. Because there is another function void setup_slab_debug(struct kmem_cache *s, struct slab *slab, void *addr); , which is to poison slab space, would have name confilct with the prior one. For parameter "slub_debug", beside replacing it with "slab_debug", there are several global variables, local variables and functions which are related with the parameter, let's rename them all. Remove the separate descriptons for slub_[no]merge, append legacy tip for them at the end of descriptions of slab_[no]merge. I didn't change the parameters in Documentation/mm/slub.rst because the file name is still "slub.rst", and slub_$params still can be used in kernel command line to keep backward compatibility. [1] https://lore.kernel.org/linux-mm/7512b350-4317-21a0-fab3-4101bc4d8f7a@suse.cz/ Signed-off-by: Xiongwei Song --- .../admin-guide/kernel-parameters.txt | 44 +++--- drivers/misc/lkdtm/heap.c | 2 +- mm/Kconfig.debug | 6 +- mm/slab.h | 16 +- mm/slab_common.c | 8 +- mm/slub.c | 142 +++++++++--------- 6 files changed, 109 insertions(+), 109 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 9f94baeb2f82..d01c12e2a247 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5869,6 +5869,8 @@ slab_merge [MM] Enable merging of slabs with similar size when the kernel is built without CONFIG_SLAB_MERGE_DEFAULT. + (slub_merge is accepted too, but it's supported for + legacy) slab_nomerge [MM] Disable merging of slabs with similar size. May be @@ -5882,47 +5884,41 @@ unchanged). Debug options disable merging on their own. For more information see Documentation/mm/slub.rst. + (slub_nomerge is accepted too, but it's supported for + legacy) - slab_max_order= [MM, SLAB] - Determines the maximum allowed order for slabs. - A high setting may cause OOMs due to memory - fragmentation. Defaults to 1 for systems with - more than 32MB of RAM, 0 otherwise. - - slub_debug[=options[,slabs][;[options[,slabs]]...] [MM, SLUB] - Enabling slub_debug allows one to determine the + slab_debug[=options[,slabs][;[options[,slabs]]...] [MM] + Enabling slab_debug allows one to determine the culprit if slab objects become corrupted. Enabling - slub_debug can create guard zones around objects and + slab_debug can create guard zones around objects and may poison objects when not in use. Also tracks the last alloc / free. For more information see - Documentation/mm/slub.rst. + Documentation/mm/slub.rst. (slub_debug is accepted + too, but it's supported for legacy) - slub_max_order= [MM, SLUB] + slab_max_order= [MM] Determines the maximum allowed order for slabs. A high setting may cause OOMs due to memory fragmentation. For more information see - Documentation/mm/slub.rst. + Documentation/mm/slub.rst. (slub_max_order is + accepted too, but it's supported for legacy) - slub_min_objects= [MM, SLUB] + slab_min_objects= [MM] The minimum number of objects per slab. SLUB will - increase the slab order up to slub_max_order to + increase the slab order up to slab_max_order to generate a sufficiently large slab able to contain the number of objects indicated. The higher the number of objects the smaller the overhead of tracking slabs and the less frequently locks need to be acquired. For more information see Documentation/mm/slub.rst. + (slub_min_objects is accepted too, but it's supported + for legacy) - slub_min_order= [MM, SLUB] + slab_min_order= [MM] Determines the minimum page order for slabs. Must be - lower than slub_max_order. - For more information see Documentation/mm/slub.rst. - - slub_merge [MM, SLUB] - Same with slab_merge. - - slub_nomerge [MM, SLUB] - Same with slab_nomerge. This is supported for legacy. - See slab_nomerge for more information. + lower than slab_max_order. For more information see + Documentation/mm/slub.rst. (slub_min_order is accepted + too, but it's supported for legacy) smart2= [HW] Format: [,[,...,]] diff --git a/drivers/misc/lkdtm/heap.c b/drivers/misc/lkdtm/heap.c index 0ce4cbf6abda..076ca9b225de 100644 --- a/drivers/misc/lkdtm/heap.c +++ b/drivers/misc/lkdtm/heap.c @@ -47,7 +47,7 @@ static void lkdtm_VMALLOC_LINEAR_OVERFLOW(void) * correctly. * * This should get caught by either memory tagging, KASan, or by using - * CONFIG_SLUB_DEBUG=y and slub_debug=ZF (or CONFIG_SLUB_DEBUG_ON=y). + * CONFIG_SLUB_DEBUG=y and slab_debug=ZF (or CONFIG_SLUB_DEBUG_ON=y). */ static void lkdtm_SLAB_LINEAR_OVERFLOW(void) { diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug index 321ab379994f..afc72fde0f03 100644 --- a/mm/Kconfig.debug +++ b/mm/Kconfig.debug @@ -64,11 +64,11 @@ config SLUB_DEBUG_ON help Boot with debugging on by default. SLUB boots by default with the runtime debug capabilities switched off. Enabling this is - equivalent to specifying the "slub_debug" parameter on boot. + equivalent to specifying the "slab_debug" parameter on boot. There is no support for more fine grained debug control like - possible with slub_debug=xxx. SLUB debugging may be switched + possible with slab_debug=xxx. SLUB debugging may be switched off in a kernel built with CONFIG_SLUB_DEBUG_ON by specifying - "slub_debug=-". + "slab_debug=-". config PAGE_OWNER bool "Track page owner" diff --git a/mm/slab.h b/mm/slab.h index 54deeb0428c6..c78b3d24be2c 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -507,36 +507,36 @@ ssize_t slabinfo_write(struct file *file, const char __user *buffer, #ifdef CONFIG_SLUB_DEBUG #ifdef CONFIG_SLUB_DEBUG_ON -DECLARE_STATIC_KEY_TRUE(slub_debug_enabled); +DECLARE_STATIC_KEY_TRUE(slab_debug_enabled); #else -DECLARE_STATIC_KEY_FALSE(slub_debug_enabled); +DECLARE_STATIC_KEY_FALSE(slab_debug_enabled); #endif extern void print_tracking(struct kmem_cache *s, void *object); long validate_slab_cache(struct kmem_cache *s); -static inline bool __slub_debug_enabled(void) +static inline bool __slab_debug_enabled(void) { - return static_branch_unlikely(&slub_debug_enabled); + return static_branch_unlikely(&slab_debug_enabled); } #else static inline void print_tracking(struct kmem_cache *s, void *object) { } -static inline bool __slub_debug_enabled(void) +static inline bool __slab_debug_enabled(void) { return false; } #endif /* - * Returns true if any of the specified slub_debug flags is enabled for the - * cache. Use only for flags parsed by setup_slub_debug() as it also enables + * Returns true if any of the specified slab_debug flags is enabled for the + * cache. Use only for flags parsed by setup_slab_debug() as it also enables * the static key. */ static inline bool kmem_cache_debug_flags(struct kmem_cache *s, slab_flags_t flags) { if (IS_ENABLED(CONFIG_SLUB_DEBUG)) VM_WARN_ON_ONCE(!(flags & SLAB_DEBUG_FLAGS)); - if (__slub_debug_enabled()) + if (__slab_debug_enabled()) return s->flags & flags; return false; } diff --git a/mm/slab_common.c b/mm/slab_common.c index 238293b1dbe1..d7360a50633c 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -282,14 +282,14 @@ kmem_cache_create_usercopy(const char *name, #ifdef CONFIG_SLUB_DEBUG /* - * If no slub_debug was enabled globally, the static key is not yet - * enabled by setup_slub_debug(). Enable it if the cache is being + * If no slab_debug was enabled globally, the static key is not yet + * enabled by setup_slab_debug(). Enable it if the cache is being * created with any of the debugging flags passed explicitly. * It's also possible that this is the first cache created with * SLAB_STORE_USER and we should init stack_depot for it. */ if (flags & SLAB_DEBUG_FLAGS) - static_branch_enable(&slub_debug_enabled); + static_branch_enable(&slab_debug_enabled); if (flags & SLAB_STORE_USER) stack_depot_init(); #endif @@ -766,7 +766,7 @@ EXPORT_SYMBOL(kmalloc_size_roundup); } /* - * kmalloc_info[] is to make slub_debug=,kmalloc-xx option work at boot time. + * kmalloc_info[] is to make slab_debug=,kmalloc-xx option work at boot time. * kmalloc_index() supports up to 2^21=2MB, so the final entry of the table is * kmalloc-2M. */ diff --git a/mm/slub.c b/mm/slub.c index 3f8b95757106..f67108ed2653 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -197,9 +197,9 @@ do { \ #ifdef CONFIG_SLUB_DEBUG #ifdef CONFIG_SLUB_DEBUG_ON -DEFINE_STATIC_KEY_TRUE(slub_debug_enabled); +DEFINE_STATIC_KEY_TRUE(slab_debug_enabled); #else -DEFINE_STATIC_KEY_FALSE(slub_debug_enabled); +DEFINE_STATIC_KEY_FALSE(slab_debug_enabled); #endif #endif /* CONFIG_SLUB_DEBUG */ @@ -280,7 +280,7 @@ static inline bool kmem_cache_has_cpu_partial(struct kmem_cache *s) /* * Debugging flags that require metadata to be stored in the slab. These get - * disabled when slub_debug=O is used and a cache's min order increases with + * disabled when slab_debug=O is used and a cache's min order increases with * metadata. */ #define DEBUG_METADATA_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER) @@ -765,12 +765,12 @@ static inline void *restore_red_left(struct kmem_cache *s, void *p) * Debug settings: */ #if defined(CONFIG_SLUB_DEBUG_ON) -static slab_flags_t slub_debug = DEBUG_DEFAULT_FLAGS; +static slab_flags_t slab_debug = DEBUG_DEFAULT_FLAGS; #else -static slab_flags_t slub_debug; +static slab_flags_t slab_debug; #endif -static char *slub_debug_string; +static char *slab_debug_string; static int disable_higher_order_debug; /* @@ -1582,7 +1582,7 @@ static inline int free_consistency_checks(struct kmem_cache *s, } /* - * Parse a block of slub_debug options. Blocks are delimited by ';' + * Parse a block of slab_debug options. Blocks are delimited by ';' * * @str: start of block * @flags: returns parsed flags, or DEBUG_DEFAULT_FLAGS if none specified @@ -1592,7 +1592,7 @@ static inline int free_consistency_checks(struct kmem_cache *s, * returns the start of next block if there's any, or NULL */ static char * -parse_slub_debug_flags(char *str, slab_flags_t *flags, char **slabs, bool init) +parse_slab_debug_flags(char *str, slab_flags_t *flags, char **slabs, bool init) { bool higher_order_disable = false; @@ -1643,7 +1643,7 @@ parse_slub_debug_flags(char *str, slab_flags_t *flags, char **slabs, bool init) break; default: if (init) - pr_err("slub_debug option '%c' unknown. skipped\n", *str); + pr_err("slab_debug option '%c' unknown. skipped\n", *str); } } check_slabs: @@ -1669,13 +1669,13 @@ parse_slub_debug_flags(char *str, slab_flags_t *flags, char **slabs, bool init) return NULL; } -static int __init setup_slub_debug(char *str) +static int __init setup_slab_debug_flags(char *str) { slab_flags_t flags; slab_flags_t global_flags; char *saved_str; char *slab_list; - bool global_slub_debug_changed = false; + bool global_slab_debug_changed = false; bool slab_list_specified = false; global_flags = DEBUG_DEFAULT_FLAGS; @@ -1687,11 +1687,11 @@ static int __init setup_slub_debug(char *str) saved_str = str; while (str) { - str = parse_slub_debug_flags(str, &flags, &slab_list, true); + str = parse_slab_debug_flags(str, &flags, &slab_list, true); if (!slab_list) { global_flags = flags; - global_slub_debug_changed = true; + global_slab_debug_changed = true; } else { slab_list_specified = true; if (flags & SLAB_STORE_USER) @@ -1702,31 +1702,32 @@ static int __init setup_slub_debug(char *str) /* * For backwards compatibility, a single list of flags with list of * slabs means debugging is only changed for those slabs, so the global - * slub_debug should be unchanged (0 or DEBUG_DEFAULT_FLAGS, depending + * slab_debug should be unchanged (0 or DEBUG_DEFAULT_FLAGS, depending * on CONFIG_SLUB_DEBUG_ON). We can extended that to multiple lists as * long as there is no option specifying flags without a slab list. */ if (slab_list_specified) { - if (!global_slub_debug_changed) - global_flags = slub_debug; - slub_debug_string = saved_str; + if (!global_slab_debug_changed) + global_flags = slab_debug; + slab_debug_string = saved_str; } out: - slub_debug = global_flags; - if (slub_debug & SLAB_STORE_USER) + slab_debug = global_flags; + if (slab_debug & SLAB_STORE_USER) stack_depot_request_early_init(); - if (slub_debug != 0 || slub_debug_string) - static_branch_enable(&slub_debug_enabled); + if (slab_debug != 0 || slab_debug_string) + static_branch_enable(&slab_debug_enabled); else - static_branch_disable(&slub_debug_enabled); + static_branch_disable(&slab_debug_enabled); if ((static_branch_unlikely(&init_on_alloc) || static_branch_unlikely(&init_on_free)) && - (slub_debug & SLAB_POISON)) + (slab_debug & SLAB_POISON)) pr_info("mem auto-init: SLAB_POISON will take precedence over init_on_alloc/init_on_free\n"); return 1; } -__setup("slub_debug", setup_slub_debug); +__setup("slab_debug", setup_slab_debug_flags); +__setup_param("slub_debug", slub_debug, setup_slab_debug_flags, 0); /* * kmem_cache_flags - apply debugging options to the cache @@ -1736,7 +1737,7 @@ __setup("slub_debug", setup_slub_debug); * * Debug option(s) are applied to @flags. In addition to the debug * option(s), if a slab name (or multiple) is specified i.e. - * slub_debug=,, ... + * slab_debug=,, ... * then only the select slabs will receive the debug option(s). */ slab_flags_t kmem_cache_flags(unsigned int object_size, @@ -1746,7 +1747,7 @@ slab_flags_t kmem_cache_flags(unsigned int object_size, size_t len; char *next_block; slab_flags_t block_flags; - slab_flags_t slub_debug_local = slub_debug; + slab_flags_t slab_debug_local = slab_debug; if (flags & SLAB_NO_USER_FLAGS) return flags; @@ -1757,13 +1758,13 @@ slab_flags_t kmem_cache_flags(unsigned int object_size, * but let the user enable it via the command line below. */ if (flags & SLAB_NOLEAKTRACE) - slub_debug_local &= ~SLAB_STORE_USER; + slab_debug_local &= ~SLAB_STORE_USER; len = strlen(name); - next_block = slub_debug_string; + next_block = slab_debug_string; /* Go through all blocks of debug options, see if any matches our slab's name */ while (next_block) { - next_block = parse_slub_debug_flags(next_block, &block_flags, &iter, false); + next_block = parse_slab_debug_flags(next_block, &block_flags, &iter, false); if (!iter) continue; /* Found a block that has a slab list, search it */ @@ -1792,12 +1793,12 @@ slab_flags_t kmem_cache_flags(unsigned int object_size, } } - return flags | slub_debug_local; + return flags | slab_debug_local; } #else /* !CONFIG_SLUB_DEBUG */ static inline void setup_object_debug(struct kmem_cache *s, void *object) {} -static inline -void setup_slab_debug(struct kmem_cache *s, struct slab *slab, void *addr) {} +static inline void setup_slab_debug(struct kmem_cache *s, + struct slab *slab, void *addr) {} static inline bool alloc_debug_processing(struct kmem_cache *s, struct slab *slab, void *object, int orig_size) { return true; } @@ -1821,7 +1822,7 @@ slab_flags_t kmem_cache_flags(unsigned int object_size, { return flags; } -#define slub_debug 0 +#define slab_debug 0 #define disable_higher_order_debug 0 @@ -3285,7 +3286,7 @@ slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid) oo_order(s->min)); if (oo_order(s->min) > get_order(s->object_size)) - pr_warn(" %s debugging increased min order, use slub_debug=O to disable.\n", + pr_warn(" %s debugging increased min order, use slab_debug=O to disable.\n", s->name); for_each_kmem_cache_node(s, node, n) { @@ -3778,14 +3779,14 @@ void slab_post_alloc_hook(struct kmem_cache *s, struct obj_cgroup *objcg, zero_size = orig_size; /* - * When slub_debug is enabled, avoid memory initialization integrated + * When slab_debug is enabled, avoid memory initialization integrated * into KASAN and instead zero out the memory via the memset below with * the proper size. Otherwise, KASAN might overwrite SLUB redzones and * cause false-positive reports. This does not lead to a performance - * penalty on production builds, as slub_debug is not intended to be + * penalty on production builds, as slab_debug is not intended to be * enabled there. */ - if (__slub_debug_enabled()) + if (__slab_debug_enabled()) kasan_init = false; /* @@ -4638,10 +4639,10 @@ EXPORT_SYMBOL(kmem_cache_alloc_bulk); * 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 = +static unsigned int slab_min_order; +static unsigned int slab_max_order = IS_ENABLED(CONFIG_SLUB_TINY) ? 1 : PAGE_ALLOC_COSTLY_ORDER; -static unsigned int slub_min_objects; +static unsigned int slab_min_objects; /* * Calculate the order of allocation given an slab object size. @@ -4658,8 +4659,8 @@ static unsigned int slub_min_objects; * activity on the partial lists which requires taking the list_lock. This is * less a concern for large slabs though which are rarely used. * - * slub_max_order specifies the order where we begin to stop considering the - * number of objects in a slab as critical. If we reach slub_max_order then + * slab_max_order specifies the order where we begin to stop considering the + * number of objects in a slab as critical. If we reach slab_max_order then * we try to keep the page order as low as possible. So we accept more waste * of space in favor of a small page order. * @@ -4695,7 +4696,7 @@ static inline int calculate_order(unsigned int size) unsigned int max_objects; unsigned int min_order; - min_objects = slub_min_objects; + min_objects = slab_min_objects; if (!min_objects) { /* * Some architectures will only update present cpus when @@ -4712,10 +4713,10 @@ static inline int calculate_order(unsigned int size) min_objects = 4 * (fls(nr_cpus) + 1); } /* min_objects can't be 0 because get_order(0) is undefined */ - max_objects = max(order_objects(slub_max_order, size), 1U); + max_objects = max(order_objects(slab_max_order, size), 1U); min_objects = min(min_objects, max_objects); - min_order = max_t(unsigned int, slub_min_order, + min_order = 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; @@ -4726,24 +4727,24 @@ static inline int calculate_order(unsigned int size) * and backing off gradually. * * We start with accepting at most 1/16 waste and try to find the - * smallest order from min_objects-derived/slub_min_order up to - * slub_max_order that will satisfy the constraint. Note that increasing + * smallest order from min_objects-derived/slab_min_order up to + * slab_max_order that will satisfy the constraint. Note that increasing * the order can only result in same or less fractional waste, not more. * * If that fails, we increase the acceptable fraction of waste and try * again. The last iteration with fraction of 1/2 would effectively * accept any waste and give us the order determined by min_objects, as - * long as at least single object fits within slub_max_order. + * long as at least single object fits within slab_max_order. */ for (unsigned int fraction = 16; fraction > 1; fraction /= 2) { - order = calc_slab_order(size, min_order, slub_max_order, + order = calc_slab_order(size, min_order, slab_max_order, fraction); - if (order <= slub_max_order) + if (order <= slab_max_order) return order; } /* - * Doh this slab cannot be placed using slub_max_order. + * Doh this slab cannot be placed using slab_max_order. */ order = get_order(size); if (order <= MAX_ORDER) @@ -5259,39 +5260,42 @@ void __kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct slab *slab) * Kmalloc subsystem *******************************************************************/ -static int __init setup_slub_min_order(char *str) +static int __init setup_slab_min_order(char *str) { - get_option(&str, (int *)&slub_min_order); + get_option(&str, (int *)&slab_min_order); - if (slub_min_order > slub_max_order) - slub_max_order = slub_min_order; + if (slab_min_order > slab_max_order) + slab_max_order = slab_min_order; return 1; } -__setup("slub_min_order=", setup_slub_min_order); +__setup("slab_min_order=", setup_slab_min_order); +__setup_param("slub_min_order=", slub_min_order, setup_slab_min_order, 0); -static int __init setup_slub_max_order(char *str) +static int __init setup_slab_max_order(char *str) { - get_option(&str, (int *)&slub_max_order); - slub_max_order = min_t(unsigned int, slub_max_order, MAX_ORDER); + get_option(&str, (int *)&slab_max_order); + slab_max_order = min_t(unsigned int, slab_max_order, MAX_ORDER); - if (slub_min_order > slub_max_order) - slub_min_order = slub_max_order; + if (slab_min_order > slab_max_order) + slab_min_order = slab_max_order; return 1; } -__setup("slub_max_order=", setup_slub_max_order); +__setup("slab_max_order=", setup_slab_max_order); +__setup_param("slub_max_order=", slub_max_order, setup_slab_max_order, 0); -static int __init setup_slub_min_objects(char *str) +static int __init setup_slab_min_objects(char *str) { - get_option(&str, (int *)&slub_min_objects); + get_option(&str, (int *)&slab_min_objects); return 1; } -__setup("slub_min_objects=", setup_slub_min_objects); +__setup("slab_min_objects=", setup_slab_min_objects); +__setup_param("slub_min_objects=", slub_min_objects, setup_slab_min_objects, 0); #ifdef CONFIG_HARDENED_USERCOPY /* @@ -5584,10 +5588,10 @@ void __init kmem_cache_init(void) int node; if (debug_guardpage_minorder()) - slub_max_order = 0; + slab_max_order = 0; /* Print slub debugging pointers without hashing */ - if (__slub_debug_enabled()) + if (__slab_debug_enabled()) no_hash_pointers_enable(NULL); kmem_cache_node = &boot_kmem_cache_node; @@ -5628,7 +5632,7 @@ void __init kmem_cache_init(void) pr_info("SLUB: HWalign=%d, Order=%u-%u, MinObjects=%u, CPUs=%u, Nodes=%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); } @@ -6702,7 +6706,7 @@ static int sysfs_slab_add(struct kmem_cache *s) int unmergeable = slab_unmergeable(s); if (!unmergeable && disable_higher_order_debug && - (slub_debug & DEBUG_METADATA_FLAGS)) + (slab_debug & DEBUG_METADATA_FLAGS)) unmergeable = 1; if (unmergeable) {