From patchwork Wed Sep 4 09:44:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790245 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 58325CD3431 for ; Wed, 4 Sep 2024 09:45:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF8AD6B00A9; Wed, 4 Sep 2024 05:45:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AA9296B00E4; Wed, 4 Sep 2024 05:45:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96F716B011E; Wed, 4 Sep 2024 05:45:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 79BE96B00A9 for ; Wed, 4 Sep 2024 05:45:09 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 218B7120E01 for ; Wed, 4 Sep 2024 09:45:09 +0000 (UTC) X-FDA: 82526572338.02.8302348 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id 5456F80018 for ; Wed, 4 Sep 2024 09:45:07 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pVF3VDs0; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725443036; a=rsa-sha256; cv=none; b=xhM2DZjQhmptOdWN4v8TTJ7/kvNG7koP4DOfUzhQi4cZrUnAj9pMukO18FgWyhwFQD1pik iI95JRfNgQCeprBw48l7vooo+RAXrw2cRK48wMxzLDM3r1ZcSttlOMmAjDQ5lP3eOvYVQh mxdwZDeLP81yV9xTywMA25k9Kmc/EhA= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pVF3VDs0; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725443036; 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=qdgGJ6cwgEJVO9SKCUaFd/iTWI0ape2PK/7C9NtdbPA=; b=MIlsvzOhUUa+KUVxsedZQIhseV6t2NICrD2vMwb8INqGR+jvXD6YmgsLeYqIF0h+yfTEMZ fNBamfI1xMwhArC5eAU/2n3HushrM1LOG/Gw7JpUsiedU6pdgte21VJqVMANugRnRef7ED OLjYZDED9a0fyt+j19BEmf+9EqWNQA0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AFC8C5C497C; Wed, 4 Sep 2024 09:45:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCDA1C4CEC2; Wed, 4 Sep 2024 09:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725443105; bh=0TbYaIlAyW4MAXY6VAEmQDqD02yJBCeFBP+TG2hljGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pVF3VDs06NfHifXprvecTcWgLyuIjjOZODyuarPgxP4k+4vZj9Xvac302QhHxQeFf SMQSApucUVdM5guUbLcRTK+D6jcI0qdJYKZUalyVBJsy74gWc03qlsaiVmQo4xikpD nW/CL8mNiZIDP3px2IzsFjRlmY9j7nzh6mru0N6b+KWsQK/8QyuBAJDVYtNlqKflUq BE/FQ5IOUMrUUYEqrby/6c/0gqocPGDoQDpSP+IXhm6mVY9M9SCUb/YwGmLUvGaG8G eGoLpj2P045rIPlI+sErjowEbWQ5Ly/NNOE9Inacod2qPzKBy4GeJv4+SCLYhVLeiY mPpxMxhaLJysw== From: Christian Brauner To: Mike Rapoport Cc: Christian Brauner , Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 17/16] slab: make kmem_cache_create_usercopy() static inline Date: Wed, 4 Sep 2024 11:44:12 +0200 Message-ID: <20240904-schieben-hochdekoriert-5808b31c9f3c@brauner> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4667; i=brauner@kernel.org; h=from:subject:message-id; bh=0TbYaIlAyW4MAXY6VAEmQDqD02yJBCeFBP+TG2hljGY=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTd0BG+rO3986DXU820qgiOTJEnO9YVrd7wYtHurnA9R tmApL2rOkpZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACby7A4jQ7OAU+ayqjzZul8G QT//LpjBHWRtfqo5/4rC7ZWR83YE+DIybLuTcbRC6kxAqeDRsDk7rxd+XrexYlb/jxWVkq7nf3N nMAMA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Queue-Id: 5456F80018 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: udxs13wh7y4xxmnchq9zej3qeky9gr7q X-HE-Tag: 1725443107-879320 X-HE-Meta: U2FsdGVkX196nbdQXf7pYPz5qd9FnlIPuq2F00YwwJNjOycOQaVu44PXY2kfHL0i91UwMhFc7iNVaTKNpJ+qs0vwp7gKMLhF79bsgNWhbnM060lRCx9O6fi+MELEenB1vB2g5WJGuY8wqj4juiNHFZNwfstAqI4A6cFsGLgNFTPdo30XHSEtkVw25iyDVpT95W+EuFkbdfDDH0g2IZjdHMOJbTiId3kDz9FzXb1MtmppJlydECiySayRI3PshvG+7S5/vOnuewhGrv6o38ZD+VN6madzglJLSRPAB1aztxeovsBBAeY+uf6dDTkkbOGLpK/RyFAZiypg+AqGyxhN8X14DZWVQ8N/4KGsoy8cf5CEqsBqGK76WMZelZ40S/JFY7KIl50qtEWKiBn7K3npVcweAuPi3hWZNoyTP9D1CSaGruJBjX5e3/M1jQ1M2qkMPJ1xMfNmFfe7obUK6/65JOg2u9HMBdh6q0jgjyxjONSvetDg2/5OP38OmScGnhgVCsq5whX79UQfkOrofO11T0yIQJS2EAF66nYYgxYis7HQn/Yd8VfHZ6+bGfpPmqH+3sfwOe+0kc96bmR70q2chZxwcs+QgkMOFkQb58e9JdeVyQQaosoCjD+oJ9+V7EdKhVCMavQmXN/5IK08uV9CkAb15K/TdXLxr/K81jlajnQfKUh25an9bg2MwgA76UNCLUFGF96gKXcNP+KEMjmiQ67Jb3okuV4S0Aj1KG0LWhfyg9Rq/3AtAP9/Y72YlIwopTXTucIvsygM8JKynBJpeb/Dtl++d/vqAdlWQoxkzQNY03QxcaICZ4BaNB/hCn5l53tdgub0WhH1J5oCcaTE0+odwPVwbSKbd+bBCpM1cGYvA3R4nXUW3eOJvaEyw8Odvo0S0GlHN3pDUZ1diS6KKhNPE/8UdnVoZyL7+c2BbQScm/lpWy8P1XCIxiLSJtxUAir24tJL8tMEVxTQ/9U nLOEK53o oYhVyvKOapPcphzN/9uv3Vr0fcBlVAuqYbUrYopO0PPGqh59U8GMjeyEUza1HkFviu5+3ozr6sjd0fCUXIyiSoMelzYG3ofW+NdxcfSbL067O7P5ImaSg/Li3PURzIg2u734IXDHMazwIrqnC7rc9VJCO6aHuuAgsW1W9QHakXZd3T2bRDUj09VU3Daeq3M1A4PH2kYguMu8RNsga6Z8+oUJpKZa4krd2b+9VammqAc+Tb3CIpXiw2z/eJMXFXwBFL8H18aBSgtr0TL1KXUzF5ICRmgDuz4s8/IJwhTbr6wVEokJiFiZLczeliBqP824JiUveO/OsvQrthvm32Eyy+yOLsA== 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_usercopy() a static inline function. Signed-off-by: Christian Brauner --- Based on a suggestion by Mike. --- include/linux/slab.h | 49 +++++++++++++++++++++++++++++++++++++++----- mm/slab_common.c | 45 ---------------------------------------- 2 files changed, 44 insertions(+), 50 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 1176b30cd4b2..e224a1a9bcbc 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -265,11 +265,50 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, 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 *kmem_cache_create_usercopy(const char *name, - unsigned int size, unsigned int align, - slab_flags_t flags, - unsigned int useroffset, unsigned int usersize, - void (*ctor)(void *)); + +/** + * kmem_cache_create_usercopy - Create a cache with a region suitable + * for copying to userspace + * @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 + * @useroffset: Usercopy region offset + * @usersize: Usercopy region size + * @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. + */ +static inline struct kmem_cache * +kmem_cache_create_usercopy(const char *name, unsigned int size, + unsigned int align, slab_flags_t flags, + unsigned int useroffset, unsigned int usersize, + void (*ctor)(void *)) +{ + struct kmem_cache_args kmem_args = { + .align = align, + .ctor = ctor, + .useroffset = useroffset, + .usersize = usersize, + }; + + return __kmem_cache_create_args(name, size, &kmem_args, flags); +} #define kmem_cache_create(__name, __object_size, __args, ...) \ _Generic((__args), \ diff --git a/mm/slab_common.c b/mm/slab_common.c index 9133b9fafcb1..3477a3918afd 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -337,51 +337,6 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, } EXPORT_SYMBOL(__kmem_cache_create_args); -/** - * kmem_cache_create_usercopy - Create a cache with a region suitable - * for copying to userspace - * @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 - * @useroffset: Usercopy region offset - * @usersize: Usercopy region size - * @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_usercopy(const char *name, unsigned int size, - unsigned int align, slab_flags_t flags, - unsigned int useroffset, unsigned int usersize, - void (*ctor)(void *)) -{ - struct kmem_cache_args kmem_args = { - .align = align, - .ctor = ctor, - .useroffset = useroffset, - .usersize = usersize, - }; - - return __kmem_cache_create_args(name, size, &kmem_args, flags); -} -EXPORT_SYMBOL(kmem_cache_create_usercopy); - /** * __kmem_cache_create - Create a cache. * @name: A string which is used in /proc/slabinfo to identify this cache. From patchwork Wed Sep 4 09:44:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790246 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 DF915CD3431 for ; Wed, 4 Sep 2024 09:45:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57AA36B00B7; Wed, 4 Sep 2024 05:45:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52EEC6B013D; Wed, 4 Sep 2024 05:45:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3CBCA6B0143; Wed, 4 Sep 2024 05:45:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1CAFD6B00B7 for ; Wed, 4 Sep 2024 05:45:15 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B72E2160F86 for ; Wed, 4 Sep 2024 09:45:14 +0000 (UTC) X-FDA: 82526572548.27.F229D2B Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf05.hostedemail.com (Postfix) with ESMTP id 12FCF100009 for ; Wed, 4 Sep 2024 09:45:11 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VaHKAzf8; spf=pass (imf05.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 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=1725443017; 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=L4PDPZ6Hf5Cb3e/YiaP36qNkgjQAGoDFoVNBz6I0ASU=; b=TFXIuOhnjckTUAnA+wNkUVK9wJ2NNCk0U++FUgNJMKAl3YYBpR4W4fnbJMxrCGpWbevMEG anJktTD/fQQMH3zKE8C4kLZr/h9cMI2b9DPWpI0Q1iSZFUP0n5BnixOYLaoEZSNxPdwTHN yEZnvOQ9NCp+2rLUzYZ2XPlICgKEmx8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725443017; a=rsa-sha256; cv=none; b=Os5ZVfPLfEp1d9BmnY8m7zd0VA0bFCP2rGx/XzPOADGxmrZn3AGobD6i45tTuk+YN97msb I6GeXNVWgIeUXYUKzoBgIfkWaq8DX/PqlbjyZmScE+H8oBKPOsVJzBN/D+LVqjf+bSWgfU BrKvu3sX1glxe8DsdzDsd68NO63OkX4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VaHKAzf8; spf=pass (imf05.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 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 nyc.source.kernel.org (Postfix) with ESMTP id 1F506A4357A; Wed, 4 Sep 2024 09:45:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 069EFC4CEC6; Wed, 4 Sep 2024 09:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725443111; bh=7VgDRqmx+Ik8PykBNr2uZycRwWkeQDI9rAEBtMLW9VU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VaHKAzf8okC6RU4aD7r1kxRBPo9J7x9RVLEC48KyPy09U+bjdje9w/zcKoVpSmmbZ rOgU3bOVzYctw3312c/F0/WwpAj66C9a38684ytJMa8Hrog29r0d9QYHpW9BwyhoI6 wBYn4U0GzuPu7/YzspnHirYqpZTSZJPvyDf3jtmSHWtLE4htf79AXAUL8212SfeyDK CdyMaELAUHfDxolnpeWUcE7lZVwsPIWXvvFNWdOIbtdVdlxMkMAyAUuX2Hm7XveCkp HwGSzTJ5FS/CUyRmAHZ0BXEwcxCENhJDGtTs9lt/UH76agLfcmxUlodk7rBGTISiW3 h43WhOluJ5m0A== From: Christian Brauner To: Mike Rapoport Cc: Christian Brauner , Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 18/16] slab: make __kmem_cache_create() static inline Date: Wed, 4 Sep 2024 11:44:13 +0200 Message-ID: <20240904-musizieren-zicken-ee74f5e5c49f@brauner> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3824; i=brauner@kernel.org; h=from:subject:message-id; bh=7VgDRqmx+Ik8PykBNr2uZycRwWkeQDI9rAEBtMLW9VU=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTd0BFhe/srK/NTn35KxZew11HWU8T2MFgstl+yePoyD Z+Fm55/6ChlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZjIocOMDA0bbF7+rXCR+m2c PHXVzGNP1csiZIqPtq36dMLy9A0tDWaGf0bR/H6NT3+uS2uxMH774l+o6qNrZgaRf9vepD/c4mo rwQMA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Queue-Id: 12FCF100009 X-Stat-Signature: jbntnhz59a67x3mkmmmots3eb1hm73jm X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1725443111-135297 X-HE-Meta: U2FsdGVkX19SG28tVVYm4UFP4UyLVZlHVuXXTmy9PIekmrvVWkFfdiQT6MTvqrXDHzsQckv3qV6+RWn+QJrYfJqoW+YV+UOUYW22Qy/ypz9QT4hMuK3IvSjJkQH1I5wrLJcoXwSdstUSSuCuQNnFiJUyiVcFy1pXK45vzHlWZK+B8PjrXQ3KQ4A9ok1Zp4/W2AaE3BmvQlw9plUUGHiscNw7tcfkIgb+P+DQMDxotzSmZZueHHKV/8rxUvJPS7Uc6xeO7CYEPW0kUBZ+/AtMexUiR2KxQ5PxHOJ1uGkMdaGYx9RYWeLncCUiDZqKx+WGDMTmvLNTm7BSf8zEpYQRs1legLwdPqg2SbVQu7OUW3lSFL599IlVvUUKFuq5l/0AI7OvtODPYGMHhnRsZM+N63WYvY4S9A7A+a5rtgdo4TYTA6pi/P7tFX9D3Kzafwxt+GX86jFIm+d9rZ5MkKAs8R9fdLzXZUncryShhhOafin19Hv/aQ/V+SI56zsxlPuPhbStEVJ2SPUmtVs3aAPnS578yp+GLhpQQ5508pnkHXY3vqOYhsQ9lceOGczryFOANRM1FCoykWfQXKhGo0UpynacoARSEwB1KI3NBRjNvorkh3ZLX/+pRC3JCVKEkqCphiljcIWqUSsUS74tX7SBXv0ktDlDLpA3fWesq29R6gp5v36FPRr9DU3sroFS0xC8si+L6jBmN74w+WUEj1+5cK8LGqI2PrgcPTl/z//2RSLfaDRG7nI5TiUwFIsHIZ630wMreUc4udSY74QJcUTvDY+Od08t91gUg2RbfTKRxjqtav+OFqNOfdg1Drb3SVtFbp9OTfIWScRj+dNOZ1Z+9zVr2g8zVV+v145QV2RjrpIAzBmJdf92glv0bNa1HMWoNHDUCSSZIC88x+TkAYLdWxQ7JduDP9XQPzDtscGLVG5pT2fW4uSE6N1e2FU1wGpOGg7IfIWViTdm0B7tAoS O3gVp3fH Ir+cRRlTJMYGCv4H0n/xe8PYlsmG6mgOzwJzTKCoPf7Nh9WgvYvh7vakqR2+iJXflwsBl40qcLQ4r5vSIB6EIgZ5aC36cWUyqw4QLuHwf0olQYkafbfMH8Tlrxg407C9WTCcGpfSEu4P9zap/qE9ocXWMV9bOtEA7V0aT+UPNxk2ulwPAa8W6RSXrDCpmz7VCLzFa7c48mdB3PG91RSRNajauCg0yW/X843BdTHUdiZwIjtgsLw0f2VQGO+pS7bmk2vuLBvFpgrsVw840d724fVB4ObLQCmIYhcgv0rshTRk9LtF1m6O/1uvX6y6aOztz5MJ960UBtu08OVY= 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 --- include/linux/slab.h | 39 ++++++++++++++++++++++++++++++++++++--- mm/slab_common.c | 38 -------------------------------------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index e224a1a9bcbc..3e16392fa37f 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -262,9 +262,42 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, struct kmem_cache_args *args, slab_flags_t flags); -struct kmem_cache *__kmem_cache_create(const char *name, unsigned int size, - unsigned int align, slab_flags_t flags, - void (*ctor)(void *)); +/** + * __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. + */ +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, + }; + + 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; /**