From patchwork Tue Sep 3 14:20:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788793 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 B4299CD343A for ; Tue, 3 Sep 2024 14:22:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDF3E8D0181; Tue, 3 Sep 2024 10:22:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B8E378D0151; Tue, 3 Sep 2024 10:22:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A30798D0181; Tue, 3 Sep 2024 10:22:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 80B298D0151 for ; Tue, 3 Sep 2024 10:22:51 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CD1BF40441 for ; Tue, 3 Sep 2024 14:22:50 +0000 (UTC) X-FDA: 82523643300.04.CFCD8CF Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf23.hostedemail.com (Postfix) with ESMTP id 1E5C7140011 for ; Tue, 3 Sep 2024 14:22:48 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="elIp/6pQ"; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf23.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=1725373263; 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=EWZq7yOeNR6OU5sAPwgrDdhD274T+bXm1EOFILUdrQU=; b=mH061F2EzuETT5ViYEB0jnwy98VO3BRM2fiYJjZF73CXSYkFHkaxpuvFe7j1Z6IwAIE8T9 wciFa1gL2CqXLnLkXS/dCwMOxOEkunl3yl7e+aSO4Ptbli+4ktPdBeckoEcKDWHAZt9T/o uiZbFK9DpYG90/BhXWaYqfcel++Tnmw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725373263; a=rsa-sha256; cv=none; b=E7x+7tGLaQPwIJxOcK2enk4b1NVj1WdiZSIaW2tthZUCX4Y4iztVUl8iiXxtEGUaY3l6Px MqC2CHsaIUJswXUtKUEOUvhl0bYWADm42YKCBiT6k4gVhVgp7CspbFDSZPnLHpfRrrkHtV oLA4fndP2CtZc2Om5lpQU4yJSsdaL48= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="elIp/6pQ"; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=brauner@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 41680A43662; Tue, 3 Sep 2024 14:22:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AA01C4CEC8; Tue, 3 Sep 2024 14:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373368; bh=PVJGD880SWN2QXXzV8G7Km5Za31W7UeV1k1iq+DB/nU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=elIp/6pQ1ITB14KbYVhhnY4NhT7QtlcVxjp9pClky3Odf1lSc8k/GlrrMjwudI3ax yZwcsK22IVTe+MaIv2LhcWKwuVfpxK1mrAd2BVCIrbu18yRcqDhU7IjFWBVk8AT4hG jYl22Y4aKeWbX368tp3tfoGRyKmfgpMXin1THiKLPKrzMgUj3BfM7eaCQRVfaOOIPC nITQ/g5+8+rj/moMX0B22xFmMvIGax8lLdryc6+GYcw+Bp2TAAL6OjI5THqFTzk93u D5aRUGE0ebxI68nZRNOO0yy94hDdzj+N9/pAeYFNqt9Gul75ONyfUQaNPfPZyF4DNg HPbjixYQEaTxQ== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:52 +0200 Subject: [PATCH v2 11/15] slab: port KMEM_CACHE_USERCOPY() to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-11-76f97e9a4560@kernel.org> References: <20240903-work-kmem_cache_args-v2-0-76f97e9a4560@kernel.org> In-Reply-To: <20240903-work-kmem_cache_args-v2-0-76f97e9a4560@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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=1312; i=brauner@kernel.org; h=from:subject:message-id; bh=PVJGD880SWN2QXXzV8G7Km5Za31W7UeV1k1iq+DB/nU=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl55jWn9i6mW97Oe7fSc2ZE0PfnPFdUX6r3ju02dmP ovy4Eks7ihlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZjIfzaGvyJSqTpK1dVflng/ qYvIlF9x9mrjg4hrO3mTTmZE1UYddGD4w9NxXOtzZHCaj+Lnvbu38c7Iebb4xaWMg4pdJwxuROh q8AAA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1E5C7140011 X-Stat-Signature: 8amjkz391e4da5j964ukyytqm5imac9m X-Rspam-User: X-HE-Tag: 1725373368-392043 X-HE-Meta: U2FsdGVkX18K5JCD1rTHn3wyfoc386cuCH89Ax3PqToGd1nBbymDMdjEC+Q8W+66gRSScVXsP7KKavf0KpmwxzPzzYB13yPi77lW0++91B9dUlvFnd0r0imdVMNIaEHovoGZQDdoKrYhoHnehExlLGZYNhbgDyPzvzaX+z57emOPHV4PUob+lQ0JvxSAOGpvGj7GdK85pZgmJpqOrCL2qD+mKRqIsZI4wcNXZKS9DYIVQJS25l2XcY3qOFq10AD+Q578WJp9IWKOyt5bJEqvV37WRq20Cpj6gtnR6Cb0pPCA051IiIumECwIB3v3E43l57lHfeXCgMOwYnqBONwnvtql5YF0XqW64kbsEQf/5PW9F84G7EbANV7sWPPIrA/JIZndJRmkXwAEgOo2ZDYtPGB1sfW3IbPIvp5qGGNcWrFYDQ0DQdFyuOo+6YcpWN7+pqAUHb0G+WlLV3Z7CGmJrJnKB1O40Eoelng44GOPw1wfzY+tyjB93ZzhfjtjJIjtS0zm+ns1hVwJPTfYIazXIGIIf9QksK+X84P6pKT5COn7SvF0XRNLNNYTflhrMe59KFD/cHKQQyZIJXs+et7wVl+/yvFkFscGWaEmdbopLzFVW4QbGky7r35k7fHvD3Oo1B4dh/tteBVgac2hbnE4HPRp9X33jLWjDvRERNPeAV2hjwU9K4cgNrCDgaMX/+TrbfIzGkZmZjrpBv4hRnepmyksZETvpxk4CNBJtmDSOve0fPLbt0pJ7Ep/vCmnFN8HvMaQ47W1pQUat3tYw+1PfHETV7ZKG8DUQVNwJWabTnUIdvcgVjsAcWwo4z59cFQNRvz0gK7BtWdzvnlNDlD5rne8Ffds4w/IkHG/76r3kLn78NGdYq2b0pUDNRT4aaPH4rYGRsLnijS/Pt0JPxvsrAdEPRFKt40Styvt8AaRUrMvM5nfErxxPVIsnuMEZgOdh/GJAeworiGmexTMdCn Ed6kNYVK sSAmg3w32SQvylz0Ngk1qDwl4VaeBqhUTVuubMbaP0mpi+4kdtIhFQqNPw9vJRHKVmnMRUXJwfC5UuA4zL+Dg1vcWAQmRrUlrD96LxYSaqHIcZ1LcHazhwEEPMGGeJXc2Vfm9dTHn3VRQi/9e31eIPSQ36UxxSmS5SvKFR2ZPfAPd3xnZJ6De6LDG5JY0k+zDCL7Nm+pqt+aa/YtEnepSmic+2VndRiktlkDIwluNE+Qfah0kF+ShI2Ryw7Ojd4Ww6WgMNlTH69qykJK5QunnOto9fjGpYTl6uh99 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 struct kmem_cache_args. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- include/linux/slab.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index d9c2ed5bc02f..aced16a08700 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -294,12 +294,14 @@ int kmem_cache_shrink(struct kmem_cache *s); * 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_create_args(#__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