From patchwork Tue Sep 3 14:20:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788783 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 AE5C9CD3439 for ; Tue, 3 Sep 2024 14:22:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C6E18D0177; Tue, 3 Sep 2024 10:22:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3767F8D0151; Tue, 3 Sep 2024 10:22:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F0938D0177; Tue, 3 Sep 2024 10:22:29 -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 EF87B8D0151 for ; Tue, 3 Sep 2024 10:22:28 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A51A58047A for ; Tue, 3 Sep 2024 14:22:28 +0000 (UTC) X-FDA: 82523642376.07.82676E6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id D6550A0012 for ; Tue, 3 Sep 2024 14:22:26 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=j7WjnjG6; spf=pass (imf25.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=1725373251; 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=qA1kYPvS3ryvpXACw9tYGAdC6w/y1wsMU9Gj9O3qCaU=; b=JYE8c9uM+uFq57o7UPaPjm6WcbIv9xC96TNaIqo5u3nTi53MhY53HoUZmVjilJj7ynd5b0 Lwx+43LPT73RUpexTrSkelMi8GWsu0BN+/4Wqb2Ka3dLvnb8pa4KoSfFq/i7R4UCzrtSo8 3Z9EpyBNclFilGZhb3Pk6A6eY9NHCAs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725373251; a=rsa-sha256; cv=none; b=J9PBmyuvZhN52PF1YQumpWOKIT2hfUWB/L1fE+BxuoipO5X8A2FxuIn3q/9kCZrWjdBIXD nmMQv5XDSAirnIpFUkPQ3gASfBirfs5gTN6TisZwgWzTPT2lKL7hkHLMSD4J9PWNk/27H5 DiR5d19i+TbdKy/pkEHrPalgy2vUhA4= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=j7WjnjG6; spf=pass (imf25.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4EA9E5C5871; Tue, 3 Sep 2024 14:22:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DA9EC4CEC8; Tue, 3 Sep 2024 14:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373345; bh=aQiIKK7aypFaSSN7lgRJDvRI7/Ip5hPvhqIbIRsPc90=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=j7WjnjG6DU4tzE1BuBWHzDqxuj8IxdxSm8g0U15AEnbMBM8wttB1Y3G09ev5GLai5 W2xu715Lw9oCHM2xxc3zKsxgwCJlvcnbklI8orrNlXFMpmDE+/+EIkXe2HdsgB2AUw 7w5NIffNI05CLpefEIII4pV9TAVZt8+LH7bvSgW2lsoZFWpV/vjxSr8pH3VqHi15qD cQeUJebohkTHwEIHi5xUjNX8zFobHPdwFYu42KnOQBePw5MBtvUmDOOV8oi62Mo/Vk oziANUL3cw4Sh1Czk/9uSWtD9W51cHqOWLNO+FLe98JB/bZZtu4tHx/HPWN5Wnm3XP LAQw2zTFSQMBQ== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:42 +0200 Subject: [PATCH v2 01/15] sl*b: s/__kmem_cache_create/do_kmem_cache_create/g MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-1-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=1917; i=brauner@kernel.org; h=from:subject:message-id; bh=aQiIKK7aypFaSSN7lgRJDvRI7/Ip5hPvhqIbIRsPc90=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl55994PxvuwGq4XPVzybc53nc+GFXI8vs3/9VhDNM exdODGMt6OUhUGMi0FWTJHFod0kXG45T8Vmo0wNmDmsTCBDGLg4BWAidu8Z/mn7pr9d4vP/0D4O ibK9/vqX9kjKvtg1wTfqWyoXZ/XLma6MDPcTjRjfBf0+qqr9bb7gudfOv1ayefxlvdyk9OXzX5W HSWwA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Stat-Signature: nr8p7en9b3ybr34esdu7g3545qfbut65 X-Rspamd-Queue-Id: D6550A0012 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1725373346-5860 X-HE-Meta: U2FsdGVkX19CHfGQz4j5/8MkY56gnDdi294B0Th7SNTsXbXRjBTKBgGVf1HYshHnhMArOFax/pJZjz/L7iEwFlAeQF04d49qgOLZxB5C6OKpRrj9p5T6MVp/LNfhSsf8C9e/29msOlYwuLbLD4hE8fW91m1x2y7QuT6Oyki2l+9v68JT+RDMgv5QzaxL32xu8PPihEp/wY2paZsdHcpITsaoykVfZjI9hdE3LvjH45OF/kXVIE/32Jb6YT8CTZre4N/Fm3FK8m8loM3iery4knUP0W0+s4tCXeGeLVfY46gkxbGTU/XguVV4ETkzPw2CEi8IrYbMFRIN/k7pq5Pf0prOoLiDkGQDg/MmSWOacIPxUfEOZA7VG9cpVsKnQelQ5OcJlaC1zSxLwf5DsfOaimiCo0ekYbr28cx0uYmi8NKkOQeIrpEmgsXF7RXmZxx/5u7lF4xDySsisRn3LGJLSK7zSTaELhk8yvCS9aNUAdkAGUWPYwYf+oqGWjl6gwWq2VdsEEdWv5EdLixJLk+sSIr+WyYDFlT+3OW4htdzfTMP6bZZJagQk/hTTtOqfiehhmD2YHp5GL22HTp+Yi87GN8W/Lio5vOf7YModeiyHew20zcI23iY4mI79p/OvxuM6Dt128MNk/XKKt/xTVNgqPIw1dYlJv9UE+R7DYUBNkUrG4VD0xGN5BhiJW52ak9g3AX412J4njEJV34561MdGwXWQo0hZzfx/Hlh4BhWyWs6fkD+OUwt9s38/xQ4w2L+WBc/eUY1IEdhQl6FQzpgGYkLyNcQ0/b/5t1CnPbxkAh38w7+l2tL5kZRYd4w9qjJ6wIZAudLO4yauWqM1JkbqQ+Q063VK1FqtgKI3pihYGzhkWdW/bKANSsb6vmomFrCTmdHrYQdmULx+F1FjPTCIGJN74K9EhxNh4c55P50eiSfmyQBuzoUkzGnGRHskEa0xVguXwL05uypTqJfvkF hdCMMuLw a8ZwZYnuWhuhsLsMx59K43u6466Q4g7RgEUakRjwOBjnXJiF0/aUyYLSpnIi2RlZTe+KUdsCSaGoHq77ZAMwm31CvqgMSdSIqDOtuFd0TayBlGzf1HQzl7Ilz2ppnko4yPxBN4YGzu1RJM9wlhhwbSfm0kIJdyhjqEfiqjHGSAA5cppyjvFZw2m4xtgRzT8evSY/TPfKQlS6T2lph7H6Qp6OUBNB49P7RLCxOibYLMHXjqEThpVVzhmAKs07lcjpzF1v9cvhvcHoJWTz/IkBXhCe/MpANZPWVxmfi3GfrcOgUzwc3Z8/HnEIYpX+MK/yQoiHcSqPrD+LX8zPaeeQvQHQ/Hg== 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: Free up reusing the double-underscore variant for follow-up patches. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- mm/slab.h | 2 +- mm/slab_common.c | 4 ++-- mm/slub.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index a6051385186e..684bb48c4f39 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -424,7 +424,7 @@ kmalloc_slab(size_t size, kmem_buckets *b, gfp_t flags, unsigned long caller) gfp_t kmalloc_fix_flags(gfp_t flags); /* Functions provided by the slab allocators */ -int __kmem_cache_create(struct kmem_cache *, slab_flags_t flags); +int do_kmem_cache_create(struct kmem_cache *, slab_flags_t flags); void __init kmem_cache_init(void); extern void create_boot_cache(struct kmem_cache *, const char *name, diff --git a/mm/slab_common.c b/mm/slab_common.c index 95db3702f8d6..91e0e36e4379 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -234,7 +234,7 @@ static struct kmem_cache *create_cache(const char *name, s->useroffset = useroffset; s->usersize = usersize; #endif - err = __kmem_cache_create(s, flags); + err = do_kmem_cache_create(s, flags); if (err) goto out_free_cache; @@ -778,7 +778,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, s->usersize = usersize; #endif - err = __kmem_cache_create(s, flags); + err = do_kmem_cache_create(s, flags); if (err) panic("Creation of kmalloc slab %s size=%u failed. Reason %d\n", diff --git a/mm/slub.c b/mm/slub.c index 9aa5da1e8e27..23d9d783ff26 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5902,7 +5902,7 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align, return s; } -int __kmem_cache_create(struct kmem_cache *s, slab_flags_t flags) +int do_kmem_cache_create(struct kmem_cache *s, slab_flags_t flags) { int err; From patchwork Tue Sep 3 14:20:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788784 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 7DC85CD343B for ; Tue, 3 Sep 2024 14:22:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BD398D0178; Tue, 3 Sep 2024 10:22:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 01CA38D0151; Tue, 3 Sep 2024 10:22:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E00778D0178; Tue, 3 Sep 2024 10:22:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B4CCA8D0151 for ; Tue, 3 Sep 2024 10:22:30 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 72C96A8254 for ; Tue, 3 Sep 2024 14:22:30 +0000 (UTC) X-FDA: 82523642460.15.E416B32 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf06.hostedemail.com (Postfix) with ESMTP id 9AEB5180006 for ; Tue, 3 Sep 2024 14:22:28 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iQJr2KSY; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf06.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=1725373278; a=rsa-sha256; cv=none; b=DR2pw+8m4dz51TcRN5AU2C9xsb6/yQo+kUPsNe12266keym/RcE42zzYNrITPYqm2o7RHt aM7ta783PTumdu6zYLRP8HNtbLUwk0OTw76v+8EkMscHoGcVcUp80mStZysxFTPRHsldMt TWQuYHPuE/SGOVEw9xRD2vvU1Ej6SrE= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iQJr2KSY; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf06.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=1725373278; 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=p8tzsaUFpSg3rt58dz7tkuciGP9etf4F0l6ymHLZ59o=; b=rDcc5LXFSj04hZbwKBXEl9nZCmgXuwjpEfJNDOvJ1gTBIzHPua3MSYxdDIFqE8adPcgHOS ZzIxw2DEsY01YVtrQ8dhs29qxxzALzqIbFTpTrdGwmpwF8mJEqrgYGEkANWme+mRHWUcll lynG0TNIa3RL2g5SpEvnOzxb7uV872w= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id BE5BBA43662; Tue, 3 Sep 2024 14:22:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D032DC4CEC7; Tue, 3 Sep 2024 14:22:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373347; bh=2h5DOrmEliYOEskMyLdOlS+a422lNEm7iLYnRuCn078=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=iQJr2KSYx/rknS/FfpX+JxiEROKLTM5PnAYZ+o7XEVv6NgP3Ss7tjJhNVLJDjAYmg V1w3/5f+g0CdyNTOTYOk+MyMT016PpeTQSQ9CVWlQjEmYiiidRhd5oBc/sSsG1zBIa e2QfgbzfX02r9yFo7QRX2G58gqj7RaPb+Tur00aybamWoo1hRqz8NyWQLbQXnL5bTq 9TJ8oEHrOK+F3C/N/OCCnqLEonwIvdHgPRKO+9swiWGr5ikMlWxa7lOaY4WvE2YHLg NAXHIZBEH3+euJk3IsDszxZJDMupI0XClXyaDEV4YW6f5o0YzZ0GNF3IuO1vHXJZhy CdnYHOYX2nb8w== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:43 +0200 Subject: [PATCH v2 02/15] slab: add struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-2-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=5053; i=brauner@kernel.org; h=from:subject:message-id; bh=2h5DOrmEliYOEskMyLdOlS+a422lNEm7iLYnRuCn078=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl559e5Opz1zVj/eFzHY8dLq47YuR2uY7dlX5wfVT8 wO/B7+80lHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjCRgrmMDJvP/rf4f7iw78yF f8xdB6L/NnxZxs9957/CyR9zXj9dJerAyDC/eIqDhMKq5ZGlvj+2LF9+QOFBocTslZo74hdGpq9 /+YcBAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Queue-Id: 9AEB5180006 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: jfwrn9c4qxj9giw96gowdid5xo96hps6 X-HE-Tag: 1725373348-506655 X-HE-Meta: U2FsdGVkX1+dYMWUrFwSwXcRRgZR1RObuSon4VLZ3aqu+r1JH097WRtIr/ty/QQ9i7yOn8YeLziF4MDRNytdLyrjp8vbIRw01IIbzpSnjbJ2SWbzd2JUCWZlzSLN63KMsZlZMMh8X48GNNxtdxDWqtYUodADTCNrmdA4jL8FKF1w66LAwrZbRtV2Mv4AxxDjgXW8bCl+Y6IEde2B/bYI0GY77qvOpEMAV0Dx5khcQKwVWe7ns5wmer57I1a8xP5J2EWIRB3D1dW0KUhWj7sFkqvpfc8l78WiGk+s+J0txFewXIHrlxwX5h+ZqMYWSALuP5auYdKiLdgsdTu8w/m7MDMk8iRSPzEV0YKJ+KVLNPMYSv7EO5xzyv2djIQB52o4SW7SM0rzuv/Ze9X4jlcTdFR/M8m4gdVzaJciZd6VwTipEsth4hioDGlYMzkPnw4uOm1Tx97ga0FjZKwqu+wZUyKYdDdsb1zbl4Ii8+GDpM1m9TXH2ybqYYkHq9PCwpGtr0urVlnvawBeuq2qFTT/D/f0x9EDrCqyJ9IihWtaS4d37JZLOJFWBl+kPj8ESIZkbJ8E5DN8xqQ0Tu/RHgweETaToJVqwwdyLC60uklZKsu8LJ3cDtGPGLLyOz7CmGMkiDxxLEa7/8S4t2BOudrQRWHUMmVBtKGllV3uI2DWakRZk5CYzxH6cUpGnl13gQltfpzpg0dH3tEt2ZNWxGPSWfzEwboBndM3EZvtRPgBdYRqQC4Jh32sT9HHi6n8rVpKtf1ys3XL5q2kqMxluF+jdpDX+dq7xoiCw5v5olri9M+flfY9s5wwG4aDMrd4ZNOv3mcUzPxT8lf9hi83J1heboIfhfOeEGNI7XjNdne4XAPI9BpYXowmGrUZraqX7aaQyrkTwF4OqnoFmct2ZBVdrM2Nu1dl1bb6o0ZM8u5EcOlMj4pIluOb0UluBw9EJ3c9bMX89bxvZ2iF6dyo3kE KAoX5Kxv 0NHcOfu9ggEwptVFmmdW9acHuNBHWjBqv6+UUHkJP+ep/zvn4nMTvYTCGZKvbwnDZEB9dcw7n/1wAbIceqcc0pPg9qyhT4gw9XhiOZMWFW8WLq2ZMlQEDnHHw0jVjn1oMKKcQZuUJJkKOIbMQnq+lsOaBL4gurEMyPWk5ijwOXjMyqWGeoUC8T+S+Q3s9bwXO8XPD6VaNQPp37OI/sRJd4jtAWg95ZfADqu3jYgUzNUaltbypYnjRtX0gt8VTyFaV43CKkbMskRasOLgqkG86/qm3mrjmrFmaPhA9 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: Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- include/linux/slab.h | 21 ++++++++++++++++ mm/slab_common.c | 67 +++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 72 insertions(+), 16 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 5b2da2cf31a8..79d8c8bca4a4 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -240,6 +240,27 @@ struct mem_cgroup; */ bool slab_is_available(void); +/** + * @align: The required alignment for the objects. + * @useroffset: Usercopy region offset + * @usersize: Usercopy region size + * @freeptr_offset: Custom offset for the free pointer in RCU caches + * @use_freeptr_offset: Whether a @freeptr_offset is used + * @ctor: A constructor for the objects. + */ +struct kmem_cache_args { + unsigned int align; + unsigned int useroffset; + unsigned int usersize; + unsigned int freeptr_offset; + bool use_freeptr_offset; + void (*ctor)(void *); +}; + +struct kmem_cache *__kmem_cache_create_args(const char *name, + unsigned int object_size, + 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 *)); diff --git a/mm/slab_common.c b/mm/slab_common.c index 91e0e36e4379..0f13c045b8d1 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -248,14 +248,24 @@ static struct kmem_cache *create_cache(const char *name, return ERR_PTR(err); } -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 *)) +/** + * __kmem_cache_create_args - Create a kmem cache + * @name: A string which is used in /proc/slabinfo to identify this cache. + * @object_size: The size of objects to be created in this cache. + * @args: Arguments for the cache creation (see struct kmem_cache_args). + * @flags: See %SLAB_* flags for an explanation of individual @flags. + * + * Cannot be called within a interrupt, but can be interrupted. + * + * Return: a pointer to the cache on success, NULL on failure. + */ +struct kmem_cache *__kmem_cache_create_args(const char *name, + unsigned int object_size, + struct kmem_cache_args *args, + slab_flags_t flags) { struct kmem_cache *s = NULL; + unsigned int freeptr_offset = UINT_MAX; const char *cache_name; int err; @@ -275,7 +285,7 @@ do_kmem_cache_create_usercopy(const char *name, mutex_lock(&slab_mutex); - err = kmem_cache_sanity_check(name, size); + err = kmem_cache_sanity_check(name, object_size); if (err) { goto out_unlock; } @@ -296,12 +306,14 @@ do_kmem_cache_create_usercopy(const char *name, /* Fail closed on bad usersize of useroffset values. */ if (!IS_ENABLED(CONFIG_HARDENED_USERCOPY) || - WARN_ON(!usersize && useroffset) || - WARN_ON(size < usersize || size - usersize < useroffset)) - usersize = useroffset = 0; - - if (!usersize) - s = __kmem_cache_alias(name, size, align, flags, ctor); + WARN_ON(!args->usersize && args->useroffset) || + WARN_ON(object_size < args->usersize || + object_size - args->usersize < args->useroffset)) + args->usersize = args->useroffset = 0; + + if (!args->usersize) + s = __kmem_cache_alias(name, object_size, args->align, flags, + args->ctor); if (s) goto out_unlock; @@ -311,9 +323,11 @@ do_kmem_cache_create_usercopy(const char *name, goto out_unlock; } - s = create_cache(cache_name, size, freeptr_offset, - calculate_alignment(flags, align, size), - flags, useroffset, usersize, ctor); + if (args->use_freeptr_offset) + freeptr_offset = args->freeptr_offset; + s = create_cache(cache_name, object_size, freeptr_offset, + calculate_alignment(flags, args->align, object_size), + flags, args->useroffset, args->usersize, args->ctor); if (IS_ERR(s)) { err = PTR_ERR(s); kfree_const(cache_name); @@ -335,6 +349,27 @@ do_kmem_cache_create_usercopy(const char *name, } return s; } +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 From patchwork Tue Sep 3 14:20:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788785 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 1C2EBCD3439 for ; Tue, 3 Sep 2024 14:22:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 465DB8D0179; Tue, 3 Sep 2024 10:22:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 377048D0151; Tue, 3 Sep 2024 10:22:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 219C48D0179; Tue, 3 Sep 2024 10:22:33 -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 F12608D0151 for ; Tue, 3 Sep 2024 10:22:32 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9840AC03B9 for ; Tue, 3 Sep 2024 14:22:32 +0000 (UTC) X-FDA: 82523642544.23.A80B4D8 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf23.hostedemail.com (Postfix) with ESMTP id D44AA14000D for ; Tue, 3 Sep 2024 14:22:30 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hGdsgjSh; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725373273; a=rsa-sha256; cv=none; b=4xKwyedCN6A+VeA5DwTw2RcT1ut9OSW4ZdS3m1ipdUGCO+lk8ZiUPOnQ6RFddG82WUSv/O dOS7d05sMo/Ig7AtA3SOzDooQd+eDWJ/E7byoPEMd0rQ0JibT6zi+by368zTc72ncE2vio x4C+kCJvSg/Ox2NKDtMGf1TfZiw45q4= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hGdsgjSh; 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=1725373273; 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=70H4RI2MEzoZOUbJGuPR/tQdQ/7ILOnZjvqPgQ71tCM=; b=TFRoXooyQ4wR5pFzEQVJTkiTQDUZeDz8egf/FfFOwHWGNudHHKLP7cpwZZDig9PT5IDVs2 zqOBonp+12DWYsVqJqPWoL/0x+VOcfjtS51WqiFfu4le7NuaCf+B5CtM+uxymQEPbudgbN vPnflwC+DzrrDWvWedsR8S8dvbSSGUM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 18B05A43662; Tue, 3 Sep 2024 14:22:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E388C4CEC4; Tue, 3 Sep 2024 14:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373349; bh=B1znre1e72KpovENRq2WhUqNJBBTL5E5a2ArimpQcWQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hGdsgjShNU2trZTfO0WBjhdzdFWFkHmlXYOn8HDfCT0GXxvKeNgF4wR7j4364QNiY q1wD+/F1glEBVwIUOInyw4qaqmx4U/Oph+rmhif+EMEeXNW9a5ukgf44ThUWBmDYIi s6r+Feb7OUFSWPCiIeWlwCWwlrIDgqGQrCev2KyPGKL2d9Xrh3Kt5i2PDrOFFWYC2p Ps42dhybyCiqsS/P2ys4JCo0fFAdNK5dcBwvyUNllQ2ssvhGcnQjY7A3UMGp33KJlZ 14g0pUVTW37Xs8qGyENRNZfTRhVIZwvxc1frcIpy8vVjZFSQas0GJPOpGCeIHFzX4E 1f1beu4RpQiyw== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:44 +0200 Subject: [PATCH v2 03/15] slab: port kmem_cache_create() to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-3-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=820; i=brauner@kernel.org; h=from:subject:message-id; bh=B1znre1e72KpovENRq2WhUqNJBBTL5E5a2ArimpQcWQ=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl57930r5SMjm0K8nn3zub9kt13bs1KNlE6zjn196/ CGhZP/b9x2lLAxiXAyyYoosDu0m4XLLeSo2G2VqwMxhZQIZwsDFKQAT2aTByPDq+TzWEP84jutP EhdmX+j96rHG9Zq3e8irf2+2pCxe53Sd4a/Ev+bF1kurI62YuGbzCcysF7Dsqp1xhqWiMWEC607 DC5wA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D44AA14000D X-Stat-Signature: bpwkhs93gu5xpjamjqngarmqnh9iwp4o X-Rspam-User: X-HE-Tag: 1725373350-955459 X-HE-Meta: U2FsdGVkX1+9dKy51Hmwb1e1PBSCdYGtjUoKz/SPcnik6dXBjBLXcssQn0jbZEoqw2iSqulEff7hNUy6lG89VODWTyOym+OahRCawkqEU4+vY0bgGh70tbjV+KPPMVlQxCg+8yhc4ugcYPKZPX2VcLHiDm2uca+ngS/gAOBY0Sll4BzH+elXQS1C1MzGgxEXZ+pjiSUUtt7Hg587ximdjQSg61+UK9igJdd7rZY0JM7PY5Oq3ZafDAONtGGSQB6bs1SiHDTQH6HTeiaHVk0aRYqUw46pZf+Lv/2gfI5Cgj6tA9rgBbrU7NWYhIO5EhjA0IIHsveuCt0D20bSvsZJHMnllN5j+8tVilT4G32qPf+vQJjqhQr8EBlSJVTostyIosVPIJ+05xiXeQv+kspg2lTy0dOE1od3XwBW15RxwGV/2LrpsRdLeT++DbpFVqzqb4YIhvddffyUF2znfgyMAGvYwCRITITjcWClyeKVWJN2oqgQx15Qg/nbulqVaWrlsOCC+6hO0usEuEBU5y7SRJTXGQ/+xUlv20R6Dc7EP4KurONJhceAr7KLwbSaidwo7j7DuAf5qKXd7dMP33+tCirPvlhGVzca8Jsm8G6hGj2JUY/43Orgwhshen0NbdqcWk5GO23VVnZ0OzEffgOu0QaEI9bd6Zoz5W61mBMjW0IwuvsPOC+SG/8agevLjT/e+Cat+8ZMGpNw0vJa46UZpUs6JsXZm0kSUtbpxZQp53y+3nc/5wEQo6eXmd8Q5wQVnCPS1cQfddgaGQgJk/G5kclcS0WenZkKavhs/vs9StWVB7+EL49/psrGX93dsIha2obRNU538/yNt5ygPVZlIUYTI6/NYMFPshLzJQI7vOAySbTQebjvBmMfmly30xzoXXY7rWXedmv8azqh6QELWfeoZ7rAo3jSxbhzMdMofF0PllQEoSX5OKpyBiwMJmwc4vgg1aNJ+NG/UnKaXPg +W+QCWOl sdw2DCfxgXu/WaYgTZOe+DDjKw7lsLb/bKxcgN0G0spEcl/cau/bFys1iY99D0MP25fVH0+6sGjj0HMrU34QXkYkI2OanzWAnSFXKw/iZAr9MrCKt6iNRK1cy7YkN1lZ1/xyaTzJb2ALb2F5gq6TmlnC6R9JJY88TvAQtVH/Vb3VuBv3yNihR0UHL3u0vhpXH/hUB0h9d8bgdmCubt/+XsE3WzkHTrK7mqYc6zXmVNR+bgd9/gFR1xafT4cXcBgqOGb+e5SzFJ9NSnPPN9LSkrH72kI3I0aD0wG9/vnorL+OC1ZY= 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() to struct kmem_cache_args. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- mm/slab_common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index 0f13c045b8d1..ac0832dac01e 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -439,8 +439,12 @@ struct kmem_cache * kmem_cache_create(const char *name, unsigned int size, unsigned int align, slab_flags_t flags, void (*ctor)(void *)) { - return do_kmem_cache_create_usercopy(name, size, UINT_MAX, align, flags, - 0, 0, ctor); + 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); From patchwork Tue Sep 3 14:20:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788786 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 CE212CD343A for ; Tue, 3 Sep 2024 14:22:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C5838D017A; Tue, 3 Sep 2024 10:22:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 748318D0151; Tue, 3 Sep 2024 10:22:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59C488D017A; Tue, 3 Sep 2024 10:22:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3A8A78D0151 for ; Tue, 3 Sep 2024 10:22:35 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D89891A03FE for ; Tue, 3 Sep 2024 14:22:34 +0000 (UTC) X-FDA: 82523642628.02.C031BBB Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf12.hostedemail.com (Postfix) with ESMTP id 148D940010 for ; Tue, 3 Sep 2024 14:22:32 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pVJqXNnq; spf=pass (imf12.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=1725373305; 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=fGY+mHu23x8ypU7UjXimXJG4cvLc4bgiQvcdGyZgne8=; b=xt8CAQ1Zl7wsBMrO9YFvFmfWr4OhvZN5t3R3Tx902NRNnOS6eKLt/H6yPpZKyQ6qQoChAE AEQV35cBPzSuMv4H3FIzAVjpAJ7qzb3hphIQMkO3KrNst3iB1vkmNuhnb0Xd+mJjdBm1nA 9UZrf0ovkg/kVvIPMXlnBtLkHIYBPv4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pVJqXNnq; spf=pass (imf12.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=1725373305; a=rsa-sha256; cv=none; b=QjkleO3UQIO1lp4qlzDa6tzCovnczWru8O7VV1wjoJqB4Dswz9k54jBSM3OCOEQIYMzRGr crV8FxpACH2xDAXujtYX9oNbd1l2W5+yV6QhJlmVMXMlNxtkns1ICVfXSIB+UNctE6iXpF ym9E1xshew1UJkXLhFULiXtmozUsjow= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 4F431A43662; Tue, 3 Sep 2024 14:22:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67AA4C4CECB; Tue, 3 Sep 2024 14:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373352; bh=Kd1uMp+HUkedeShv2sPdOAndToo750mFLJVW3GciVU8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pVJqXNnqYjpyuPF/kKeJ/msDo8LDirhJKxcVzSVn7jGoOyLMZ2EXXghasprE9pufQ nsM1+pfcpmCTfnI+Xk7jru584AUPl7jVdYtUCniXFOdwNzUUsY50ZS2tt62vETfhET zeEFzy9W1AshaSijXs20r8yLrPteIML1dTi9/GnZqons/TcQC6DryLuUPzDwBaJurq vqeEXvHKGC8YbzAqMK7hE/s+NQn91v8Kygf3A1/ZmWC3qwmFV6pQLZ6JJu+RVC4LmW 0kM1crsub4Y2/rH2WNdJgsRU9kKgMaKkPrkY0zIWAeIcQowvDzdck8rCkTDRGPf93d IyAJNVW5/3KdQ== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:45 +0200 Subject: [PATCH v2 04/15] slab: port kmem_cache_create_rcu() to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-4-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=931; i=brauner@kernel.org; h=from:subject:message-id; bh=Kd1uMp+HUkedeShv2sPdOAndToo750mFLJVW3GciVU8=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl5793k/QulzHebby06KKRblnnhx44rZyyUXdmuem3 lNztXqVO0pZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACZincLIMPWl3gRFHUOh9u86 PqpMrrd2+//g/HxW5YVgcmtiMqPCU4b/0Wlrlt+fzrDsf16A6JusAplFhXIGM8y+v59xpv+cqPY 9HgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 148D940010 X-Stat-Signature: bwduurbtbg4eqrtkg7rpmgb1hndh1zpn X-HE-Tag: 1725373352-911370 X-HE-Meta: U2FsdGVkX1+bJVE1q+wPv4EgHaZUM9AYL57En+jdIFZIcJzVqUGLseDS3mWTdy3g+LST9EzrmWOoHyZY1rOHZsFBAXD25pVQKHYeQxKZyuoXsKVwS+ebRsRyzAzpaKMAUviBIBNqLhH95qfhoi9TpiqMgosj0d6M2aJJXJ2YfO8Gb+UDkh8hezs5MGhPtQZ0k2QrNYDwRMAHevNuq5jWCHT06V3BVH4NglrI/JipeHN4syJk3raeNmBB2Yj9oPX1A9NcaLKq1Lq0UzFuDXzxY9APWLEOY3AwZm7WdopZGNcreUraQSf9zl+A1zAXpOnVG4dEQEWzSGtyvYKTz9M/SIDPIXDiTQlqK7oDM6D5wELUTBPvx6qJEbGHIcTilWgCkv1DUwF5pVbgYBeBvMPVswElvQdnX9yHWyBEcKkvteR6gtVII4sU0vlI/uNwPag0guTqbb+4UVOIzboX0kzqiK/RkZzWP1woWR1hm5QIUBqh2zASRdlMbOM2I0V/qnLvmNZYLb5m05yooKFXFJ11QzO+wzynST0FmL4uVcDpCFlABsxU0j6vduo3TMlsQGCUc8s6kkouKuXTl6pW4BFGbHZztvt7U7hwuJ8NCEWve77HtsF1XHG/k/93whn7/dLiQ+3D21mMJjCk2SlgqA6gtp5hNPD9iYYF4C2Lb78B7s/rXDsSN4DEoEKddolteWu8NZizbKtTXDpT0r9FVryjJ3iuCyt2vjftXYCZC8ck1h+ffSYCJNiS6Y95rFhRp8Y+fCe11QDe6uVwxxBPlYtl+wdrgwiDPLZF6acF6u37O/hG+bRsdoQBLc0WP0yOwKNDrPz55/zHOQZo+ZwdsmAV7ykl/DiROzQOtHxP41l3Gnx3Ts6JAcIAcRrA4U5j/ZAU7pvFnoZzac7cGN2jzrvwZ0Og0wvfGwCaTV3M63eBuzn3vgNveFUWbplW9fc4hmUa/OG79/jjBo9Aqdy/jVA ey48rVNH KpZyOl4ayrR2aizlUfxKcuxNDC9wyeyUT59I8/xt2UQhncMO7gF1JGHrsooWL4sg1fu5C57U5JR/tLz2CblqMXUWhH6T/tiLdgVGmsgBc/LyNm4M4OJDVjQqdGGUckxGq/cCWOT23ajDa/feRa8j6Kmru/nZ7UdJgSQ0nMXYWNxhXaFoM0G1r22M+uBljIhmYIcOu3yOs7wVAFcSlilnsAGr64f8eTf98Ht365v5LQ2olx4qe/cYJbwlspGXLPXEGfw6QAMQwvVb783hCQbGLz9D02k41iMaUiQkB 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_rcu() to struct kmem_cache_args. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- mm/slab_common.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index ac0832dac01e..da62ed30f95d 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -481,9 +481,13 @@ struct kmem_cache *kmem_cache_create_rcu(const char *name, unsigned int size, unsigned int freeptr_offset, slab_flags_t flags) { - return do_kmem_cache_create_usercopy(name, size, freeptr_offset, 0, - flags | SLAB_TYPESAFE_BY_RCU, 0, 0, - NULL); + struct kmem_cache_args kmem_args = { + .freeptr_offset = freeptr_offset, + .use_freeptr_offset = true, + }; + + return __kmem_cache_create_args(name, size, &kmem_args, + flags | SLAB_TYPESAFE_BY_RCU); } EXPORT_SYMBOL(kmem_cache_create_rcu); From patchwork Tue Sep 3 14:20:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788787 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 8AAD1CD343A for ; Tue, 3 Sep 2024 14:22:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA2748D017B; Tue, 3 Sep 2024 10:22:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C55348D0151; Tue, 3 Sep 2024 10:22:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACD568D017B; Tue, 3 Sep 2024 10:22:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 830438D0151 for ; Tue, 3 Sep 2024 10:22:37 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 405F8A85BB for ; Tue, 3 Sep 2024 14:22:37 +0000 (UTC) X-FDA: 82523642754.13.C95BB49 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf18.hostedemail.com (Postfix) with ESMTP id 85DA31C001C for ; Tue, 3 Sep 2024 14:22:35 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="lnwsuY/D"; spf=pass (imf18.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=1725373261; 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=Mve8L0Ir7YTQzYWI8ceHCLtQR3JmgpY233DDCqEobOc=; b=BXDoa2I6At+4jcTUs7ocOs8/5i1f6i3m07AX5P+IW/U3t8sk/4CyOgcU9aGURA6u0TFGgg x0E/dkuKqe7cY0+XwgGVBPI2jPr97Y/9fe7VSBS97rxnMHl8FJnv1AtZyTfMN/ap+71TYc 7pXGzJDdgDdSX2VoPMTg5v4oGHSraXg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725373261; a=rsa-sha256; cv=none; b=2xBu36QjWrE329pzSwndc2lICRcraD6n/7fW9oT+YbUbwz+M5zJ3tPqmM19N0aAEkn/lTf TL0j7hQlJpdYcfDeDIIQ1xYFEA6QFruUDHtoIcL9BlUEYvG/I6yguBz8iQ75qIyOfA+xQv o4MXZMv9xD/RDFMduzJMo+x0hpxatCo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="lnwsuY/D"; spf=pass (imf18.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 988A4A43662; Tue, 3 Sep 2024 14:22:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D591C4CECA; Tue, 3 Sep 2024 14:22:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373354; bh=qZgCti9Uoopmu2of9/KPoTLyubqgNTKqAU6SyDZvCz4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lnwsuY/Dm0ZSsZkzBUqNed0O6oKMY249pFL4KNk8UDjxunv1NStiWR9awREnGzVT3 KBca6yWLYFHtQw02kRp1g6S93mGZZkvCh5SMf91cFE7Mul25Dqh4HgLh5x7QqOwd+a IASO+TMGu/s62B+KpNVrBsap/j/xFtqNvZeb+reXcuH6Akbp9Civ9Iho/TgGCsQpCA aS9Sl+/mzHzSVEnoGfBPXOvJcKIw76woMywoZxaL0W32AZxRLrz0Pnc7TYIap5nl7y A8+0eYI0Q8g9DM/vln56yslETXQgU1VF6SjvAlSG5UkpgA16SsQBPb+vrEyZK6c+6g lX57Vb026CJPA== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:46 +0200 Subject: [PATCH v2 05/15] slab: port kmem_cache_create_usercopy() to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-5-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=1887; i=brauner@kernel.org; h=from:subject:message-id; bh=qZgCti9Uoopmu2of9/KPoTLyubqgNTKqAU6SyDZvCz4=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl55dWRq+dU34k3mzC1vupey0rti+eO9s/2fNCoxHp X382RXfdZSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAEykKpPhr7Qby4t/pje7HY9u d25SzA3LY3tX8d15WbGbx7uqade+TGJkeHz0ycy1v7eviJaabRm/Ruw2154d1/h0nodxKkyfx73 3DRcA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Queue-Id: 85DA31C001C X-Stat-Signature: p3acqrityht1chs36fux7mdwqoqagbdf X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1725373355-127119 X-HE-Meta: U2FsdGVkX1/sdXEpQEn36LDrsMOPzMGRO522XdiANWZAxdnDUJXUtj6pQvGijNNP0dAkm39ukz8OARFoq4cgSCL7MSDmRUkDz4ITzptGbY5qMKz7xesBmrbEBMbqfUm44LYGVFyedHwoErSUBq6pDDwuQXbOZb6DQkGfGzgRqdwW4y9BIq8/VqzkSV+bnLmaQ1J8EJTEq1c1E0gyyVuulDWphQYp88TL/qMLFWUA96HCRIZQ/nYhw6LBIJ1BLAVkMAE6q0VmkgEvFXIEwS96o8v8lt8+2p7YGR9RZxT81ZPgAVYZAz9x7IgiGBfAvC+CuPQTrCo46j5Rzb7ieRibWBdreJTdnt/SN0KM3wxN+4Zgs1ytJdTNRs066UgHp8yZ1+6bc8DKndbCGichZrDKBV/dT2dSv8IsWOQK/bccQAS8JZbSZ+Djl1/IxDUcv548mPThU9N7bmfIVMPm7A7dYnRYLhVeWYwHl547/9Cvqdv7AbAOjsIaIe8j5Q5GlhUuDjSpdBVWZLZpPlGN5kqzvk1CgPhq6kFTsVK5MoEa0TU7QR81MBxwr6BZ07eSCiW7wyiQ40/jKn1hczcNlcm0AqEzwGIUUxu3Vn2Zv8K0e6OqdMF2d0X/kCoruz5f6tCOrni60V2vPSpYYMfFEYB/9lbdiuW5s75Dv9rIhSBRnHU3sPzSuS4YnKRBuugN2KlH7OUMSXOmQVxGCoC9s4Sf38rJOs4Ne/fUfx9WwusuCf1IMroVsk22GapUz7WvGUJaYUbm5P15e4HIU1OSz1n0Dv45G42iCa8CBAXlVXdzMguGdxYGZ/FLd7o0A3t+wPas2Lg4ID1EJ5z8rqrWIbSnS3mLVLihljp3EcA4WKU2hNs79+LEn9TbLQMnEAWllIqozjJVBPuYaK15XBCyuMjDOe99cYnnQv3Gsy4Z6oyKAEzn94libC2Kdu9fAj9CKQ1otl2Wp+zeKd1iS86OmeT 8SKF7hfi hhCx0vTD4Zic0Lnt40GWSgZoMQGP9jIJxn3i/a+SzyznhN+DrQlKFH1GfShk1fcZ2AlFvravpkyAREDhRYUSbngqKwgXJkaAgNjUb9ghkldbPKJ1iRqJvY6M6TtdkzaMrE04XfMmRB0glgsfu0vZmJzFOCogvq9r4qj4dNrIS04aQ/BB2kQGS4mq8KFxv9HXeLQaRFdt4rt/y09zhbbpJtVviiGRrYCalh8sjfYJ3/mDD1602kBzcAkScAPex1LdbDjqUTHlEcif4LoT9YXyVphZc3fYQMQJqFe3SI14xCSXPEW8= 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: Pprt kmem_cache_create_usercopy() to struct kmem_cache_args and remove the now unused do_kmem_cache_create_usercopy() helper. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- 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); From patchwork Tue Sep 3 14:20:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788788 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 6E4A2CD3439 for ; Tue, 3 Sep 2024 14:22:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F1AE8D017C; Tue, 3 Sep 2024 10:22:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 39E128D0151; Tue, 3 Sep 2024 10:22:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 131BC8D017C; Tue, 3 Sep 2024 10:22:40 -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 DFB348D0151 for ; Tue, 3 Sep 2024 10:22:39 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9235840414 for ; Tue, 3 Sep 2024 14:22:39 +0000 (UTC) X-FDA: 82523642838.05.E4E7597 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf25.hostedemail.com (Postfix) with ESMTP id 9FD01A000D for ; Tue, 3 Sep 2024 14:22:37 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HU3gT6w0; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf25.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=1725373287; a=rsa-sha256; cv=none; b=Ab11Yi0PLOCuvR9+gsODFfAx+6SI7oDho+I1+P5veib0sny9JE5RP6wPvbqfx1r1xXAIxq bI+XTncDnDBeHWwFzKiF/3PCPd88khOTgepnxPYlza/BjF6G0sN8vjO8o79/OAnrcOaEkl V5u9QaoBqTkTSE1wDT/pjcORe/vxgkQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HU3gT6w0; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf25.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=1725373287; 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=yEY0+sYD4afS7Y69IH9fptdKaBQqOQvxxzlHkXobPM4=; b=ri1hA6I1psq0ob79H/eYZeMXJFUw///DWrMaR+pKxbHBP1qEVkzzktqUEyr7eA4Wypl+S9 vmyOUvyIqsKNLKG18mitlhx3GNaGyacFX8lKcBXI2ti+Pvg8eNFNW3DR8xh19oPkwuQTCf B1MqT9k5SHWaS1/9N9sfnmCz5sst+qQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id D150FA4363C; Tue, 3 Sep 2024 14:22:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6A06C4CEC9; Tue, 3 Sep 2024 14:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373356; bh=Kwi+I1VrtzNjFT2qOG43GSdAkcM45KGq+XLRDdRsBW4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HU3gT6w0kxMRCh5cjqQ6GVZT9zHNO+tW5OEaJBvo0wqjvITuNxXJnWE0javyOTqvr FQwWfOYB3XwW8uiTGL2BRtw0FoBY4nIFYHGzhueA7CW6+ZyWob9/v19WpyvgykMF4F 0P5Y++52gJVpGcEw0uSSOQl7l/1cihjlemmOLneEIhFzMqJeYJJTjt7Sh9wrB3qQZL zetPgbUDZvBTIRqtEdsoFD8Ulima2cMJVWDVNxfp/B1qF2Xnx2SVhJALGh05CPWFwm 6zvELTznDpr/2y7c4+PII7Y1eE8bujIG2SPWHhcRfP6+MLYRrjAPDYDXSFPKDYKOUF OXufpqNfUg41g== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:47 +0200 Subject: [PATCH v2 06/15] slab: pass struct kmem_cache_args to create_cache() MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-6-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=3048; i=brauner@kernel.org; h=from:subject:message-id; bh=Kwi+I1VrtzNjFT2qOG43GSdAkcM45KGq+XLRDdRsBW4=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl54t6HCjduvW5zuL87Xma60vmixz2EVi+v1EUzOu/ KIdp1n2dZSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAEzkdTcjw1bOm71eDxO4vzrM tfp8IvronE09clPakure3Xb5PMPU4hQjw+M3m9gORTG+O3BeYtH19PclB7bZnHnHsN+5Xm53kE4 CIzsA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Queue-Id: 9FD01A000D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4gfn8c4j9owxcxhomone4fee8agubqqf X-HE-Tag: 1725373357-778771 X-HE-Meta: U2FsdGVkX183GBbLDV7asRmE+N5mFoh4K1xHfLeahuXA7ifzULfABqE9c+IqrBVsyrXB+PeAW1Lz/eRvios+pu/KA4oddSiFdHKkvdxkHTZALVyO4EnuDMwt25OTDXn2z9ht9nGhngZGbHTfrSts5ojAYwZfbv/0uw0gGbahuFZnFGGDeC8xJAkW/nbCYB0DeVg4IFwZneJ7kXhuh0rlQd6cVu7XvSKWCseNpOG0Jkvg6OkVjCH4IuFPdxKusvyZToXnSjOr8jzje0rU7sZLYmx55JEJSOvfOv/V4cZdVuiPYoUcYbcDiw3KIPP+s9R69hVhjQRWI8VOfA5iVYkJAyWczXv59adhdbNce9e2JLlMgD8IfVrlI95u45u90erVU3Bwdx3QbWNqC8HoA4wj7c7kZvrnlKUMP4f2GVxKZ+G6hQB2PW9j0tozfLcpeFpVTNvydW5fCwNextwMFifSnHwc7YlE+aGQ1QQIL8wth5svsi5A092PWq0HdyMiLSQeYHOGD45OiJhP5BOoxXGQ0X/PJA7YAEDVvRCqgB4l36jKorrikZ/EUgNoNtccaT+0w1+EeGmEnNEAwgQjtW86FiTt3rpL2wv3AD0N3dDB94ILQ+ytjWh88uBGz4wvcdqSoRcJb9PzgjfcRINlD95hd118QBXmj3/az98wRWUJtWv5q8EuCx3R2JBlYDveziHMFKomh47qIOAtG5XtXMYEsyShqtPaIhcitSkWr+VaImvPEbjaCeZLOU2DtMf3QYoNTDOVlz5ImLmbCqQZArvNsObPQSYX3tQv2+IYTtiXcwq/ESADQQoRcT/dLLarmSf+MwxuWraYWUikkTcr7GZu9fY2IJFn6tg1NpM6jp05LA1A1H085AvY1LHjdJbCsfncgSzN4UxpNbQdTdF0jpbFG8XwsIwgSn6Q7qG+QuhW1yxe5p+SFlycRajr3tBAz4C8RqPX6Wkvc5+jN1AbS2d sPFTo4Uv 2QCIYrKux7aLKfRLvlPgjdZuPBLTMihcTP64D39FdANFgKBGyhtJAYO8pNHsw5T5LpcCSB0Z+1kif+FatppP3rN4SSCMDIMP373qjJWJADZ+du2ppoUHUh40JCf0e//5E2elJ/Bx1EuAsQ4oiDlAU8pPXJAD+cu6uQ19HVP+go0Z0Z+uMseumeYmQhi+2Ii7VJXhpjLl7106pbPG9HlbEAPor/rO2uV27xy5i+H5BVN7Uhy3rkj6YQdZ2Zqu5REfZY9fKLwni4JXph3/DyEHOXaB0zWreiNthb/1G 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: Pass struct kmem_cache_args to create_cache() so that we can later simplify further helpers. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- mm/slab_common.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index 16c36a946135..9baa61c9c670 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -202,22 +202,22 @@ struct kmem_cache *find_mergeable(unsigned int size, unsigned int align, } static struct kmem_cache *create_cache(const char *name, - unsigned int object_size, unsigned int freeptr_offset, - unsigned int align, slab_flags_t flags, - unsigned int useroffset, unsigned int usersize, - void (*ctor)(void *)) + unsigned int object_size, + struct kmem_cache_args *args, + slab_flags_t flags) { struct kmem_cache *s; int err; - if (WARN_ON(useroffset + usersize > object_size)) - useroffset = usersize = 0; + if (WARN_ON(args->useroffset + args->usersize > object_size)) + args->useroffset = args->usersize = 0; /* If a custom freelist pointer is requested make sure it's sane. */ err = -EINVAL; - if (freeptr_offset != UINT_MAX && - (freeptr_offset >= object_size || !(flags & SLAB_TYPESAFE_BY_RCU) || - !IS_ALIGNED(freeptr_offset, sizeof(freeptr_t)))) + if (args->use_freeptr_offset && + (args->freeptr_offset >= object_size || + !(flags & SLAB_TYPESAFE_BY_RCU) || + !IS_ALIGNED(args->freeptr_offset, sizeof(freeptr_t)))) goto out; err = -ENOMEM; @@ -227,12 +227,15 @@ static struct kmem_cache *create_cache(const char *name, s->name = name; s->size = s->object_size = object_size; - s->rcu_freeptr_offset = freeptr_offset; - s->align = align; - s->ctor = ctor; + if (args->use_freeptr_offset) + s->rcu_freeptr_offset = args->freeptr_offset; + else + s->rcu_freeptr_offset = UINT_MAX; + s->align = args->align; + s->ctor = args->ctor; #ifdef CONFIG_HARDENED_USERCOPY - s->useroffset = useroffset; - s->usersize = usersize; + s->useroffset = args->useroffset; + s->usersize = args->usersize; #endif err = do_kmem_cache_create(s, flags); if (err) @@ -265,7 +268,6 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, slab_flags_t flags) { struct kmem_cache *s = NULL; - unsigned int freeptr_offset = UINT_MAX; const char *cache_name; int err; @@ -323,11 +325,8 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, goto out_unlock; } - if (args->use_freeptr_offset) - freeptr_offset = args->freeptr_offset; - s = create_cache(cache_name, object_size, freeptr_offset, - calculate_alignment(flags, args->align, object_size), - flags, args->useroffset, args->usersize, args->ctor); + args->align = calculate_alignment(flags, args->align, object_size); + s = create_cache(cache_name, object_size, args, flags); if (IS_ERR(s)) { err = PTR_ERR(s); kfree_const(cache_name); From patchwork Tue Sep 3 14:20: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: 13788789 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 A1B86CD343A for ; Tue, 3 Sep 2024 14:22:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D2DE8D017D; Tue, 3 Sep 2024 10:22:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 881C78D0151; Tue, 3 Sep 2024 10:22:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D3CB8D017D; Tue, 3 Sep 2024 10:22:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 49C0E8D0151 for ; Tue, 3 Sep 2024 10:22:42 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E668D1604EF for ; Tue, 3 Sep 2024 14:22:41 +0000 (UTC) X-FDA: 82523642922.28.7AC0A5E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 192C4A0002 for ; Tue, 3 Sep 2024 14:22:39 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iC8yw4Sz; spf=pass (imf15.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=1725373336; 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=lyceHmOdHcYpPumcL6F0x/Qy6aEh/eoDX6pXPbAt/0I=; b=X/SZnb9H8LfqYmNsW01bCFEtg7KQMBKnbwZMMmee7XwKDSRq4qs6ctue8bF7EP9YejZNK5 4mHq/kb3+zGl6MGn6Tjl/YzoHtEh+diyA2fvPUmD11lWfl/q72K1pwRRX27XHPnP9/47BR mDrMtjY75/TL3ioYpnoaC7/lAz5tsjM= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iC8yw4Sz; spf=pass (imf15.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=1725373336; a=rsa-sha256; cv=none; b=FsWy6MXGHCe1X6T0o7YkWQYur2gUWAuoxVooDSVAb92vXHFGSsf0CsWsjn5AX6pGWcQOQI ASkHX0ziZDRkwE5a3MbcfTv3ULWxg00Klj9qSbJqcdpJRzoqGto0bY5yNih6y14s2/PsLR zcFHub6ZWhin9o6idJ83LO8guSZAtT4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D82B25C5816; Tue, 3 Sep 2024 14:22:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F9BDC4CECA; Tue, 3 Sep 2024 14:22:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373359; bh=NICKa5KUOQG+AjRPua/q+Zy7rozMk7chEiygU85Xzfw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=iC8yw4SzaTmXOI0hC0s8OsuBU5aCzpjtbsOXChYJgSb+rOOw8TJqTrZReqPkClcGK ZNgy01bxU/uKUhxj7oMkaQhQAQx/3DyNu5CeaR/EV1moRwRvMHEMwMUAnyjEI/TDMW skD2yBxQE+vFthDy+IfReCtlevTldr3uCMhDIvE8Z+T4hQhePNd2ER/HHlrrFD/4JJ 0kGkpS2svFTSfpQC/Q40LPhG3ke3P4HRh3ee0tF902OveKbf7i3QXXtYpW3TGeBec6 Vrza4B7lPz457uYQqrZhBLocJthwFr5XglrmZMgfN9bATDcthv/vrHLusm04OqJSJH +goSwi9E619bA== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:48 +0200 Subject: [PATCH v2 07/15] slub: pull kmem_cache_open() into do_kmem_cache_create() MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-7-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=4182; i=brauner@kernel.org; h=from:subject:message-id; bh=NICKa5KUOQG+AjRPua/q+Zy7rozMk7chEiygU85Xzfw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl55TEKXz8vYFK94ZvtNPxHhluBqE8J9eprm0vqG4t aFTqWhWRykLgxgXg6yYIotDu0m43HKeis1GmRowc1iZQIYwcHEKwETUFzAyHK382DX77OSW782/ Tyb0tolO+W8Z9G1hP99sobz366eZKTP8L/Lb0Wjtcnz14nu562PZJ+ZXWnRa+BqwelZ9XbLf9vo 9VgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspam-User: X-Stat-Signature: 3mdktzu6awjedx1t3ofdwhkigzbtff9j X-Rspamd-Queue-Id: 192C4A0002 X-Rspamd-Server: rspam11 X-HE-Tag: 1725373359-460429 X-HE-Meta: U2FsdGVkX195vklx/0seYmhPazXK2ZMaMZG7Y9D7Yf33IX6RtE7FkpJ1++ZwAPhRBW8B1m7eL8jUa9c6MvxSsT1ogE86JuvhRb5zyXgspVD1Hp8m44nieRq3ojl++w+6+TFmflN1/1u6NNZyDszQ/3ewVppXWK7vtrPr845R1aNJg5bQV+ABv3cR6utg8ytuPEsU0QdrlYCOH4s9DolPTdhEVdxqHRPdpfXovlgcFXQ4BTm8rRQeONR1sq/t8lUABOAuzU3VwGbvbm+hzcSRBOjtXad1QAPCoFYnfbY/tv4oMSsxEBs0VWOuo1DXF6rFNuRNvQGssPBF1jJEbBcaOm3Z4xUssO9jfK0sHqx8FcxDcLZZyt4rLAdLCmQCrD8zhD+EkhjNhJNjcM9TRxh9vm0VoKyEHP1RyC+VTFfrPpC15ZjBGumaspabjXlypTr8VJMrsJxq/jineNxTJy53Lqi4ozamFFJmiZnJ1Znl1ffAfHWXrKI/poY0usF3zvRgiRDYDYTIup8j0u5CLLddYDaHEJdKBfQbaHyEubKaBWCY99/xHA0w3tD15/MyExf2PXPVIL/VPx5ph2BeXqgH8p/IvzpRArJsDEygq/niDRxsXsaRN85qidxmxDsXFbX2C2XXi/+3+qgQpc1XFFmX20c35emXBygoCmVcL9UFzFnNCS/QWk0lr6r3uEWBp8/ZZARl5VLzwgLM0HKGKXSnTuWP8V7YhFx0zlmnEVaSoe5zOElReCMi8HTbrT2TjISRfXlA2/SpNXZpoiyfT7roW9DSibH8xjWJxo6LYLgjk9tPWfF1KkR+GASX3U6k3xgNKXmvOx4J2GU64AU8MLRgCD2sMSGdC/6Qhu+tB3INkIqO9JVJgfD41eb18Do/pUuQwT40kclfM4Koo9M+09WCQeXg/IFjuxBoIr/bzksSTdkAOkMgaqiKf2KYdXonCKsa8CkXfx3Uh2mawr1bprl DfvzhFlY BYyEX82c/N5s0OGwf8Gkg5v1SRalzNEZtrP/4UOIrG3TO5hDcHNT+Z7ta5q2+vBcm4Yc8HTHyBYDJQyD7jisMrc7pDjPrViEYHS0N+WVkk9yQ9pZ7/pG1Lg+uWgSat9tjE631K52PVU3vVZ5BPU90gMFTGWJ9Mep9y7rdb5sj/lqKaN9CV760Y8qHBATGsT29r5ACnEtTF/ohG1pzXMtgRnx5MVAIzJl8bzsZ4x72I9K43Bw8NSjz7GcZyjkAtLpoZ4kCtt+OUpf3rSJRVsQxcM1gMDk81Vu05jFj 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: do_kmem_cache_create() is the only caller and we're going to pass down struct kmem_cache_args in a follow-up patch. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- mm/slub.c | 132 +++++++++++++++++++++++++++++--------------------------------- 1 file changed, 62 insertions(+), 70 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 23d9d783ff26..30f4ca6335c7 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5290,65 +5290,6 @@ static int calculate_sizes(struct kmem_cache *s) return !!oo_objects(s->oo); } -static int kmem_cache_open(struct kmem_cache *s, slab_flags_t flags) -{ - s->flags = kmem_cache_flags(flags, s->name); -#ifdef CONFIG_SLAB_FREELIST_HARDENED - s->random = get_random_long(); -#endif - - if (!calculate_sizes(s)) - goto error; - if (disable_higher_order_debug) { - /* - * Disable debugging flags that store metadata if the min slab - * order increased. - */ - if (get_order(s->size) > get_order(s->object_size)) { - s->flags &= ~DEBUG_METADATA_FLAGS; - s->offset = 0; - if (!calculate_sizes(s)) - goto error; - } - } - -#ifdef system_has_freelist_aba - if (system_has_freelist_aba() && !(s->flags & SLAB_NO_CMPXCHG)) { - /* Enable fast mode */ - s->flags |= __CMPXCHG_DOUBLE; - } -#endif - - /* - * The larger the object size is, the more slabs we want on the partial - * list to avoid pounding the page allocator excessively. - */ - s->min_partial = min_t(unsigned long, MAX_PARTIAL, ilog2(s->size) / 2); - s->min_partial = max_t(unsigned long, MIN_PARTIAL, s->min_partial); - - set_cpu_partial(s); - -#ifdef CONFIG_NUMA - s->remote_node_defrag_ratio = 1000; -#endif - - /* Initialize the pre-computed randomized freelist if slab is up */ - if (slab_state >= UP) { - if (init_cache_random_seq(s)) - goto error; - } - - if (!init_kmem_cache_nodes(s)) - goto error; - - if (alloc_kmem_cache_cpus(s)) - return 0; - -error: - __kmem_cache_release(s); - return -EINVAL; -} - static void list_slab_objects(struct kmem_cache *s, struct slab *slab, const char *text) { @@ -5904,26 +5845,77 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align, int do_kmem_cache_create(struct kmem_cache *s, slab_flags_t flags) { - int err; + int err = -EINVAL; - err = kmem_cache_open(s, flags); - if (err) - return err; + s->flags = kmem_cache_flags(flags, s->name); +#ifdef CONFIG_SLAB_FREELIST_HARDENED + s->random = get_random_long(); +#endif + + if (!calculate_sizes(s)) + goto out; + if (disable_higher_order_debug) { + /* + * Disable debugging flags that store metadata if the min slab + * order increased. + */ + if (get_order(s->size) > get_order(s->object_size)) { + s->flags &= ~DEBUG_METADATA_FLAGS; + s->offset = 0; + if (!calculate_sizes(s)) + goto out; + } + } + +#ifdef system_has_freelist_aba + if (system_has_freelist_aba() && !(s->flags & SLAB_NO_CMPXCHG)) { + /* Enable fast mode */ + s->flags |= __CMPXCHG_DOUBLE; + } +#endif + + /* + * The larger the object size is, the more slabs we want on the partial + * list to avoid pounding the page allocator excessively. + */ + s->min_partial = min_t(unsigned long, MAX_PARTIAL, ilog2(s->size) / 2); + s->min_partial = max_t(unsigned long, MIN_PARTIAL, s->min_partial); + + set_cpu_partial(s); + +#ifdef CONFIG_NUMA + s->remote_node_defrag_ratio = 1000; +#endif + + /* Initialize the pre-computed randomized freelist if slab is up */ + if (slab_state >= UP) { + if (init_cache_random_seq(s)) + goto out; + } + + if (!init_kmem_cache_nodes(s)) + goto out; + + if (!alloc_kmem_cache_cpus(s)) + goto out; /* Mutex is not taken during early boot */ - if (slab_state <= UP) - return 0; + if (slab_state <= UP) { + err = 0; + goto out; + } err = sysfs_slab_add(s); - if (err) { - __kmem_cache_release(s); - return err; - } + if (err) + goto out; if (s->flags & SLAB_STORE_USER) debugfs_slab_add(s); - return 0; +out: + if (err) + __kmem_cache_release(s); + return err; } #ifdef SLAB_SUPPORTS_SYSFS From patchwork Tue Sep 3 14:20:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788790 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 7C416CD3439 for ; Tue, 3 Sep 2024 14:22:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9204A8D017E; Tue, 3 Sep 2024 10:22:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 885BA8D0151; Tue, 3 Sep 2024 10:22:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B15D8D017E; Tue, 3 Sep 2024 10:22:44 -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 3B6BB8D0151 for ; Tue, 3 Sep 2024 10:22:44 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E319BC03D7 for ; Tue, 3 Sep 2024 14:22:43 +0000 (UTC) X-FDA: 82523643006.22.10DAF3D Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf24.hostedemail.com (Postfix) with ESMTP id 2F15818001F for ; Tue, 3 Sep 2024 14:22:42 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RsLWeAqc; spf=pass (imf24.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=1725373267; 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=47AOvIePKm4VA+iqk58/MZHnc36sqtLPgyX8VJocIiA=; b=x4aN72ZvYtGmjSH+QER5LglMysbMOvfGU5aPY8gfec0lVu2Ks1+/moavOFSwUO9vwwd8jt DUss/Sm/K1Beu+Eo/7sUDt1xqucCJRdM8XPfz9FogmR5Tj6LyacCjSZ4NlkqNXVhK2awg1 aeR9cni6WFHGYFx8S7UB7B5bg/NFBfA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725373267; a=rsa-sha256; cv=none; b=Yv6hcvF5FrNu06XLBV/yOUXHWrh12Se93Jm4mXG4UBHq5yvfn3e39AYnr7r2TNr9/ZIKct bTjAcVfVvGQM5q3+23YxfW6xVmUumbJcoH06xYk2umZZT1TTirR4ZYafvjHDosLdB4z+yg ADO4dp+AyojvyxKBcwUQ/T8Lr/cPyXQ= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RsLWeAqc; spf=pass (imf24.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 64761A4367A; Tue, 3 Sep 2024 14:22:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8786DC4CEC4; Tue, 3 Sep 2024 14:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373361; bh=LGtj/e6uWtTAC/2FfRENwjsuEXl8qpeXQfpfD6hAo/g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RsLWeAqc+DgpjX7fIXp3seQzC7Jou5QA3YNKQA96AB5ngZNz4PJaisGMq3sCixh5r QOgA1QJdHZQNaRLR/leMrddYpzKBCE8vWScxNK+YiFqISZSXv84tau6h7mXHEVcpr0 HJYqlDlVWjsSc0SNm9i+pXjDw6ODPRoFutRQQfM3i/wA8qynyXkDQggEHsE/XfNbm/ mjXtmxEjDfgHqwCzhhcHS3NajIW1E/l41DICazy+Jl/afIq9+LHEEQ2buTp2tP1QlJ 1FKl0p/6/MdN+LRySJdd4+H+ILs5xRe5Gg8ifJHwc11AtaWaRaI8iB+luaLgDbU7YU N8CBqhbYiO10w== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:49 +0200 Subject: [PATCH v2 08/15] slab: pass struct kmem_cache_args to do_kmem_cache_create() MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-8-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=3814; i=brauner@kernel.org; h=from:subject:message-id; bh=LGtj/e6uWtTAC/2FfRENwjsuEXl8qpeXQfpfD6hAo/g=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl57zp/8H58sZpdqnOv5v877EcHrts//a9Txn2or0d 272eOaU1FHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjCRDW8ZGTrXHOfxNkk++6Bu Ud50/7Xu9itYrLle9Rboh6fcuH56Axsjw7cazcD7wjNt1i5aLMG87YLj89YNW27YnctQMQqyfjp Bnx0A X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2F15818001F X-Stat-Signature: rtgyk4xechtrx4qdxh773g88ojt8tu5o X-HE-Tag: 1725373362-724436 X-HE-Meta: U2FsdGVkX1/5LkKXp6V6R504RCUSV/lrfmochRzNce4VNHtVq7XUEYc3gpKdSiMCrUsTZyLYkEXxPyrBy8LZv+ZBTmjfaFomApeEV4ASlouzbZsjfTafg5Sqr/nd6WXLHJ6+t+Rl2PmF1whD1072LOejUAYqvSHf1dMkoU9PA1VYH5mi3qgNEf+Xr8OdiIZUmji5IeVgpFPS4O/IHMjA0t6glyBIR+Uaw5e294aEkfKm5x2WgEYzWsqn1tp+N8AFc3NX+QfglFsKZPnLEKVE5I7WUWeeAAHJvKJ5ifIbGzJxonjK7ti3j0jz58LqOR/JRPsBKnqV0t40GJmVQOGUJxYN85yiKu2DKqYqahhxoMw6s5u3rcnLuMrFTEWXjf4GBH7FcgOyy1bYqFukIwLZla0Vcv6IuPG426WQfiNCeJRAB5CeDbAJ1wYGEEsJYoHZ4kVjIp4ddAucf5YaOXfMLewjiFIrprlCyEl1HEMLkDTfyEzEeMX+kQmScIWHaD0d+YV0Dt5PBOzc1PDFtObTHqOSrMgztNHm59+7+//zKd3W+u9v0vOxwQi+cRXv+vPnxiysANVZlsKt5+gLGNwtLUTesxvlJIUt1xfM5zK8i9sq8FR6iY5oeMhiF5BSHUZuC8Bkxste/TKSDG7sGbBup0045pLYE3rcscexq3xBMzA/ZojZ6VYS2uhTZlRtC698X42WYALAXRM58+ybIdyEP1EjfhsMh1aohTKpo+tDvx3vsG0Ml+kPJcNBV0D6lPIR7rxgihNtVXBd0orGz/NJq7IAraRlUNw0h+QgpFdPNhptFLohItM67h3RDGY65Y0pTF/beqJE9iFTHlsGokY58oF3Hl4I8kEIJxnVmvv3kVOotKqtCrHQRZFVx4jPPLnoNwQc/xiTvNaFXggD2ePLVWdw5JfRgNJmpW+jQ5kh9XgBKOkcQHltRYxYHNtT9hy+x/yE5vwcoJ1/yNWhMKC E6ZKZ5gl Viwstd8wj4QVOCychbARtmAeksGuHjtZG2eihApSrtmCsvdZ9rvT3g2KYJu06ogor+ubSQ5C5PXOXU3fj4bkCW+DFkNxbyx7M4pwTXDGSfWAfq1porqgByPTGwZaj7D2jwWPMzA/7zWfWYsHJ0Qp6CAQeSVJ87oJjU3fd5xGqmINcLzppvf28FhR8FbluywOT2iXHaf43HInYcyWClOMRCaEyMc+PYZ2/vyyGJyUyD4hWm82ilsivaXtimSuk+i/+I4Km19EQoCXqtGBV7or83vezV9uzTh4a/10Y 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: and initialize most things in do_kmem_cache_create(). In a follow-up patch we'll remove rcu_freeptr_offset from struct kmem_cache. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- mm/slab.h | 4 +++- mm/slab_common.c | 27 ++++++--------------------- mm/slub.c | 17 ++++++++++++++++- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index 684bb48c4f39..c7a4e0fc3cf1 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -424,7 +424,9 @@ kmalloc_slab(size_t size, kmem_buckets *b, gfp_t flags, unsigned long caller) gfp_t kmalloc_fix_flags(gfp_t flags); /* Functions provided by the slab allocators */ -int do_kmem_cache_create(struct kmem_cache *, slab_flags_t flags); +int do_kmem_cache_create(struct kmem_cache *s, const char *name, + unsigned int size, struct kmem_cache_args *args, + slab_flags_t flags); void __init kmem_cache_init(void); extern void create_boot_cache(struct kmem_cache *, const char *name, diff --git a/mm/slab_common.c b/mm/slab_common.c index 9baa61c9c670..19ae3dd6e36f 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -224,20 +224,7 @@ static struct kmem_cache *create_cache(const char *name, s = kmem_cache_zalloc(kmem_cache, GFP_KERNEL); if (!s) goto out; - - s->name = name; - s->size = s->object_size = object_size; - if (args->use_freeptr_offset) - s->rcu_freeptr_offset = args->freeptr_offset; - else - s->rcu_freeptr_offset = UINT_MAX; - s->align = args->align; - s->ctor = args->ctor; -#ifdef CONFIG_HARDENED_USERCOPY - s->useroffset = args->useroffset; - s->usersize = args->usersize; -#endif - err = do_kmem_cache_create(s, flags); + err = do_kmem_cache_create(s, name, object_size, args, flags); if (err) goto out_free_cache; @@ -788,9 +775,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, { int err; unsigned int align = ARCH_KMALLOC_MINALIGN; - - s->name = name; - s->size = s->object_size = size; + struct kmem_cache_args kmem_args = {}; /* * kmalloc caches guarantee alignment of at least the largest @@ -799,14 +784,14 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, */ if (flags & SLAB_KMALLOC) align = max(align, 1U << (ffs(size) - 1)); - s->align = calculate_alignment(flags, align, size); + kmem_args.align = calculate_alignment(flags, align, size); #ifdef CONFIG_HARDENED_USERCOPY - s->useroffset = useroffset; - s->usersize = usersize; + kmem_args.useroffset = useroffset; + kmem_args.usersize = usersize; #endif - err = do_kmem_cache_create(s, flags); + err = do_kmem_cache_create(s, name, size, &kmem_args, flags); if (err) panic("Creation of kmalloc slab %s size=%u failed. Reason %d\n", diff --git a/mm/slub.c b/mm/slub.c index 30f4ca6335c7..4719b60215b8 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5843,14 +5843,29 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align, return s; } -int do_kmem_cache_create(struct kmem_cache *s, slab_flags_t flags) +int do_kmem_cache_create(struct kmem_cache *s, const char *name, + unsigned int size, struct kmem_cache_args *args, + slab_flags_t flags) { int err = -EINVAL; + s->name = name; + s->size = s->object_size = size; + s->flags = kmem_cache_flags(flags, s->name); #ifdef CONFIG_SLAB_FREELIST_HARDENED s->random = get_random_long(); #endif + if (args->use_freeptr_offset) + s->rcu_freeptr_offset = args->freeptr_offset; + else + s->rcu_freeptr_offset = UINT_MAX; + s->align = args->align; + s->ctor = args->ctor; +#ifdef CONFIG_HARDENED_USERCOPY + s->useroffset = args->useroffset; + s->usersize = args->usersize; +#endif if (!calculate_sizes(s)) goto out; From patchwork Tue Sep 3 14:20:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788791 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 45F82CD343A for ; Tue, 3 Sep 2024 14:22:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBA318D017F; Tue, 3 Sep 2024 10:22:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B19118D0151; Tue, 3 Sep 2024 10:22:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96C198D017F; Tue, 3 Sep 2024 10:22:46 -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 771758D0151 for ; Tue, 3 Sep 2024 10:22:46 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3121F16049C for ; Tue, 3 Sep 2024 14:22:46 +0000 (UTC) X-FDA: 82523643132.14.73BB533 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf13.hostedemail.com (Postfix) with ESMTP id 6A87520011 for ; Tue, 3 Sep 2024 14:22:44 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZIqDi3Qn; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf13.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=1725373294; a=rsa-sha256; cv=none; b=OvCTdM/vvcXAoLqFNFesGECLtFKeTWHJTZ817jwXIba22UM6+4Xvdx7mr18B7l+9/siu3I Fwud1YOHZv3uVD97rAynOCpsGXNEIyiwsy7MNJjcZnvUYaPj7XZQHZcR+JpfajjV83qU3k qpYJ99SQlHGSbyWNqWD8IQWwTQ3s95s= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZIqDi3Qn; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf13.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=1725373294; 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=siTqtc1OnM67NaS3OzQvKJYHjkGXxYArN7ctaraJEz0=; b=1b6gDYUtTLSyzDEghVRRhO0/vy/KDBdRLx42tjKp+XzM1UmgLZhAhBXnAGpwkg16MK+gs9 Fz6IEsInFiMkWH94as/xTSa9m3De3r20x2CLEZfmS3x0/6WdZxBZ+qlHhBy+t/YSzoaK0V SrepGenTuBCvZry4sDGj9KylMwMfNMA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id A2489A43677; Tue, 3 Sep 2024 14:22:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE620C4CEC4; Tue, 3 Sep 2024 14:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373363; bh=+kTwNa1m6b/Hnr0YtIDtx0q9W42j7lzgwCx+jUzI5rs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZIqDi3QnJT6V+K28/jD+UNtuaEDHlnJWqYR8lxhqiapVrTdtG0h22hWUu81vD5O2+ jXFZjjBzQ8TZLgYQuZUDqWdgcND9G8Rz9UOfeQPM2XeImc+frsoPSL6onkde1jl1tY VAHgG1WziE9j9W4rFM9UIyvhpxLFqaxvTZkQ6SCPA8Gu4Mjyk55DAavUexXA9nChen uI00cTePs9fVCgmjPnmJbiR3TTTuRimy87cmxjPvCWtB3zu5XJAE3ncQJwG/bdg/RC 6t2651rDtNYBxxp2lsxTdiw2E/iwWxq/nt4y7EyD2YVjPFboFkKnXucewOKJb5i21q 76YuSfJsqpdfQ== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:50 +0200 Subject: [PATCH v2 09/15] sl*b: remove rcu_freeptr_offset from struct kmem_cache MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-9-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=3722; i=brauner@kernel.org; h=from:subject:message-id; bh=+kTwNa1m6b/Hnr0YtIDtx0q9W42j7lzgwCx+jUzI5rs=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl57jvoPX02rSPSWTt/ddD73463HOrSVxeqTj4aOzw 5g3SP541FHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjCRBysY/unOE+Ll3uq9eeUC ieve17+IL5eOKJ3Vxv1pX/e6yVsDmu8yMvy9e2/elMKab78eFp99eugk338zkZNyMxfOisxszz/ 89zQ7AA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Queue-Id: 6A87520011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: k4og8rhfdjwo8aht9y3wu7pa3drexfg7 X-HE-Tag: 1725373364-237585 X-HE-Meta: U2FsdGVkX1+gQU4DxYwFYjpREl6uUtEhPfkvrNUyuVDSPHqSSisWklqRv7GAY3JtuWZ8+a+yEhwWicnJQG2EbtBG4/KFcd1UH8LbwXFO8wtJPRAUU6oN7gM77xbG7SKv2czeG05eQC0GRG+F+yxR8t3wtSFjwrF7BzfcRs92JTU+ML8l9mqExhSM87K/BMc+l/W1F2tylr8lUTXIWyvToJ7c9konICKOD211nPEwS5Q2f0IqEr1/xaHHfKOhYiTjI2PmLmYHvBSBkGB827tvs6szOx+X5Lms4xN4EKciwujB6/t5UEincA0bqsc1cI5JpdAS+MXuRN52oIfT8d8gx7ba/nBSZ0fFy/HyvVy/K9kH3eI1LP5je1hyrR9XpODpTTVau18Qg6Oq1uJpd4YB6uGGz4xG3riY10FQ4BNvbx7oTM0vZWqiSxtpQ0gDEKfSYvB30CA9kOUKuAb9zXnnij3sSMCW1FSqlxQMp00kI4r1l5pJ//MianTChLgMUn9PbFOvJpzSx5wkJpIL823hGw4DSXAAFh8xRs6Jhy7n49hllTVSiCUCdmo6FikwJLVsO7bh6YjXxiz4A9Ei8A2eXbgde43WcPfLTpvPhshVwC1dGuFmHvElHm8xbfF3LdC6DNAgg6UZxQdNmI87lH3hrqtuJSssAqJjpnYin/UBxRNXXixux+UmuiNt+9/JqUuiMBOgCiv70KaAfKtFxEqosmiqKt0jal5n7zAUsbLonJFE3JvDDhEyLVhyQdUd91oL/eDzRuajA9QI5LuIQ4Bcw8biaBIoLQTupuVPF8El2TaamuapQ/vmoGJ7NrIRlIco5mCsDlX7B+JT2acuH8jIOXDFWCqBItPlzxebmehfw/sacSb6t8soRWkO17eToRg3501FPC5VZ24K8XdIMKd4OB2QUKoHVGaCCYZANCSUlZ0YDQc7T5ssRqPLuH0vyXC45EDIEqFRRUKCMn9DgS2 h8uOnXUv qJViEtoAvhD0lU1tmoKIC2iQpXydAdigNc+fJ+5VXhe+VeBheXzeYgDmNfreKc0SJVFE7WP+7NAc/gQylR4WWyRlEaUyja1XGbsUJMAFsFoy44cEtONL+zhI0WAgnJupgOky6NYVtzWuaA8Q6FHYnM3XWECQOLirx0/dnJYXPVwZ6khd3pXsH43mYrSgjrbLVmx2zBa5eqfNHNPaYprdBSzZcagwLuqSjbtAgpboT5Ehj8QO/KXJpVwVqCAWHaAPB8x/RTLDTzCJTGFTKtJzgylN5v+VP8E+cfRPAMJX1ltZWQ1hMqnEjx95oKlorvkTjMgR5 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: Now that we pass down struct kmem_cache_args to calculate_sizes() we don't need it anymore. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- mm/slab.h | 2 -- mm/slub.c | 25 +++++++------------------ 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index c7a4e0fc3cf1..36ac38e21fcb 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -261,8 +261,6 @@ struct kmem_cache { unsigned int object_size; /* Object size without metadata */ struct reciprocal_value reciprocal_size; unsigned int offset; /* Free pointer offset */ - /* Specific free pointer requested (if not UINT_MAX) */ - unsigned int rcu_freeptr_offset; #ifdef CONFIG_SLUB_CPU_PARTIAL /* Number of per cpu partial objects to keep around */ unsigned int cpu_partial; diff --git a/mm/slub.c b/mm/slub.c index 4719b60215b8..a23c7036cd61 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3916,8 +3916,7 @@ static void *__slab_alloc_node(struct kmem_cache *s, * If the object has been wiped upon free, make sure it's fully initialized by * zeroing out freelist pointer. * - * Note that we also wipe custom freelist pointers specified via - * s->rcu_freeptr_offset. + * Note that we also wipe custom freelist pointers. */ static __always_inline void maybe_wipe_obj_freeptr(struct kmem_cache *s, void *obj) @@ -5141,17 +5140,11 @@ static void set_cpu_partial(struct kmem_cache *s) #endif } -/* Was a valid freeptr offset requested? */ -static inline bool has_freeptr_offset(const struct kmem_cache *s) -{ - return s->rcu_freeptr_offset != UINT_MAX; -} - /* * calculate_sizes() determines the order and the distribution of data within * a slab object. */ -static int calculate_sizes(struct kmem_cache *s) +static int calculate_sizes(struct kmem_cache_args *args, struct kmem_cache *s) { slab_flags_t flags = s->flags; unsigned int size = s->object_size; @@ -5192,7 +5185,7 @@ static int calculate_sizes(struct kmem_cache *s) */ s->inuse = size; - if (((flags & SLAB_TYPESAFE_BY_RCU) && !has_freeptr_offset(s)) || + if (((flags & SLAB_TYPESAFE_BY_RCU) && !args->use_freeptr_offset) || (flags & SLAB_POISON) || s->ctor || ((flags & SLAB_RED_ZONE) && (s->object_size < sizeof(void *) || slub_debug_orig_size(s)))) { @@ -5214,8 +5207,8 @@ static int calculate_sizes(struct kmem_cache *s) */ s->offset = size; size += sizeof(void *); - } else if ((flags & SLAB_TYPESAFE_BY_RCU) && has_freeptr_offset(s)) { - s->offset = s->rcu_freeptr_offset; + } else if ((flags & SLAB_TYPESAFE_BY_RCU) && args->use_freeptr_offset) { + s->offset = args->freeptr_offset; } else { /* * Store freelist pointer near middle of object to keep @@ -5856,10 +5849,6 @@ int do_kmem_cache_create(struct kmem_cache *s, const char *name, #ifdef CONFIG_SLAB_FREELIST_HARDENED s->random = get_random_long(); #endif - if (args->use_freeptr_offset) - s->rcu_freeptr_offset = args->freeptr_offset; - else - s->rcu_freeptr_offset = UINT_MAX; s->align = args->align; s->ctor = args->ctor; #ifdef CONFIG_HARDENED_USERCOPY @@ -5867,7 +5856,7 @@ int do_kmem_cache_create(struct kmem_cache *s, const char *name, s->usersize = args->usersize; #endif - if (!calculate_sizes(s)) + if (!calculate_sizes(args, s)) goto out; if (disable_higher_order_debug) { /* @@ -5877,7 +5866,7 @@ int do_kmem_cache_create(struct kmem_cache *s, const char *name, if (get_order(s->size) > get_order(s->object_size)) { s->flags &= ~DEBUG_METADATA_FLAGS; s->offset = 0; - if (!calculate_sizes(s)) + if (!calculate_sizes(args, s)) goto out; } } From patchwork Tue Sep 3 14:20:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788792 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 A05C8CD3439 for ; Tue, 3 Sep 2024 14:22:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F2D48D0180; Tue, 3 Sep 2024 10:22:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 17C568D0151; Tue, 3 Sep 2024 10:22:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE9928D0180; Tue, 3 Sep 2024 10:22:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C82978D0151 for ; Tue, 3 Sep 2024 10:22:48 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 86753C03B9 for ; Tue, 3 Sep 2024 14:22:48 +0000 (UTC) X-FDA: 82523643216.01.2800341 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf08.hostedemail.com (Postfix) with ESMTP id C4BA716000D for ; Tue, 3 Sep 2024 14:22:46 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tKQpFLSf; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf08.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=1725373343; a=rsa-sha256; cv=none; b=YolOswsis78Zud7MntMG+/LFeZeQ5iMZZHwvjDNbMSQI8oksaT4uTg3Ywg0/YP2KE5JFF3 maZ6SUz8gEif/oCrR4tTb/DvpX1CSYYCLZ3o0bep3tvtXRGlcFk6UUe+X/VpgPaa38A0sH kRHcXB3naWl9JdKEyHm2+etepFXCKwQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tKQpFLSf; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf08.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=1725373343; 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=NqT8l9iBbApRr428ZhSfeRf/6VErRQPorn9MViO0YRQ=; b=PjXBUwnZjyTNvd0mBfeEsbKPwKRM1oqJqSPLQuCG1vg2e6xmLtKGm9CLt46fiEeZ0nhNyU WIxTayQ1B/nsuVGTPct1PY2GsMFpMXT96GZe5/i6mUsOGcBv6RT0CNX6e6hAqpMES1o3qK LpmmEbNqEm6QuPnrds9m0S66sIDCJKo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id F08DFA43662; Tue, 3 Sep 2024 14:22:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F330C4CEC9; Tue, 3 Sep 2024 14:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373365; bh=FR8F1qZbTb9zJTJgS+qNyN7qWMc09eHWUOjOyojvTgI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tKQpFLSfOXlziqcKn5RJLf9QiXJle0j40hcp8DAm2CZ1lv7nJtGL/phOIBav3PgIC lzdqEzEIhBfOm9AkvzY8eEKDiqdCLYQRCba9BYeFluRTZu9ju2EG8PJs/3cRxadAJF uPt/sGkTf1PyIhsEyxIoMg93KIak/gufudOUMg6FnObWCiaPK+LhWaxxIOE8PfkZEK Yu1wpiF4B94Q70AdFf0K6xv1dfOL3lwkGQmfvouRoV1y4ToXCfTiz2pajuDM/1AXke o2xlUd2qOCKEUaRipptLB6XVHbDhp/nQz88H6MzqsGe25WNixmOeeB16a0EZn0mwC+ 9YFW6udqq4n3g== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:51 +0200 Subject: [PATCH v2 10/15] slab: port KMEM_CACHE() to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-10-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=1112; i=brauner@kernel.org; h=from:subject:message-id; bh=FR8F1qZbTb9zJTJgS+qNyN7qWMc09eHWUOjOyojvTgI=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl54TcJsj42vuU52ix9cm7n+RpX7vt0mi8vPZK59N9 mXqMBMW6yhlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZhI7xlGhlPX6wSmfa2LrRe9 f1Cu5+Prxe6Pbt0KtAqYwrF0fbL/1QOMDBdW/dzeJ5JSJeH+/mJSfZTb+vkfVf5WLjYunOaiZRj wkxMA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspam-User: X-Rspamd-Queue-Id: C4BA716000D X-Rspamd-Server: rspam01 X-Stat-Signature: 6wm87qecn15cwtrzz6i96ne1gg1ineoy X-HE-Tag: 1725373366-79708 X-HE-Meta: U2FsdGVkX1+jNUMlcabR35GxgAaSL6kX0crxNctF9hVcCghD3GziDi2NuUPi/lULIJ/NpBkBjRoee+ObKBx0R8pu4CKEFbxJTgbAe1yihCQvnHWN08ItXD6m8Hc0PI3QIA9J5aT+4nXGKjEZfiMBHj3CQcmeOfyaZvLY/DFycPfY1ZUT7mfChHjRc0BFaCHnfTGuU4vX6gyL6smhAYYyccZGVAbAmkkVa87csEc/1WpU5kyaUTMqrUKv01BHTq0rMPm1a6nQQbq3aJXuaxtuzhc71/VL4LnPddPKGRtd+P155/6+a6504OeYpEFTPd061R8O4UfVjwZAOAUiJGsVytMNkFZcCJ5fpsA9b6ZUv4ua9SGjRpLeZveITH/3FJzB/Q+24FVXhjYDbwKmDI2JJs+uFek928FkEdJUqySgTk4oy21rOW9vvd7IUk71P6p3f73bnsTvfXIdXLSjQf1daaXZQJS2bMVuGmISto0df+Cn1EJ1K5AbzGqgeE4ywq1w7trC0CGCdWOTICInMcqduhRRbvgnLcLmWVgZEskw3gl5cb2YPTdDVtbOcY6HX07U5gNt8xdG+5kPgmvoPTppKvhXm8Sc5SGNHE5gztxau6GjCNDnSt92HZw1W5FKA5GV7iZhDGFrhEse/r6UdkGjqexZPOfabNKmdxr29U7ID/XI+oXIr0km78/enjSjJEZ6doEbJ44ITxx/HnT/8/B4I68K9mIwB3v6ad5CymBpdGEPxPfe7FqO8rcPZibsSvglpMjn2mE8EESxQ0M+V1ovlHqOfO5sjGTiT4NnJzrrS11qeR2VKaznOLJqm2C4OWc0gtgddCdvwoGKRG/WO/EsHa5uGWIaAAE4F2zwqu42xSX8RuyKCBBnGlQxc0QThxBKvglo2MQUBf5EKSVPeMlXOUh7Q9c1d3z/g2NbPlz11te2jZNTp92VmMxFWzqxlrAbfRiKEO+7myKIEJvv5Ex IiXVepQo 0t2v+6SnNs3Wq41zzqzwKzG0YywVQ62OmBAldol7tqVQRc3Ch/F1blrzJV97No62RMg49lb8/wQF9JuRTBw1DtQpjqlzOG+3UuhyOcyRCsbIyJO8Pnx9nlxDsatoVDmyCJ1u3EYbnSiSr6oHEldMlQ/dTcyKN471XZYOAq45UJH/clQR0Ava5ku/MNxG0pyPdC9qM8E9wSAs/0Rw8vF8gQATrRy4EnWyEYNrH09Oyi21h9pCOIA91giehdSeR80blEPw70S725ptKONvLCi2+2hPGehLUqaiD2+XK 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() use struct kmem_cache_args. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- include/linux/slab.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 79d8c8bca4a4..d9c2ed5bc02f 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -283,9 +283,12 @@ 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_create(#__struct, sizeof(struct __struct), \ - __alignof__(struct __struct), (__flags), NULL) +#define KMEM_CACHE(__struct, __flags) \ + __kmem_cache_create_args(#__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 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 From patchwork Tue Sep 3 14:20:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788794 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 DB0C6CD343A for ; Tue, 3 Sep 2024 14:23:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 180898D0182; Tue, 3 Sep 2024 10:22:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 107E58D0151; Tue, 3 Sep 2024 10:22:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9ADF8D0182; Tue, 3 Sep 2024 10:22:53 -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 C72768D0151 for ; Tue, 3 Sep 2024 10:22:53 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7E9E3403A8 for ; Tue, 3 Sep 2024 14:22:53 +0000 (UTC) X-FDA: 82523643426.29.B65D980 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 9AC8740010 for ; Tue, 3 Sep 2024 14:22:51 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GI5fCg6w; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf12.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=1725373301; a=rsa-sha256; cv=none; b=JNHa0vtX95CAM7ayPzanyzXixbeZRigEPKLiwgici5NPMPxj3Wc+Tr27Fja/dBkfrf0J3w NRuP5Yw5gMy8IkaBYugw7UvNPRrpRIWt6IprNzQ+Lxmv/bbjVds7b8OeOu+ErhNrKEV4Iz S9EKigW3avxRzJnlapUoJSPeV2hCNgE= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GI5fCg6w; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf12.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=1725373301; 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=098223J6o1UJ5gzt2sRXc0SWREJnk526v0CgA06M5FQ=; b=MSmyehGi//mFTjSCmZ06USObGGLmwV//PLbxHHVkmDKJaoegjlWnfRR7W2jPwqxpakp0Xk lODHF+UM7Ynt31IMwoccQzkcn9l639M4ymgO2ZLEQ2XASE2aPc+Iho6lL+KmEiGvaqNAMn zKBJ9GTb7iseWNgPlL0znda178+96FA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 64D625C588F; Tue, 3 Sep 2024 14:22:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E9E3C4CECA; Tue, 3 Sep 2024 14:22:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373370; bh=t7al+h/ze5pARsr5Uki/kfE3prWidx+wEHKqUnyvBao=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GI5fCg6wE9JAbDFx38ntWbqoJ4WArMJXqs+IUMdUmibbQuKyzYDFU7hPngI66qys1 84hwKKRC0v19spyU7/Ipnv6ToPmsngH01J4aNuWZq+PqtCMZRclX2BEVtyRnXhuao8 fh95UuYYzzM4XjhZ7C/bRmv+10JsT54xgRGHRplcXiB21sYmQ0IYu/ePK7b3ul9xOC bVE1u96ZUhjkwFEFNiTs9fLMZbW45mYXTlJISeY08zRLxaBOtGu8yk6hXqlyYtCPqE 2vdul7RHzgcegdYpsD1x+41OOCNSIGvPIrjkKRkOYS089YiaU7mGycV1dG4FvFdDfA gLl9qU5veRI+g== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:53 +0200 Subject: [PATCH v2 12/15] slab: create kmem_cache_create() compatibility layer MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-12-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=3268; i=brauner@kernel.org; h=from:subject:message-id; bh=t7al+h/ze5pARsr5Uki/kfE3prWidx+wEHKqUnyvBao=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl57ze9V/3sgcXvbTlm733/ZNcmz8HvPm6rLvVVH3j H8EMYe97ChlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZiI6muGfyoS11b0Juc8q/Gb ynZ2SvHzuLkblG8F3Fh+ekXt4eVT0sIZ/pfzhm3/rHB5W/Mh18BrNztnn33+9KO/V8eEkCMimUK 68/gA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Queue-Id: 9AC8740010 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: rygktd5b3xkfpcdp3n5hqqqtopufbt7r X-HE-Tag: 1725373371-482275 X-HE-Meta: U2FsdGVkX1/mk1UduKDOa+QoxtBg6EIBbgml88T4Ni4Q3J8auliUOzW8CoCtA/LFebeSjfsdmXJx+ov9pcGPnvK2fjIMuxFgv+H+KxUBqDS5uazKtKZBJp6+rqUYRPW46IwIIp8o19iHdzf3pTNEmUIoUsMbTcd1paK7woOmn5fxe6uIUyFLv9+TgHEvRoVmKKO02uhhdNOysqGGmz6AF2FIcEyPEzMhzDgQMt/A8hD2eo7qdgA+VezIHgaplkY/TmiaxS/Hypyt7V7aeiCoCw+ziix6z3avaZmZufbAj80zkfKAtwE/lExAdFFJY+3xRvQvqVCYgdp4dgLGLvxvWa6oBer5uzBoCytxW6BrWXD/hrtgxmG76zWR7rEGdwSOiK8D5gvGjZY55mOS7FEM3VsjmOUyJyIz0sD3NftvNpe80ZP/AI12XfMZmEcla6qhKZh/PurjKHY28hcCsS+uhfQUwfpjOlqzzmTEuPQQGyhJZbirhu+6ZEd01jb8AzMz5TS6kRNm6EflIys33LTYXQ4LJSPMZEKdpVzeKTJdl6hO0gz57VIcAgWhEN1dbQmEi5IkcwEMv3Tfa1vP6/2gspv/iurUJr3eZ4V/Tbj2gEalyOqvx8rHLlS0I4s6bh9HyIRK3xp22A4znMIPd2SW5PZl6j0fPi5unFhXxJiIrPOevASY3XnnQZN37Dlw6V5YbX0TE1gs6xbcVC8Cn0KTWNRf/rCLPFRG6DmaEVdqyUhVWjUKV3HeuOhbfjrOsYTPrUy3Vq5pu/n8u3Stuzy4L/kcCLS8EzFcMHVyjDMq0LJ2wCheFQOqHAsrpgbX9FirkS9Zq0SCShSkDLyyjVq+WAgkDGc8XvFLYsRhmC6Lh0afQKj9Qjx+F32PDS/A7BnCNSdKFs1Pe79zg+pXk1bF98spr0pGZT3DNDY4zqttJXHs49V2xcuJ3IwfgGJuP8DtM034f+WrmUc4JLp9Fdq 6rvm/lGo eb0XoJsmwON3ZCaOKXnm2Y6XhIjPyz/x8hOnpjaUjsPezYmTk7m8KzUGDiW41YiYXbmI71BlWJBLlaW/Lvy7P3H57JK5Mqq/CS8Zx2/v1TypL8unwmY20M+XILHnPuLq6yXePj4vh9HpaPCQnrOcnZnE4LJeyv1CENoyRBprq3pTS7U0hTWFGXUBppylovwZyU0heyEQVGzD57RVUgFtneKqrAXZT/oxRFLGD3tZ4oukujaf03t5JxN0mWxk2SGMll4S0L8I1TSG91OcEHmmj5QGmhkgPzB9KYstc 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: Use _Generic() to create a compatibility layer that type switches on the third argument to either call __kmem_cache_create() or __kmem_cache_create_args(). This can be kept in place until all callers have been ported to struct kmem_cache_args. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- include/linux/slab.h | 13 ++++++++++--- mm/slab_common.c | 10 +++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index aced16a08700..4292d67094c3 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -261,9 +261,10 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, unsigned int object_size, 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 *)); + +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, @@ -272,6 +273,12 @@ struct kmem_cache *kmem_cache_create_usercopy(const char *name, struct kmem_cache *kmem_cache_create_rcu(const char *name, unsigned int size, unsigned int freeptr_offset, slab_flags_t flags); + +#define kmem_cache_create(__name, __object_size, __args, ...) \ + _Generic((__args), \ + struct kmem_cache_args *: __kmem_cache_create_args, \ + default: __kmem_cache_create)(__name, __object_size, __args, __VA_ARGS__) + void kmem_cache_destroy(struct kmem_cache *s); int kmem_cache_shrink(struct kmem_cache *s); diff --git a/mm/slab_common.c b/mm/slab_common.c index 19ae3dd6e36f..418459927670 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -383,7 +383,7 @@ kmem_cache_create_usercopy(const char *name, unsigned int size, EXPORT_SYMBOL(kmem_cache_create_usercopy); /** - * kmem_cache_create - Create a cache. + * __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. @@ -407,9 +407,9 @@ EXPORT_SYMBOL(kmem_cache_create_usercopy); * * 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 *__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, @@ -418,7 +418,7 @@ kmem_cache_create(const char *name, unsigned int size, unsigned int align, return __kmem_cache_create_args(name, size, &kmem_args, flags); } -EXPORT_SYMBOL(kmem_cache_create); +EXPORT_SYMBOL(__kmem_cache_create); /** * kmem_cache_create_rcu - Create a SLAB_TYPESAFE_BY_RCU cache. From patchwork Tue Sep 3 14:20:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788795 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 990A8CD343A for ; Tue, 3 Sep 2024 14:23:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3A568D0183; Tue, 3 Sep 2024 10:22:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EEB618D0151; Tue, 3 Sep 2024 10:22:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D62CF8D0183; Tue, 3 Sep 2024 10:22:55 -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 AE8FE8D0151 for ; Tue, 3 Sep 2024 10:22:55 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 745A0C03FC for ; Tue, 3 Sep 2024 14:22:55 +0000 (UTC) X-FDA: 82523643510.03.C29FFEB Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf11.hostedemail.com (Postfix) with ESMTP id B9F0B40035 for ; Tue, 3 Sep 2024 14:22:53 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="YuWuHWX/"; spf=pass (imf11.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=1725373350; 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=VH4A81EcWeI7SjiZUTFfJdLq0A4n/ig0LZiMLrKE94g=; b=aI/mwFCb8G83HZ+W4UIw7dW/Cu/n+LmLi9lBA70miNov3RM+dCSgkt7vdlXffcnEvq+tZ0 QOQwwziTnPxnfCrkTE0BuBJW2lYSq07146gkfYloPY0Nxhi/fpzJox0eUaLt3XKsCk0HtJ kPkNrWeLEuqc2DlWuar9RQtJiqrDjzg= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="YuWuHWX/"; spf=pass (imf11.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=1725373350; a=rsa-sha256; cv=none; b=K+9c14ejJvrvsV5BxoffnQCqrORuyUD1QTR+PyHePXclh0Yo8AfKHAXFMWGV64xNFEW7Ep XZHKe8Yoscx6+giPqCrnuAkAB4xIdexfyJti9MOAEESOuc2H8TISJplHp8YEA3FZRN4oFM oQYbqv7x/d1vmhzuz5Na9aOpdCYOOQ4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id EF563A4363C; Tue, 3 Sep 2024 14:22:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0689BC4CEC8; Tue, 3 Sep 2024 14:22:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373372; bh=CebY+vup8RjtcJO3CTsKAhV3jVPnEJg6xeCeD64qYmg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YuWuHWX/bnShus2D9Wt4BPKhUFKhBoC2JuQHtpngis5DVhaSb80K8nhQ7YjfXM6eh ORHEfli3aPbBAyZDCOUv2avSMT8I4L/rZ9xbwqotShJf22bkmi/Rrsr1ksNZo8p2qB yhroIQSw/texBgSHn0y8XTPp/cu68rNXCymuGLjwkwRXwemv4lgxsurtLDaQ3C2FcE nT4hqV+8d3IuYjkB/SMfnwpTItI3r2Jc1KdztM38vzHm7i2WH/1vYsE6bbTaTwJBuL 6MbnkTx1QYYLjTqBqXuZXney+PfSi40v/QowMB35c1MvlznDbvrPeAYZ3tsEVPZt74 WRm/04WjO8UeQ== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:54 +0200 Subject: [PATCH v2 13/15] file: port to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-13-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=938; i=brauner@kernel.org; h=from:subject:message-id; bh=CebY+vup8RjtcJO3CTsKAhV3jVPnEJg6xeCeD64qYmg=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl55zJ6dM2VhKS2/H/aW9Vbv7r6Yer3jIki0R3z/h6 +JyRfGojlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgIko7GP4n2CVvqcx/IdlwHwL uX0fojbs3pu1ckf6cjH7jpOqtgznjzP807PtnHyx7T3v4Y1ySXwx8dNiSjMPyfivrI0JePt9s70 tBwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspam-User: X-Stat-Signature: ud36go7fipcnqc4x176yfjw6r3qm5fzm X-Rspamd-Queue-Id: B9F0B40035 X-Rspamd-Server: rspam11 X-HE-Tag: 1725373373-187187 X-HE-Meta: U2FsdGVkX18aTTEEJkuv5CMDKPqlSf/3rsvvOvpwkT6zTrWkyaAEj2tQX9eazNuukN/XoATRXnQnKd3qVXJ2HEFneDWGlgcXJ1ZEMw41OBGzivVjhq3955QDrod2yE+/HKiG5sSKx6+8b5QP7Yr4PNdTKwdsKlEf0J8qolnbjtOyPqb+2w17pr4YvjXtHafHKV8Ox2ERd+OMUWYE2xuhF9QCc71IS2uNvH84ax9o2/FqEVK5msn5NP6HJBhcRDrs3kX5KQ6u0qcCDfhRmk2z3K9thXx48GMRVak+8VeYNzHuSiHTMIe56bwKzTdifTj+oD+v6NEetcUcsmvEfO0+E6e+IaJ2n2Dzu5RZIpJnDO4vXsXMdSYmTBfKWsaOfMoNzgVQZ7PQVdPAKGL3wTRaw/DNHq+w3DQX+UJTWKpSiy/XP1KMQU5YOLyRcwnPgQfcxCxIaxhRjw73Ie29w8SGgZW1Ztdkermzqjn46lhcK+kOBr0f6Txx1DGRDWWScDewchpDXqLGcdyuKc8clr/DZ9ove5wCLpJqi/AcY/Fg4lcGEk6YZihRfI7BQ7eu6vZCtjhGw2ocyxgcy/QtTi6xxIsk2K5uoSIgV0pKyCWvX5i9j0IL7b5KN5bp92I0bv2rNst01SQo9o3JichOGQOpoXf06M8R4RoHGjUOGbttXq2sEX6m126/UtLCtPuK92PuGmrQPPeZt9DUSzC5pEMdOt6Jg8PjHbVnSIkscurQtAW3mW5VElS156Kx4+iwnPVP0fH0EJZvfXD4fa8Pa9AZwyOUP6HaoT9mPQGgST05H1EqzAiI0Uo+vs0p+J2dq9qrXGuOnEWc6YWx2zqaF8DALZY3gCel50MQgplyWGXKNxyaMBwhnSuSp/BR+xxekcoQaAwnODFTUhxGXZEv/EWrtIubjxQ6FDAEeovpfGUtTpVNRajTR833dadvf76XDr0jyhs9krfsvuuZrPL/GAv //sAOH+w +lLqKDttoJ0T6bilgSrjKUv5LC8CgZYuonBtLxig8qUUDRjEk1rvAIjygFykE8p+nrHOeHT0TxJ/LN9aFTFRr/7uaKQCFqj5l2QbPI+RiQBztvs1Xseg2InB2PpUSa1pLV6Q2QnnOdgXpnGZHiiv/EqClhnxPzJpa5vPs6PndGrnRDLP47M3yf72v0+PERmFoHKhzwK8ukBzperQn3IhldENecYQVU91W3J3TsR9LXC4yfk+4H91khDeHh94ryxnW1FW7KsnD0MqPNpL7XQiqa0YyLWMj/p3QZkGQ 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 filp_cache to struct kmem_cache_args. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- fs/file_table.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/file_table.c b/fs/file_table.c index 3ef558f27a1c..861c03608e83 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -511,9 +511,14 @@ EXPORT_SYMBOL(__fput_sync); void __init files_init(void) { - filp_cachep = kmem_cache_create_rcu("filp", sizeof(struct file), - offsetof(struct file, f_freeptr), - SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT); + struct kmem_cache_args args = { + .use_freeptr_offset = true, + .freeptr_offset = offsetof(struct file, f_freeptr), + }; + + filp_cachep = kmem_cache_create("filp", sizeof(struct file), &args, + SLAB_HWCACHE_ALIGN | SLAB_PANIC | + SLAB_ACCOUNT | SLAB_TYPESAFE_BY_RCU); percpu_counter_init(&nr_files, 0, GFP_KERNEL); } From patchwork Tue Sep 3 14:20:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788796 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 17DCFCD3439 for ; Tue, 3 Sep 2024 14:23:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80EC78D0184; Tue, 3 Sep 2024 10:22:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 797318D0151; Tue, 3 Sep 2024 10:22:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 614C98D0184; Tue, 3 Sep 2024 10:22:58 -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 3656F8D0151 for ; Tue, 3 Sep 2024 10:22:58 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CD8A0160503 for ; Tue, 3 Sep 2024 14:22:57 +0000 (UTC) X-FDA: 82523643594.01.D018D65 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf30.hostedemail.com (Postfix) with ESMTP id 1366380010 for ; Tue, 3 Sep 2024 14:22:55 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JgSzT5kw; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf30.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=1725373306; a=rsa-sha256; cv=none; b=mO/W8yV5BHO/uWb73XHvqpgJZFkNwtnrzxp0LqtbQ3yrrCIFLEFJ5YPNdRF+NFcX/xBMA6 oT0SVZ16wfy92KqbTIAG5tZxzDnblAC3IY6AtvfmGz3HsBZV4GCmvqJlY1x6HZrln/TKXt hVJ2zHJ9GKNjpx6Pf1YsKNReDPh5fgQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JgSzT5kw; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf30.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=1725373306; 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=AFI0NHPHBKaBpnbS5PQtWzDi+0G5pcyZF1ja0kkTRck=; b=ELRxt6r8/WAR0KPzXtJ1ROFGYnrbrwj8KmfvI3oSUUJpXMI4LgNlc/Ub9NSlkIlr5IIuwb 5GoLZnIhayFfL9W5t7YSZCzxLy9aOMZ9nsFN73rpj9PajqmZx+XPxHLXKpNKAJutXuRhbH LASJkI4l222LcwKzTWwPrvw/hHDQiJw= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 53ABFA43660; Tue, 3 Sep 2024 14:22:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CA42C4CEC8; Tue, 3 Sep 2024 14:22:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373375; bh=6bG1JSwASGPcSbXbn/SP58oY4O44BFhaq6fvlGpwWZw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JgSzT5kw/kqZjtu62rKEOhtPQaXg6+GNpK7HPlu2JAeGj9bEhx9j07h95VDy1OKzE O31WVPK0Aor2Wj0c2PJPqCQahWpa4akQrZOu+WDkA1EG1VHsmvxZMLB+IwkYLAS7+B R/zTjA9ThANEe8EYIwWi34xcct3yVJpVNb6u5JrENfp3n1grX2Zkf/UYwZbIecoyWL 5R0XAn9j6JCIHIhZN/V6PZqVH8c1zEohmwqYI8wyr/khfF7xn4DXQ9pmAOR7954BDD NiA1S6c/x6XZLb1vhIALBBWiPczImRVo3QYYPqxEV2Kg7cVyFUf2TJgorV4wcCsnHp 6WhEIvdcTTD/A== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:55 +0200 Subject: [PATCH v2 14/15] slab: remove kmem_cache_create_rcu() MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-14-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=3031; i=brauner@kernel.org; h=from:subject:message-id; bh=6bG1JSwASGPcSbXbn/SP58oY4O44BFhaq6fvlGpwWZw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl54jXPX8rdx6/mVLDkyd06KQtJU9c0HW1+iL/6LX5 x2fsGtFdUcpC4MYF4OsmCKLQ7tJuNxynorNRpkaMHNYmUCGMHBxCsBE3ggyMrzjlnhzRLl04is9 m658Z+1bFmmFCb+0pq91PPIj48bNz6sZGZZfsks55tTGvGBllGHuUrZpJ/xDDt5X2HtBaAHH9Hc dTMwA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Queue-Id: 1366380010 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ntwrj3dpmdepizuztzx453jp46bsuswh X-HE-Tag: 1725373375-479494 X-HE-Meta: U2FsdGVkX1+tyM2dIGLJwRB+/+mo+lyuwtO5ESD9/wFqXEr1d8WuNjdtAeD7S09rHXUopviPO6njmqLRyYAoenh51rHDKqLqj0LQEMRRJZ2fJDQAb8xTh65P6xy1zm0jB3nLtRuNPtju54Zanrth3ja6JnwJ5sJet7+b907pZLu/Xy/B9jlc32eH0nlhb+/y/mqzLTopiWV8QMHD8gQRZe8SfpDCDTRLzf67UIuId65b/5WX8WXvEditaMdL0Fs5iW+VmIP6HtAtX1CQRzb3cBm7/QrcPwBojXpfKno0UfJxXcUiORVFl/W5qTp2ngoCK/pnqSHRGrf7Y3kSW6tNxQP6fBAtA7kiZmnDWA1zzmKEFSkFrRKrU51NRJ26Bd+AHcRBV8s8ak7mkEwyPOzSe5n8+TuUxKqaxG7vQ2pHgcyC+jgFjYLh4yPfVy9HmFAXeygAskktVJkMJOvfhq3cxBcpLKl7hZEwBAPN+ltKHmnSTYlUFJU3g6iX14ZSEU3b4hHDRzebpZ1nBLqdlQL4I2B6942t11eqRxg/xyMj3sE5ZuBEZL2h978LgxHwRwyUWAZxk8d2UXz5AuXDUycVKp1xAYUJwBGJ2f80usqhlCs4hOzaiBd2MXOCj1uktmgvFuqICoz75jjgn9J1pe27fjafAxgWk/WzL8e1NiznRw9G2Tm2qckePIdUpEyBGyHnQaRMmuge05Z75IQffihNS0vV3TQT5EVSie+F88Qu0klirh1xwNRZiAvsysywd8RiLalOg2MzjxqMwCGBXO6rU0iak61SC9BtId8DdwJgC3H2I0JCpG4DlGcVy+K1bZQ0Q503pV+oLmYM5LIPN0pe5CRfVvHbnAU70t1kGPkZxq+0/ANwjCKGNS0QkSwopQdWQMm6GWMFd29LcJFdlsBGafTcHmrJObeyZa3lLE5lcnVvFkR9FbHN+5c9ROiAiLwPuGhixC1l3E21fopPoUN B7Nm/HMS n8IB3kx/lSI3iu/EgrJy6VepKi/RDm6fOj8QmqZYKLsU+B/c2N9xx41vDpyA4AojapazhWLsuGldZPDCIS9fepewG2N2S4ZTfOK9D2e9kQSRBeLf4JCUjuEcwd+MBkO+VIXqrB4EgSfjIPCSALE8uanNsHyeVRFINlbShrWltqUxo4B3wDHaV0+YX9CwPYbM4CHwNi9434f6wLak44BTUMWOVfEPpKw2+/r2VWhhqql/u9WGp+OElOHeqeJtGNWiS49Fe1vB5y5IN4AvWxGJkegyXIb8M18UVG+Na 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: Since we have kmem_cache_setup() and have ported kmem_cache_create_rcu() users over to it is unused and can be removed. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- include/linux/slab.h | 3 --- mm/slab_common.c | 43 ------------------------------------------- 2 files changed, 46 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 4292d67094c3..1176b30cd4b2 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -270,9 +270,6 @@ struct kmem_cache *kmem_cache_create_usercopy(const char *name, slab_flags_t flags, unsigned int useroffset, unsigned int usersize, void (*ctor)(void *)); -struct kmem_cache *kmem_cache_create_rcu(const char *name, unsigned int size, - unsigned int freeptr_offset, - slab_flags_t flags); #define kmem_cache_create(__name, __object_size, __args, ...) \ _Generic((__args), \ diff --git a/mm/slab_common.c b/mm/slab_common.c index 418459927670..9133b9fafcb1 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -420,49 +420,6 @@ struct kmem_cache *__kmem_cache_create(const char *name, unsigned int size, } EXPORT_SYMBOL(__kmem_cache_create); -/** - * kmem_cache_create_rcu - Create a SLAB_TYPESAFE_BY_RCU 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. - * @freeptr_offset: The offset into the memory to the free pointer - * @flags: SLAB flags - * - * Cannot be called within an interrupt, but can be interrupted. - * - * See kmem_cache_create() for an explanation of possible @flags. - * - * By default SLAB_TYPESAFE_BY_RCU caches place the free pointer outside - * of the object. This might cause the object to grow in size. Callers - * that have a reason to avoid this can specify a custom free pointer - * offset in their struct where the free pointer will be placed. - * - * Note that placing the free pointer inside the object requires the - * caller to ensure that no fields are invalidated that are required to - * guard against object recycling (See SLAB_TYPESAFE_BY_RCU for - * details.). - * - * Using zero as a value for @freeptr_offset is valid. To request no - * offset UINT_MAX must be specified. - * - * Note that @ctor isn't supported with custom free pointers as a @ctor - * requires an external free pointer. - * - * Return: a pointer to the cache on success, NULL on failure. - */ -struct kmem_cache *kmem_cache_create_rcu(const char *name, unsigned int size, - unsigned int freeptr_offset, - slab_flags_t flags) -{ - struct kmem_cache_args kmem_args = { - .freeptr_offset = freeptr_offset, - .use_freeptr_offset = true, - }; - - return __kmem_cache_create_args(name, size, &kmem_args, - flags | SLAB_TYPESAFE_BY_RCU); -} -EXPORT_SYMBOL(kmem_cache_create_rcu); - static struct kmem_cache *kmem_buckets_cache __ro_after_init; /** From patchwork Tue Sep 3 14:20:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788797 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 8CABCCD343A for ; Tue, 3 Sep 2024 14:23:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 109818D0185; Tue, 3 Sep 2024 10:23:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 093CA8D0151; Tue, 3 Sep 2024 10:23:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E4F338D0185; Tue, 3 Sep 2024 10:23:00 -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 C084C8D0151 for ; Tue, 3 Sep 2024 10:23:00 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7E1421A04AE for ; Tue, 3 Sep 2024 14:23:00 +0000 (UTC) X-FDA: 82523643720.14.AF2CE1C Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf08.hostedemail.com (Postfix) with ESMTP id B767216001A for ; Tue, 3 Sep 2024 14:22:58 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NIA6dpiB; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf08.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=1725373273; 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=+U6+eSzUgYqIrunxVNxrQuJEbLQ5FZEq/qMkeBfPNDA=; b=PvyjdAZcVB56jNHHPd2kMl8vPm0T1PV05F1XA2rYCxWbQooJR14UCHf9bpmy03aa76/RfG anises8Ke//CkIIjRda8+1e1jeXK9a35A6o0ia/WUlnIM52Yc6xJqE/Brj1SSjFO/dEmoC Q564Ya5W7LyUujxvlG6lOmgEapP/6go= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725373273; a=rsa-sha256; cv=none; b=QYPteouwi3GrCL+yFD1vGWWdhEFqOSoHu2lopSB5Jl32ZNLxc1TXpCzIpSaGShIiINnWoL K41x2+06c14Xm5OdWFY1mMXb0TO5AczNYD3fARaYwsf3df4GCl2J4FhhITpygLlMv7RiVe fEGwgnH9GLUroi/0FpzxFC5orh4IOdM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NIA6dpiB; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf08.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 97860A4367D; Tue, 3 Sep 2024 14:22:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F4DEC4CEC7; Tue, 3 Sep 2024 14:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373377; bh=3NCbIt7AK7tmjnKZtBo4rWvQELZGRKFxzNKzdNzEh+o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NIA6dpiBbsE1OC9ubpMKp8jNcztrTDTatRxf5KWQbTjlNRL0XSoikHaYH8dpBad/t iQBWjOPBYr7F2hJIqWh1KHWyMLwTc0gaC0RunIT+Q0oQpZeoyPB8GGLUdhOw8irtF1 qbFVjlRZyEH7VMZ5Hv9JDpnK4Juc44MJqJh+uEOCaA5uPgtMgFvRdNmL+tmDM2VBuY Qxs7Y18c2eph5xk6SFRgiA6bR5BNORsx5hVl9nMzKNJSEjVWLvwjFklxT+weT11XLP YK1t4W5byhRnzilQiwcL7dGKwUnB0ES3FHG7KVbxBVKZQeyzZdkJf/fnMPTDWCmOuf lPTPbpjdMIbig== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:56 +0200 Subject: [PATCH v2 15/15] io_uring: port to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-15-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=1540; i=brauner@kernel.org; h=from:subject:message-id; bh=3NCbIt7AK7tmjnKZtBo4rWvQELZGRKFxzNKzdNzEh+o=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl56jXCmdfbbN7sLDswvvtcefsxDlmOklJvBbS3OD1 g+uz2oVHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABPp4Wb4X7suxbHyXNDclqBt H/cV3d8rIrLblltMhat0pdlFZwOnSYwMZx3/pP+Yc9oxtfXD0wXrz8w0cVhxRmBV4tHgZbnpa58 wcgAA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B767216001A X-Stat-Signature: azxh1hsboac57cht79mp9agywbu4u7dr X-Rspam-User: X-HE-Tag: 1725373378-302884 X-HE-Meta: U2FsdGVkX18lNx8YhkSIrUVIqoVc4ICLEJEr9zc+AxHQoo99hqPBQxTBSz7hCOYT/23D9yfuuKn71NDWOMwpmrMhwmekk5AbViePad7KvaBwnSiM3ay0tJPWRuuul+iwD0LjDdfWuWbOWI4A+zgsJPKu/6aYxA6Lo3wZ1DXrABXNSsgHwKbVEMWcf1Eax80Q+PLfug3S+UHhSsOwVPkii/iFMvgEtQZ58Cg3uO3OC3BanvS4pKHciyKpbJ5WdwpFzwickpvmBqsF2EpTNDviLgI8hR6QsXHpzHM9AIAI6Ln3+r9GU80JSl/ZsTwZS6VrvWI89ByKm4g+CGkhNMl8oEADWGgomvqxwZB7fSXCymm6nDbN2qwVQeDpW+h24KxFSf47ELv8d4ajUgDpobcvqDOHfB+gT/RumY9TroMLJxqRnd3NYxueeIAPGB4+PS6EzhZmz7Yd9ohr6/UhAaXjPbGFiL2aXilIsnUmhjKz+GAAxaQmS9shfUeMIRqqBGTP+WTZT81Wn0GyGtN2nOazoE+L5YkMuAHihhr6QyOV+WuGFVcN/nW3ublEzwaXcipxmxFGTDN/fSLWwXfehx8MqOWSFa5/452iSZKpc1tfGWlIA/sy1wU8MEkPw39+vAezXqB/M7zgd+86mJkRy2DwbKVvRZS43qS//JPKDuhKE36hexbya80L/LNdA8M/ekCouZT5PXymJHe+JZi+Ikl3vyHE9foi5lsr0UV8D+dWM0U/wzmy8/a+zw3XiB9MCDRJpuIB/LM53YndYEW9D/47TlgnFu0qog9CGPuLnL126VnVRl4gh2oAcrkfVeWu/PZY9sZP8Yyd/tG+zXt9FM8zNXkzAZrkoTGPb2MZNEHTeCN2+ulonndW9yOPY7s+Ifh7OZyHHfwpw2GMDhkQzM8VhbzN057wC9/96fjKHFkBjVf891nL1KtAvjt+fsQ+PFrj4HLIjRdPHn3EvuibqNd H2fEBBNo ATq1ZOePHJP9O/PeRwm4oZvOv6c5Y+dY+ujaO23T/kNAbUhSzee8JFaTAd5nlFtnx3+yijFe8mTISrf81de09ntXToXeyn6lkMvBoZN++iizO0gR4A4J8JRSMChxsZ9CYEF+xZUnCd/wDw1XH2ldKOGeJkK7I73a2aBnO2M7YYecvMQQCqXmHgrZtwG7rGOVc1yghUQ7b5hQOqn3oYNsP7pXYmXnH07ewl8fzvf+O950kb+fQf3u5zpOMviLxi6giMwWoPg3JhHpPNffQtgGAuqgIC/WHYo8MUdhI 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. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- 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);