From patchwork Thu Sep 5 07:56:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13791896 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 C2D5ECD4F5B for ; Thu, 5 Sep 2024 07:58:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F2DF6B0126; Thu, 5 Sep 2024 03:58:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A44D6B0127; Thu, 5 Sep 2024 03:58:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31E546B02BE; Thu, 5 Sep 2024 03:58:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 132516B0126 for ; Thu, 5 Sep 2024 03:58:10 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C7AFD40A4B for ; Thu, 5 Sep 2024 07:58:09 +0000 (UTC) X-FDA: 82529931498.08.623E98E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id F2CB2140005 for ; Thu, 5 Sep 2024 07:58:07 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UqxXrGSk; spf=pass (imf09.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725522991; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=q+WhBmSfBnW7XNOC0hG1IUMxGBPMKlAyI6vX+m1inqQ=; b=K/rZdU4spTyG4wtQboVifwEM3GfJYBzkhdDlF3NS/On6Toh67f1KFJPFBao0Vy/WpAfWRe 6TLbN6Xbieh3yxn4iaG4WK+gLrDCeUUjhXfAHFY66I2cRUfq06TjinfvTPIQbrK6DrTZAT 20OR7Hq1NGbACPyMoYbWG/NoLiDsD0c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725522991; a=rsa-sha256; cv=none; b=YpohcdWEM0xNFjnUcWFhD4XtwM8BDpzc/PzuH6idh7fHFfpWp2NdwyGoMz6F0D/3QTKprr 10jHowtoqN7Qp56ljGMMsbIgOBZyOPfn7iXCZT1G478umEdmu1snGz2CZDc9QQUIJBiloT BfYm1B//KN0c9ec+avbCYyFwlKJn1uw= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UqxXrGSk; spf=pass (imf09.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B8BA75C0FFA; Thu, 5 Sep 2024 07:58:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F903C4CEC9; Thu, 5 Sep 2024 07:58:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725523086; bh=rwJKoUBiD4opsF3q3lc+9pnVXWY01qThhoh7PngENwk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UqxXrGSksmpwRA6ISWIfcsy2RBc0SFe/JRNtZg49zhcODYuHDz3xFWj156OUJxLZ+ wlgA48rZ4aVjDeDgAisVGRtKKDZSAUgVWYuH02G8IAvR1flVT5sBrD/kRxow7t9U/b avyDBgagBqJmDSz3qCSe51VQ7h6c2PS6AnttGq5P2P8rnS3PPs8BJMOKtM7B0O91yS TrSImZBnPOaVASgyaAjqy93Uugn9w9qq7b1L9P0Er6SKg16c3pVSoYGQMouoQRQjrO 0FMi80Rd1VmLqkkLYKgzSdFQJeQW52mEZPHMSWtDuXWaiDK9hDfmx/JgEGNqxTI1tB U71j7fw3uPvdg== From: Christian Brauner Date: Thu, 05 Sep 2024 09:56:59 +0200 Subject: [PATCH v4 16/17] slab: make __kmem_cache_create() static inline MIME-Version: 1.0 Message-Id: <20240905-work-kmem_cache_args-v4-16-ed45d5380679@kernel.org> References: <20240905-work-kmem_cache_args-v4-0-ed45d5380679@kernel.org> In-Reply-To: <20240905-work-kmem_cache_args-v4-0-ed45d5380679@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: Kees Cook , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2885; i=brauner@kernel.org; h=from:subject:message-id; bh=rwJKoUBiD4opsF3q3lc+9pnVXWY01qThhoh7PngENwk=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdTPEuPu2j8kRPI0DSfXdC71rLqwZ7b+4XeG9n8f8WI 9OWKwblHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABMRyWf4K+S264SiRNnN4pCy otf59c/vPTdSWrb90XZ2I713D2RXZjIyzJ4mt6dx8kq790bb0i95+X2PfXjqj82S4I29cxZ9uaN 6mhsA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: F2CB2140005 X-Stat-Signature: 7tor5cs5bxq7fjb61aqzudq6qjc7e8bw X-HE-Tag: 1725523087-81856 X-HE-Meta: U2FsdGVkX18ofUNh4YG3qh0Hj6nXgL5/J0irLECXF9nXUNURxrY2CapAUuiZ+ZHu9lCpMw6xajcVk1sbvIPKmKed+1pcoOiHN4BRh8lsQJkg/vvztOCkqT3ZIuyFFOm5vHnbsCPMN9yJS4LU5zNazqkNB3k0eNWdJ0LIlyxIhaSUx8pfJJjut4bb7B4Hx8jzwqeaOzooXsH+Xus0CnUvKwUu3YLDzTkFKK5r0v6+uTw2kGkCXc5T/NGzfjtkgnLY/WD2jighacTdPF/qT1lBi/ikBS8lRzbrMLucCmGlFUdfzYP/aQ3RAqNYyQrJlqB59OxsjrnNPmigAce/jAJ6r1E8oXekdUVF7VNBMoH78SFPdTOeknTXGs72v9j8V/Yfkj7WWlaqlWj+ffE6iSoXH/ObOzuqDuJMItuI9QbCiOuNInZkWRnLaubrG1jMwy15gq0E7v/FU0A+dnCawx1i82TgeTNS0FH/98QAp77fkZeF5m6hAIJqU+UK8ABM+OsVx/naUeAjjVpWeuVk53mcmJUl9dHebRPEKIuu9arScwy++yjeZ6n98W8rAh2kNyUIbq1Lt8pAumWG+3zKZCovNa3nenkTnQtPrEoLjUnZorbJ8nwDaW11OIOcPEcC8yMMp+BwmjugBUb4jc+Ezb7kUdmkMH01Nep5ydNStASzefWnEaRllVzLGEkmR82UxHG5HUj5l5DnIYvg7/2elP3aEHnXHg1J36lWuGxTsXrBOYB3nKKiRbcfN5V0ucolv6CufIFS/oLXdDpWbLWWSloK7T3l3hX4aLN9Fo/r+iOWaslIfRRKrmJdVxHNMff3jJ3lKMtOTYdxXq76+C+KsXG3M2WRqt+gCYuAOrwvHiGnLJgqRF2fHC0D/fd3m1s1Rm0cGWLqKcnc6hE5XJw0eE98smSnIxwRuUZn1NdYAYUV2DZROXJlScyxcsfmrYTbeLl9q1QXq2hCkOkDy7PT6C3 5wsbp+dX /d3e1BvuIKdBK/RygJ/Dqpne3gMxFXv50fyH9GSdH8DP4mPzH20YUmKBQJUrVdCv4aTWSjfK7mx7s3uUvtk+mYg6GQNX2reYOy56OCJZcwGuYqMLUzJI92XsRGJV6nS/74kWCAUPwJ9LlwYuu6Qhny7ewMhmtdEUtJqLxE8MUF0/LeszQoC47zbGRN1EkmulJTb3h1S6Dl41XmxC/NgetaAYl39PjcbuuzPzUYhN4Lz4EFTVaRLGfjYSqGiezF83/yViEWqkeEJPx83uQVd1SK22c3BF8YrEpvhIs0y7+4EWd0Zj0Ew4GWnt58KaYEh4XzylK6If857wJFE5y3xsuiVwdTzGmfcpCO2wTz9BiCYhjE9QRL4mN6UUsMA== 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: Make __kmem_cache_create() a static inline function. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Roman Gushchin --- include/linux/slab.h | 13 ++++++++++--- mm/slab_common.c | 38 -------------------------------------- 2 files changed, 10 insertions(+), 41 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index d744397aa46f..597f6913cc0f 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -261,10 +261,17 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, unsigned int object_size, struct kmem_cache_args *args, slab_flags_t flags); +static inline struct kmem_cache * +__kmem_cache_create(const char *name, unsigned int size, unsigned int align, + slab_flags_t flags, void (*ctor)(void *)) +{ + struct kmem_cache_args kmem_args = { + .align = align, + .ctor = ctor, + }; -struct kmem_cache *__kmem_cache_create(const char *name, unsigned int size, - unsigned int align, slab_flags_t flags, - void (*ctor)(void *)); + return __kmem_cache_create_args(name, size, &kmem_args, flags); +} /** * kmem_cache_create_usercopy - Create a cache with a region suitable diff --git a/mm/slab_common.c b/mm/slab_common.c index 3477a3918afd..30000dcf0736 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -337,44 +337,6 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, } EXPORT_SYMBOL(__kmem_cache_create_args); -/** - * __kmem_cache_create - Create a cache. - * @name: A string which is used in /proc/slabinfo to identify this cache. - * @size: The size of objects to be created in this cache. - * @align: The required alignment for the objects. - * @flags: SLAB flags - * @ctor: A constructor for the objects. - * - * Cannot be called within a interrupt, but can be interrupted. - * The @ctor is run when new pages are allocated by the cache. - * - * The flags are - * - * %SLAB_POISON - Poison the slab with a known test pattern (a5a5a5a5) - * to catch references to uninitialised memory. - * - * %SLAB_RED_ZONE - Insert `Red` zones around the allocated memory to check - * for buffer overruns. - * - * %SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware - * cacheline. This can be beneficial if you're counting cycles as closely - * as davem. - * - * Return: a pointer to the cache on success, NULL on failure. - */ -struct kmem_cache *__kmem_cache_create(const char *name, unsigned int size, - unsigned int align, slab_flags_t flags, - void (*ctor)(void *)) -{ - struct kmem_cache_args kmem_args = { - .align = align, - .ctor = ctor, - }; - - return __kmem_cache_create_args(name, size, &kmem_args, flags); -} -EXPORT_SYMBOL(__kmem_cache_create); - static struct kmem_cache *kmem_buckets_cache __ro_after_init; /**