From patchwork Tue Aug 27 15:59:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13779779 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 79A5DC5472F for ; Tue, 27 Aug 2024 16:08:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EEC76B0096; Tue, 27 Aug 2024 12:08:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 09EB76B0098; Tue, 27 Aug 2024 12:08:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5A876B0099; Tue, 27 Aug 2024 12:08:04 -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 C6AD16B0096 for ; Tue, 27 Aug 2024 12:08:04 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B7E2FA1B59 for ; Tue, 27 Aug 2024 16:07:33 +0000 (UTC) X-FDA: 82498505586.30.DEC0DEF Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf24.hostedemail.com (Postfix) with ESMTP id A1D47180039 for ; Tue, 27 Aug 2024 16:07:29 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lmk208on; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of brauner@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724774786; a=rsa-sha256; cv=none; b=Wj3rF/mwCWOECgxB++7y1irF7PJpnweofCaWU5Ax5Um7Y7GDxtrn2KesReM1SincPtN4JH bNiD/pF/FcH6AKF7uWFQGrJkjgdVj8rZ3d/t1Kl/Ht3JH2DSHDXsXvz0/gaMJ7ZGxOEmyN 5+GdJQstcFRpayRCdwoJpDSHr+Ellh4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lmk208on; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of brauner@kernel.org designates 145.40.73.55 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=1724774786; 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: references:dkim-signature; bh=DaOwdh4WKH9gXF8/LMGcwnmi8yEU+uIY+2kYd8RsxRw=; b=kiX6YboQlS/MLL8i6UTcxSvuYjz+kyQ0GLsFGxFyVzjE1g511yGw+10qD4uGDvvUQcy4TA Bo/WuxoiiSTU2SsOVWuPKCKT82dauVKbY8tf5K33/jU2R+bzRPFFBAKH9Yle6OtjAQSAO5 JDJL0e6lOzwtJCDO0mlQZWbpPAnouG0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 615B4CE138D; Tue, 27 Aug 2024 16:07:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACC16C4DE1F; Tue, 27 Aug 2024 15:59:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724774397; bh=DaOwdh4WKH9gXF8/LMGcwnmi8yEU+uIY+2kYd8RsxRw=; h=From:Subject:Date:To:Cc:From; b=lmk208onsQi6UzYDW0SQkAIukShqy8isFn+Xr0qPd5H2u9D32FzmH2fqFbkR480x+ F/W+wrv5TFWcLC/ImwLn84DfNyBzfAMjA3WNI7NCIPup6kfNyIeJwCunFsgYCp8QlH p1Acml/LMl6ZId5myG6JInTvHJRvKYgaBorKFCV0GhCJ7NFCoDzl5e/DMb18j6Vj34 EMorsuMuGnsTY//Of4zrEBJoU/54CzNyI9SFFCsrECsfP/Hclqubl1EJwefX6EqQ0l qB0qoc+7Ypm1XwjLV+oCOpZh+gzkOqEkWSBXaoO0P3URKvtYZ3POfJBqpg/lEYt4Yh 1tZU/1PFl3CmQ== From: Christian Brauner Subject: [PATCH v2 0/3] fs,mm: add kmem_cache_create_rcu() Date: Tue, 27 Aug 2024 17:59:41 +0200 Message-Id: <20240827-work-kmem_cache-rcu-v2-0-7bc9c90d5eef@kernel.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAO33zWYC/zWNQQ6CMBBFr2K6tqZWLeDKexhiyjDYSUNLpoIaw t0tJO7mJfPfm0VCJkziupsF40SJYsig9zsBzoYnSmozC630WZW6kO/IXvoe+wdYcCgZRtlVBZ4 uRikAI/JyYOzos1nvdebGJpQN2wBudU1dOvSUYH11lF6Rv1t/Oq6Df8rI6P04EDIGGXKrxeDz2 ZalBaMLrBq4ZekYkEW9LMsPJzTRVswAAAA= To: Vlastimil Babka , Jens Axboe , "Paul E. McKenney" , Roman Gushchin , Jann Horn , Linus Torvalds , 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=1258; i=brauner@kernel.org; h=from:subject:message-id; bh=DaOwdh4WKH9gXF8/LMGcwnmi8yEU+uIY+2kYd8RsxRw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaSd/f6bo1JS3XRCudjUe+FSZnv6DugyzNt2/hPDxbPiw awfDppGdZSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAEyEYwnD//SzhYZ9LbUTMqWm fJt9YrbZq5knD1T9mv/ZsvX4NpUco2pGhm8SJ/03rvB+tmrXm8lRfP66SxZneL1sPLS25fmdR+v PCTMCAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Queue-Id: A1D47180039 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: yc346npiwq63fo54wybga7y4xc9g813i X-HE-Tag: 1724774849-329438 X-HE-Meta: U2FsdGVkX1/Vv0W6xcWbpmUXHaWc2w4gzTADoNm+9uxT9+5WUpdgEyhGLfEAA7mlRm70jDljB1MFXjoETGzVfMBFf5aN03izFcxS17ydQ9MDOXfWjNuy/aBhYOYDiwufanzzVUn8TatNxKT038vZl5CDS6YrefEB9R0Ls0dmSonoDrr0AzHhCmmBEpOaZSKeMbfHKimz+qi7Kgxowz4m5QjMqCaqJUXu83cDbgRAXynDBCECyzkjfubgn7A+zzZ4cShvk6SPHcO2uNtnBy56sd8WVS/4PtoNdwu1aSxy5RvRjB2067WgvTm+r7TffHT89sgzqU1+k5aKcWlf3KKOGJjWnfTStzUNG5qJRvT2YwHUr+ZcyuwBmB2GR6OwYLczdADC8t0RBEx81qmEZQeQHKlMgap/zG8fLCHJ6uQIVSaMGYDMH8dclC8J9EsIzYYkXWlJUxIUJAhNn9cXtkUVITNsiq1MN0iiess1jpzc1BcRIVbwjED3dF4p9GJQY6+Bj7vKhQtU4whrYTjh3pSXUZlgqPqzLu+sB4nW49ANaWaBnzLCzK+eR9QlcSJ4nkooNv/lC3xHzMqyCBv2/KXWbGMjSGrZrXQg5UL2TD8P2w0SRgN4YRwWh6taC9iMf4qtdDKUiEsPA3+wH6kFi5dnCBHo4Yzjb8t8wRIJELN6NakUJUHIWXKd3GXrLDdQ4/5NOl1Vtt9QGZXjYxMDRlTz9GJ0VMexXwKleQEUxuFB6PKBuPFpoO+MjKpXRvuet1x3pTM6X1SQ+26kdQNGm/aHxw73asxfbqrkTu4B9j3xFnJ7PiJEhv7ei1Y5c0RU9on4PH0jWVnXTWb1uMdXFP9Krm+OJThHRcXEaCZb9jW1uO9/0qlLtNGkWH0ghyoVEECu4Oz7xoCv8Pz+Ze8AwMMepqs9pLOEu+l+N3qKksqem+8ha3MYgqHk/tS8enEjJI/bl2m8ky2J3HvdyipQmfy Qwp0bRph GOq/hwNWIoghPO1IH/xqbi32uRECRdoPnNURJ4ClITZVuv19hlJ/kcLoWZ0pi48PbDpicMrKrx79byv9rjdeRTotk7hHSjBvOx6o1J4TnESEdqBJ4ub2RHcb+UzDTJ4J5YMnWDWDT2fNBFJxwXy/h3Fbv1uZlX02xYrHlLtc6ogsXJn/82ggxg99E5GJj9Jics2/f4N/HEfz+pE2n7xNu4yeQnGhHpHaM5mHaD2BbeIII5YU= 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: When a kmem cache is created with SLAB_TYPESAFE_BY_RCU the free pointer must be located outside of the object because we don't know what part of the memory can safely be overwritten as it may be needed to prevent object recycling. That has the consequence that SLAB_TYPESAFE_BY_RCU may end up adding a new cacheline. This is the case for .e.g, struct file. After having it shrunk down by 40 bytes and having it fit in three cachelines we still have SLAB_TYPESAFE_BY_RCU adding a fourth cacheline because it needs to accomodate the free pointer and is hardware cacheline aligned. I tried to find ways to rectify this as struct file is pretty much everywhere and having it use less memory is a good thing. So here's a proposal. I was hoping to get something to this effect into v6.12. If we really want to switch to a struct to pass kmem_cache parameters I can do the preparatory patch to convert all kmem_cache_create() and kmem_cache_create_usercopy() callers to use a struct for initialization of course. I can do this as a preparatory work or as follow-up work to this series. Thoughts? Thanks! Christian --- --- base-commit: 766508e7e2c5075eb744cb29b8cef6fa835b0344 change-id: 20240827-work-kmem_cache-rcu-f97e35600cc6