From patchwork Thu Sep 5 07:57:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13791897 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 AE55FCD4F59 for ; Thu, 5 Sep 2024 07:58:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BB466B009A; Thu, 5 Sep 2024 03:58:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3431C6B00CA; Thu, 5 Sep 2024 03:58:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E4E56B00C7; Thu, 5 Sep 2024 03:58:14 -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 ED0166B02C2 for ; Thu, 5 Sep 2024 03:58:13 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A22351219C5 for ; Thu, 5 Sep 2024 07:58:13 +0000 (UTC) X-FDA: 82529931666.29.03120B8 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id C854012001D for ; Thu, 5 Sep 2024 07:58:11 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="n/cii1Y9"; spf=pass (imf29.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=1725523015; 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=LmUvlQw/XUOFJDyv2fVCf9l2Lda32tanKJIv9PQ6SeI=; b=xkE6W8AQe/BqxECqvcKvfgVfAiASdaRc8l2Le+y4tJJDvBIKPyX8P2Yw3Kj280e35ONZO4 hOrTVhJPLsNAR/2a04oJqTpdbBfOQs/xEViJP+OY8mxDVFhkReD4bbZ6+vSxIr/lTyHf47 TDEyb/Ro6YO0WameI9lh+34/IECDEpc= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="n/cii1Y9"; spf=pass (imf29.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725523015; a=rsa-sha256; cv=none; b=Pdd2pNSgtvnFzh82zgOLV6YsU5Z5DB+gPOdH9ul2JS3bageqagk7FoM0NMf/5VSJCzjfBv z5UuY5/KNbgSKxjyBp66jaIC36klk65607A/l2eYOxe3URDoWNYFIuvgUFNpMwbblWut3V EyRo58u0QTq2NaaDAtYnr27b4HVpwAY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 8B5BB5C433F; Thu, 5 Sep 2024 07:58:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6815AC4CEC3; Thu, 5 Sep 2024 07:58:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725523090; bh=EjTjGH3N7I+He4i3zTdEnIsNUEnQ9qSuzD1HUDVnA88=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=n/cii1Y9UaMO6oLLzq+PA4Vy0/MwZIQeJ9yLODD3MvOMqqhPRxWm1x7GIX25GI/qp G690aWfdS5p10x5FCW5PqvhbTqhZefA0icmgivaU150EthEStFU1AgYtFd3GeaOJQy U4EScFhr20WPqHmcHBwGz1opcb326Vs6aCqxqTaMdv5qaB+uU16A1bpHtGHEOJoNG8 cG/Y6jAnwZWHfrKLMKWP4gsjwHZdhNZHV1UgcQkVza8kALbZknFpAhxn9Vbp65HgHn YDHbbJ5pm08OwI8mAypTWkqRLG7PQy+k8l1qGm1E1kBRtOq1owOgJziQNM69rdMVQo PdkjcvlwIrOyg== From: Christian Brauner Date: Thu, 05 Sep 2024 09:57:00 +0200 Subject: [PATCH v4 17/17] io_uring: port to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240905-work-kmem_cache_args-v4-17-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=1730; i=brauner@kernel.org; h=from:subject:message-id; bh=EjTjGH3N7I+He4i3zTdEnIsNUEnQ9qSuzD1HUDVnA88=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdTPHhj1L7r/Bk2qwz7j/NNA3ZPkds8Gb9+f4l61uHu nD93VXpHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABPxOc/wV4Cf57l0b/FcH1+T VFkn/6fcDXo3btpERvZv8f637gjjBob/SW8yPtZ1fvr0p+QH91+O+GOvnQR7eBceb745USDVSoK VDQA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Stat-Signature: dgqgzbm8zb58itxorr537mqrtnyx5yyg X-Rspam-User: X-Rspamd-Queue-Id: C854012001D X-Rspamd-Server: rspam02 X-HE-Tag: 1725523091-94400 X-HE-Meta: U2FsdGVkX1+XY4+epcNN2AwZCyLzArse6mlk4apTnl9XKo4bZ1xCyRavgkr8hKgrpNNdiarAO9SlkANjxauiphVxIr3rmqGKVdgc8zfoJSY4x6YxNCI7lmJWNkbpVEwoNgQWck54clU5h0jLGDRbbb45erEGiQoblDn8CQExbMBrM2VOmNOdtgGLpJnop/eFx9JCdABpjx9hp6S0rDWvl+Y+TZglBjcOxXHlqA4IkVwiY/G4bnOygcyOobrHTunjVv+44E0JPibls2n3hqz2JliTXBe4ioN0EG1eJ2nfHuIeGQ8wqCIflji7TOmr0kiN9IVP+tu1/vr1PPJ3scCWSMj0Wx0gtuH/TE/ikAmutt9+7Xro5IpGMOFfnxm39jt+NorhcFt1eaefA14c/X+F5saXo1PVN0fIgdag9vnrUfQvrM/qTiN0A5NeM2dJkWDoM/gwBqc6ONg6xCWwBI/dN5WVxVvPSDFuwTjvz4Vu3pxCV/jSirpInTB+f/UqrHnh5Ud9qkQiowh+PSZIbyhfL1z+7vbUsipLrAqDgStyRlB28UakwpiA8l9SeRtlgAUT5wtVZyuAhXSzBz8SMFP59QWNcP3PmaYhOzneDvXFXPJekRGeAZGoom9TfajYwjqxX5X1vavvp5UfJ9dm98H1SmmB9P+jy6S/ZwgPnY+X/k7UZr6bQ+nMWppugEEkKdHi1zV+Yk4KDzRhGILVl7/dzgjHetVoh7R041Eq7lZAZbCK7fdz06JXhGSWai43OpuAcdCS+yUYotVv8H/9dxrBPdTrKpzLbUWtW0ywGWWT0thFq/rRmijEMiul7Mc7Zo0YqwH1rYlwL9oLp4ZiE8VlEhjFEljBSF41lWn7fLxjvDIsdVJe+4xvDgwOZU6UZvrfPuSPBl8k3QOYtPv4yFl4j6E6kMs1umZgH7t6n+KQLdBmgTPrmoemYBWfHfWqpf2MDxWLm7VVmSSjhJyj5UU e6wPjwMP M7X6nTdnvGIDtWo8YR7WXLcKMJ3gWHvZbA8jIF3uaYydRcRj9CqCayqp0aWgv1TS0C12kRZrrYZZ/WL5mBtC8g1FPPASumTLKQY3CxkvUMgbktWRN4UmwbnaTB5vMXG/O7yaiaHKBIAyR6qx1SivucaV80nuMc7smavOsC8Wmo52611E3+TY1wmyJ19O3wigcdaJL/3Au2BxdpyMmG2FF4OCK+OXWHJg3YcWXRIAt3Vatu9kP4qTLIT364VfnQ5fzPc6oWlo3iQ91UEcRlEz890zrDSnB9iRtHuHjLOtVj/f2nDqQ4ROlNMDkXHkjNu7i/gb0CMmxrnKML8l4AFSz/Z5DtCxsztSe3qJtJKXa/MjCbYp1K4eCd4N8WjOr1WVaROaulJC1HT/IccqrsrOh969u81xilMAfRmhR 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 req_cachep to struct kmem_cache_args. Reviewed-by: Kees Cook Reviewed-by: Jens Axboe Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- io_uring/io_uring.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 3942db160f18..d9d721d1424e 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3638,6 +3638,11 @@ SYSCALL_DEFINE2(io_uring_setup, u32, entries, static int __init io_uring_init(void) { + struct kmem_cache_args kmem_args = { + .useroffset = offsetof(struct io_kiocb, cmd.data), + .usersize = sizeof_field(struct io_kiocb, cmd.data), + }; + #define __BUILD_BUG_VERIFY_OFFSET_SIZE(stype, eoffset, esize, ename) do { \ BUILD_BUG_ON(offsetof(stype, ename) != eoffset); \ BUILD_BUG_ON(sizeof_field(stype, ename) != esize); \ @@ -3722,12 +3727,9 @@ static int __init io_uring_init(void) * range, and HARDENED_USERCOPY will complain if we haven't * correctly annotated this range. */ - req_cachep = kmem_cache_create_usercopy("io_kiocb", - sizeof(struct io_kiocb), 0, - SLAB_HWCACHE_ALIGN | SLAB_PANIC | - SLAB_ACCOUNT | SLAB_TYPESAFE_BY_RCU, - offsetof(struct io_kiocb, cmd.data), - sizeof_field(struct io_kiocb, cmd.data), NULL); + req_cachep = kmem_cache_create("io_kiocb", sizeof(struct io_kiocb), &kmem_args, + SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT | + SLAB_TYPESAFE_BY_RCU); io_buf_cachep = KMEM_CACHE(io_buffer, SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT);