From patchwork Wed Aug 28 10:56:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13781134 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 19773C54ED1 for ; Wed, 28 Aug 2024 11:12:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 92FD26B0088; Wed, 28 Aug 2024 07:12:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8902B6B0089; Wed, 28 Aug 2024 07:12:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 757DE6B008C; Wed, 28 Aug 2024 07:12:29 -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 58F266B0088 for ; Wed, 28 Aug 2024 07:12:29 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BF0DA41F1F for ; Wed, 28 Aug 2024 11:12:28 +0000 (UTC) X-FDA: 82501390776.27.C9BEB9A Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf15.hostedemail.com (Postfix) with ESMTP id 098CBA001D for ; Wed, 28 Aug 2024 11:12:26 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=B0tkqFU0; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf15.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=1724843482; a=rsa-sha256; cv=none; b=BLJ/dZAUcmdJ2b1mIyn57BFa/O/cxILOT5mQnBh/MpnC8xjN3kid+gA47TtoyvUsvwlHk8 X+4fyDpJ4uOIAuP/pk2tFqOoTVupFjtpvNlpb/EkyJsPK2gTesaRKK3TQma/WbYNVZ3fW8 Z+lOkZNk+n7QRaXDgTUVmVNqlauhXKM= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=B0tkqFU0; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf15.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=1724843482; 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=Q/4ZuQAHivHS47Qh1bVpCkPwi5OXsHv/q8ivNrkzfTg=; b=PxhWLmjQ+DtJy0xrX0mZTbBnKAkZfKeg+rv27iaBUtWceZVozRHdY4RKdphWsIKjKzzU9d 6zzpWaFKDp+T8yop6aDlyvA8Q0FLnpJEEJXiZ1z9HSDAv+xY1Xw4Yy68udtNM/J8h70Z5D PIKHXZFf4dKcz+VRt2BK+K/+Cz6lZmg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 23C61A43515; Wed, 28 Aug 2024 11:12:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4835C4CADC; Wed, 28 Aug 2024 10:57:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724842633; bh=sHidI5jLSIX8UVIkMjGOIDyMLbkLDe+hp8XvmRLq1Os=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=B0tkqFU0sJKz1kSgkSPagbo7d+km0HFluA7VxuYR7+178B+NrzPVKuoIwjxPWVUsz dcJxIroODwog7d2FVspEVzk83T586CuOtp9L0hCCnHfKFf18fNmfUL27A8R024RQ4O 3/VusbKgIvFSJHDJskhfUwwK/sdmw/km9mN60NLr2WswhtqA2ATORIq8C922InicQU Zds8j07G4y06GhWe06R6ZCWDoqOXttIIIbklmBjGuFRBCj2fsdE+2hiFTm9gtG9cAt u1Bs7l+z3UmoSG3gZLLIgwMCTlKUeXl4ZvmtTCJ+ssUYt3B9ylPudtO8zL8xsXWrYs 9/R/IuBXINTyw== From: Christian Brauner Date: Wed, 28 Aug 2024 12:56:25 +0200 Subject: [PATCH v3 3/3] fs: use kmem_cache_create_rcu() MIME-Version: 1.0 Message-Id: <20240828-work-kmem_cache-rcu-v3-3-5460bc1f09f6@kernel.org> References: <20240828-work-kmem_cache-rcu-v3-0-5460bc1f09f6@kernel.org> In-Reply-To: <20240828-work-kmem_cache-rcu-v3-0-5460bc1f09f6@kernel.org> To: Vlastimil Babka , Jens Axboe , "Paul E. McKenney" , Roman Gushchin , Jann Horn , Linus Torvalds , Mike Rapoport , linux-mm@kvack.org Cc: Christian Brauner , linux-fsdevel@vger.kernel.org X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1718; i=brauner@kernel.org; h=from:subject:message-id; bh=sHidI5jLSIX8UVIkMjGOIDyMLbkLDe+hp8XvmRLq1Os=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaSdZ6q5v6hBTF6IM/HeIbPn2qWv6zQ+c8mU3Fr3+Nyv7 h/fOkK/dZSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAExk6y6G/wmJtYGf3WQnBFvY dAa9CWXdZ+QdMM18h0Xbcp/c3TlaWowMPyq+bkycXNlYJG8hGpGceuWrTLR61vd67V+d27ZYfmv hBAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; f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hKNd7HlRWLmHGv82+44GjRNMt/0H33KO3l5J6A00DYaQ7xWB2UKROS/T2F XoFLJTWD 1M6qHzEBbbWdokiXAFtEUIXXuZAcXr4axhcFqhq3ea90QMZcCKJkQ1rZsWVtydj1CdUmgTxDWp+LnNGGUt6+QtoyoxZ5uO71dgxSp+8qGyXvg4WpaNFjkVg/FRteY/WYnxn7QodS9r0kZSj9EMactrnhyndv/H2CR4VobLFUtKlJfTATfSiQTDq8Kc0J6Hu7pnlmDjQg3M3qQ36h2FPXlGkaFhGKuT1BJa//yJXkEsPDlrpG8BN3s9NDzOiGWsapHyWZKxUjr6a+AgKnhrKzVF6FbJrpcdJ40WztTGvE1+c3NMBBCWlpMr1i5bQ2/GLEKkCQR 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: Switch to the new kmem_cache_create_rcu() helper which allows us to use a custom free pointer offset avoiding the need to have an external free pointer which would grow struct file behind our backs. Signed-off-by: Christian Brauner Reviewed-by: Vlastimil Babka --- fs/file_table.c | 6 +++--- include/linux/fs.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/file_table.c b/fs/file_table.c index 694199a1a966..83d5ac1fadc0 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -514,9 +514,9 @@ EXPORT_SYMBOL(__fput_sync); void __init files_init(void) { - filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0, - SLAB_TYPESAFE_BY_RCU | SLAB_HWCACHE_ALIGN | - SLAB_PANIC | SLAB_ACCOUNT, NULL); + filp_cachep = kmem_cache_create_rcu("filp", sizeof(struct file), + offsetof(struct file, f_freeptr), + SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT); percpu_counter_init(&nr_files, 0, GFP_KERNEL); } diff --git a/include/linux/fs.h b/include/linux/fs.h index 61097a9cf317..5ca83e87adef 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1026,6 +1026,7 @@ static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index) * @f_task_work: task work entry point * @f_llist: work queue entrypoint * @f_ra: file's readahead state + * @f_freeptr: Pointer used by SLAB_TYPESAFE_BY_RCU file cache (don't touch.) */ struct file { atomic_long_t f_count; @@ -1057,6 +1058,7 @@ struct file { struct callback_head f_task_work; struct llist_node f_llist; struct file_ra_state f_ra; + freeptr_t f_freeptr; }; /* --- cacheline 3 boundary (192 bytes) --- */ } __randomize_layout