From patchwork Mon Sep 2 15:31: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: 13787432 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 383F0CA0ED3 for ; Mon, 2 Sep 2024 15:31:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3942A8D00ED; Mon, 2 Sep 2024 11:31:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 31B506B02A5; Mon, 2 Sep 2024 11:31:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 195DB8D00ED; Mon, 2 Sep 2024 11:31:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id EF55B6B02A4 for ; Mon, 2 Sep 2024 11:31:30 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9E9C8160283 for ; Mon, 2 Sep 2024 15:31:30 +0000 (UTC) X-FDA: 82520187540.09.5BD9030 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf24.hostedemail.com (Postfix) with ESMTP id C7EC818001E for ; Mon, 2 Sep 2024 15:31:28 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EPNxNTKu; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725291019; a=rsa-sha256; cv=none; b=ZFomvAWmP3OeUZiALx5fgr/EEV7mWSnoa/JIN6nU/3c7w4AHffpc+8JNdQBu579qBhvVDE 167ZjrLzAEOsyuTZ9DLQtHbd+azdWBbZ1SxJC0uy+EfxGE2SViiKX4Dqo4C4E427z/5bVt oa++c2jdjzAnBG0ggbcb0RqF2/7gIys= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EPNxNTKu; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 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=1725291019; 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=90SHcvMsbdNnqjgumEcJgbzVisqYtJ/leNjYKGgh34U=; b=q+eN+6wv4X6t/8FKMagS0RBS+ugY+bD5yT+sbYtrFzqbezcUhTzROAr1DP2+YtNNRMF7hG lkpNvab3cZ/wVtwL03dUu87Hjq9T//CEY1AHBtYAlur/ig2t+aeZA4jJvUWqlxYtqTUsQZ 4jIBz4NrQlSmkXMngSIpxA05mRfHxfs= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 0DDFAA426E4; Mon, 2 Sep 2024 15:31:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 773CFC4CEC4; Mon, 2 Sep 2024 15:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725291087; bh=Zpt9lSArTGXLvcTSsZDpq8nm6fr+snVIvMpKU7zrw4w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EPNxNTKumdFSDoKqTWxRdfaOUES2A8xnZKBBUpnCFEq2D3TvtkhDry6yMwS/WA3S6 u7vgRoF17UFn59ueMrkVKC2hbLv5x0o4al0rPCQPG2Crg40fJo1KMblb/DOmcddNKJ kIH1i+9M7/CjJn9pXEDX+lcxIBKRrboj/Dcq7hyNOf1a3H6a7K+hmt5EO1L4OhtDmg y9x8S5xlsV/Uw4AlIOM43V7QsGDVHeOgj3ABMwJOG9vQ6xQ253jNAkxg+Gtg/OVkiV Aw1IVNjZsE/UhFLvEUWIStEWIp+UhOExEwOkmSq0iZZJi6yZJAcrbiDaKagJHqtSwF Mmq0OaUGtCQ6w== From: Christian Brauner Date: Mon, 02 Sep 2024 17:31:13 +0200 Subject: [PATCH RFC 3/6] slab: port KMEM_CACHE_USERCOPY() to kmem_cache_setup() MIME-Version: 1.0 Message-Id: <20240902-work-kmem_cache_args-v1-3-27d05bc05128@kernel.org> References: <20240902-work-kmem_cache_args-v1-0-27d05bc05128@kernel.org> In-Reply-To: <20240902-work-kmem_cache_args-v1-0-27d05bc05128@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds Cc: linux-mm@kvack.org, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2113; i=brauner@kernel.org; h=from:subject:message-id; bh=Zpt9lSArTGXLvcTSsZDpq8nm6fr+snVIvMpKU7zrw4w=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdveWx+ZC/lp9vyxPvqR9/pvwNvvLLrPtT5TUu+YrVC 7JfzRHY3lHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjARkceMDAefiptt6W80T/jb G8Y/qYHnXvzz7NJPVcqLg4/ddT20RJrhD/fSr9oMT43nMQpyvKt7l8wYFsl9RUbS+8u8rH2Mv/m lmAE= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-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czh4Qp1Ay0u9lRsZp8BLB0w g92Go4qs S+zvlhQVy4Y9KEwKFsvANlw0+yc5Gxbzwkp5SA3E7x6bVw8oKvheogwe9+wK6r0E7x97Jb8k704JS4kikzFTdJGpjNpuqC7VRuJ9PuZ55R4Go+DiGZ2amv/9Pyy6oxuIGpmwGd6HL+p33UPgksiogRICy1yCE3VVVf2OsfXKv0ulPY1L1aLQ3hcDnAmnMbnBnXjFWOpjKTgBUjHNc2B4QjAihZhIkqj1AXbHR/IH5Kvm2+Ve4naHwS3Xa9luWr+3we9CpPCHQ9of4HpjW0lTqpxmo9kZ2+lyhautgcw5T/AozoQY= 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_USERCOPY() use kmem_cache_setup(). Signed-off-by: Christian Brauner --- include/linux/slab.h | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 79f4799b7083..52928474e6a1 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -283,24 +283,29 @@ int kmem_cache_shrink(struct kmem_cache *s); * f.e. add ____cacheline_aligned_in_smp to the struct declaration * then the objects will be properly aligned in SMP configurations. */ -#define KMEM_CACHE(__struct, __flags) \ - kmem_cache_setup(#__struct, sizeof(struct __struct), \ - &(struct kmem_cache_args){ \ - .align = __alignof__(struct __struct), \ - .ctor = NULL, \ - }, \ +#define KMEM_CACHE(__struct, __flags) \ + kmem_cache_setup(#__struct, \ + sizeof(struct __struct), \ + &(struct kmem_cache_args) { \ + .align = __alignof__(struct __struct), \ + .ctor = NULL, \ + }, \ (__flags)) /* * To whitelist a single field for copying to/from usercopy, use this * macro instead for KMEM_CACHE() above. */ -#define KMEM_CACHE_USERCOPY(__struct, __flags, __field) \ - kmem_cache_create_usercopy(#__struct, \ - sizeof(struct __struct), \ - __alignof__(struct __struct), (__flags), \ - offsetof(struct __struct, __field), \ - sizeof_field(struct __struct, __field), NULL) +#define KMEM_CACHE_USERCOPY(__struct, __flags, __field) \ + kmem_cache_setup(#__struct, \ + sizeof(struct __struct), \ + &(struct kmem_cache_args) { \ + .align = __alignof__(struct __struct), \ + .useroffset = offsetof(struct __struct, __field), \ + .usersize = sizeof_field(struct __struct, __field), \ + .ctor = NULL, \ + }, \ + (__flags)) /* * Common kmalloc functions provided by all allocators