From patchwork Thu Sep 5 07:56:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13791885 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 859E8CD4F59 for ; Thu, 5 Sep 2024 07:57:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2334D6B0207; Thu, 5 Sep 2024 03:57:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E41E6B020B; Thu, 5 Sep 2024 03:57:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00F256B0209; Thu, 5 Sep 2024 03:57:26 -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 D369E6B0207 for ; Thu, 5 Sep 2024 03:57:26 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 519A3C09EC for ; Thu, 5 Sep 2024 07:57:26 +0000 (UTC) X-FDA: 82529929692.27.209BF84 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf13.hostedemail.com (Postfix) with ESMTP id 9BFBB20007 for ; Thu, 5 Sep 2024 07:57:24 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="R/D1P6TD"; spf=pass (imf13.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725522995; a=rsa-sha256; cv=none; b=imrNyq4b2PkVYIimMqjNuh1pwA7BRleW8/j9ez0IyXF6noerEmptf8qTH4t69Ff/XUVAPg bFCXEUy2FFTiAkb3OjIEw4oYkiUvYb06DHhTgOqGjJtM85cTgGZUjzBVyLUpqRLUHeHdsU KDvaZKLtzUw6KL7MFpvmD8/fHI0ugrk= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="R/D1P6TD"; spf=pass (imf13.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=1725522995; 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=5+G9qNnNibOPVizeOtt1ZuXdkZTUPqHhLY+eMhYoYUU=; b=zyfZLGeTASyce0/OSuPZNUyhjzWWUzmmB/Q0jmyGFuzf2iVAb7zXBk8EfAEnczOW8I0YQy LPUt+Jo4FCZdVIok4BNPQxew1qZWYw/PCGMwdIR5UWk1rVwOrmMSQ6e4GP19kAQcQMxIGQ CtnM/OgQFEQPbXw8w66r7d/vkzlsk5Q= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id BFE2CA4437C; Thu, 5 Sep 2024 07:57:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45DEDC4CEC6; Thu, 5 Sep 2024 07:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725523043; bh=6Lwr5vukmiiT/FN2uceSot6K8Ni/9MrZgxWKfDi+Qrw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=R/D1P6TD7i3UY0YoNJUwmFJ6UyYHcjDyPANa2Wlb5o90hiQ26zKS5AR/jkc4f4SEy YceSaYFbEZHm/C5PYEd5MAowgwnVp6kdP/beQa/V8vHmLlhdst0Xz1xWgKs0FkuH1+ kRbclNIQTlz5eexEo1D/n1agRtf/mXV9cXck0Yzr6cRT+LB+zwIebWhvkBdbQee3Q2 SnFAEKpZUub3Ye8AUkfS/JNiKoWP7Vh+Yrrg3dCuoORvb55B+KAXFtGKaXoZYcqaRg GErCg5kgnpSiSOWZql/CqFt4+pB8A7esVmSzAcsfb0+uGVxtIuu6szTo6w26XFuiOx 2HsMsH/RvcV9A== From: Christian Brauner Date: Thu, 05 Sep 2024 09:56:48 +0200 Subject: [PATCH v4 05/17] slab: port kmem_cache_create_usercopy() to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240905-work-kmem_cache_args-v4-5-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=2077; i=brauner@kernel.org; h=from:subject:message-id; bh=6Lwr5vukmiiT/FN2uceSot6K8Ni/9MrZgxWKfDi+Qrw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdTPGKsfyzU2iy6oqJdrum/37ZLHLyxDqPwI66x69/G dy/cZWns6OUhUGMi0FWTJHFod0kXG45T8Vmo0wNmDmsTCBDGLg4BeAmr2b4X3hDN+grt9yT67Il Ng1Zx+Lux4SrOv7fxsC34I5BRsWGYEaG9/ZhR62uTH6+RsrF4JPes3+/Ns2q3ugaI+X3Ysf/D67 XOAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Stat-Signature: 8sf3e6ymthackw36fmgkbnqxhfhgremu X-Rspamd-Queue-Id: 9BFBB20007 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1725523044-535673 X-HE-Meta: U2FsdGVkX1928XbWvfwTpYEXDE8ANnTUUjh3bTP/GnJG3svXEo13WfFhTfVOIQ49E3NDcibQeWIwD4ZBIC5gOdcqR3ZwykTo2ObIGnaQS0mAAGwvggk0Tlr8lBP4vsU2ffL69ZIhTnRA1LdA/ZLO96Furh2hsEMZaml8ApkSXONg/Vax3NUpvMTmBWrWwcFP7hRpRtyypBjgMNVFJ4QqJ8HdWSBYrC/0ynqzxjD1zyW0+svwkktE0atAORbv+4YHP7hiUtGFpaVVdKmI6Wrks4Rp1NyTwwR+oMB//TAWXaLW4Vlk4DEfl5aW3cb9tN2CyoR5Qu+8WHOgLdksp6QhO0z1+sOL3BP3KScGQN1XaoHB6ljy1q1fBnlcwANxvkXVExE+fl9t8eAsH9v+NY01PNZ4O68Gi8YJfJlUPfk1powLzOpJvbsnpCOZNosAIvoWkZOHTsFBZbmktH6+N5YakikJiysWzprcRfQnU9SN19brr17VjuJET+HYYmy9mld7M91hg2Hyxle8TqJxtZL/X1Z+oLpLLoE3Whq8LkSPgrX5/KnNzIWh1bGRPTPAwcIW7GTXNLWl05CDZdcjvPiErxdQ1CwifnbgZtOCz9F1UqeAVRbU975s2SbDn/7Ea/HFx9Z6ykQAGeHDmLrXZ18FWs0RuKOTcg/6azcyOE8c7E3yZyIX2SLRlWu+5+JGTTRQ5EWWO7lGV6yQAJtyGt09RehyBRom6ZC/g2utInO6DHkz6WGiiQMkJ0dccip/UBx+8BwrRcCdijXFYjOKIiymv7aqKD18BG3lg07VQCeSQfHzklC29jS+HkuFK71Bn92TjrIRSJrgVR0Nu8EGY6XcgN2mpCG68MS5M/CWU1e2xNgfpefsPiLfXbzeL2LYjF3cEI36yu1JIW0LFqEZj1darG4ZuDAbVMqzYieICy5qM5qglqnFwGIlp103LOauInmo4uEyU7C8cZRwGbDaBQV JcbhXLBu 564WGaXJW4QFGUO+pt/KOn66HEQIs49od8BbcPjCC0oWDkAphoyuWisC26oV2rIF4RGnpKN2XKR66FlWqbmCUIJ6v5vfy4c6k2NZIqNzVo1HHiMj81rMmO20o8//rs9OmJbNnPyjBpyexjj3ozkVL/9YsJtoMZTeRrse5UZW+S2aWMfaSqzdNuglgb9aEq062QCx/u/kUWqWmUkW3/VEjvQfb9sDvc8gpSC+4wGyj1RniG7Dp3WMXVWrwCrBXBhW/tNQyl3C/LdFy4WinNJvr0tGTtBMbZNcFVouf+LMYIHK8qonVsdyTzuMVfBnSPEPMf1+/h5x0+DhhJQhZDdxD4YmCP2CU594CG+SRFsDuWcEP3ERZzgp1xI+8GJVM8lX28WOgD1+yAP/G4yhMTNNmDdG9YVmxT1UOY80j 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: Port kmem_cache_create_usercopy() to struct kmem_cache_args and remove the now unused do_kmem_cache_create_usercopy() helper. Reviewed-by: Kees Cook Reviewed-by: Jens Axboe Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner Reviewed-by: Roman Gushchin --- mm/slab_common.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index da62ed30f95d..16c36a946135 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -351,26 +351,6 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, } EXPORT_SYMBOL(__kmem_cache_create_args); -static struct kmem_cache * -do_kmem_cache_create_usercopy(const char *name, - unsigned int size, unsigned int freeptr_offset, - unsigned int align, slab_flags_t flags, - unsigned int useroffset, unsigned int usersize, - void (*ctor)(void *)) -{ - struct kmem_cache_args kmem_args = { - .align = align, - .use_freeptr_offset = freeptr_offset != UINT_MAX, - .freeptr_offset = freeptr_offset, - .useroffset = useroffset, - .usersize = usersize, - .ctor = ctor, - }; - - return __kmem_cache_create_args(name, size, &kmem_args, flags); -} - - /** * kmem_cache_create_usercopy - Create a cache with a region suitable * for copying to userspace @@ -405,8 +385,14 @@ kmem_cache_create_usercopy(const char *name, unsigned int size, unsigned int useroffset, unsigned int usersize, void (*ctor)(void *)) { - return do_kmem_cache_create_usercopy(name, size, UINT_MAX, align, flags, - useroffset, usersize, ctor); + 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);