From patchwork Wed Aug 28 10:56:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13781136 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 983CDC54ED1 for ; Wed, 28 Aug 2024 11:12:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F7E76B0092; Wed, 28 Aug 2024 07:12:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 758F06B0093; Wed, 28 Aug 2024 07:12:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 591A36B0095; Wed, 28 Aug 2024 07:12:32 -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 333266B0092 for ; Wed, 28 Aug 2024 07:12:32 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E4064AAF41 for ; Wed, 28 Aug 2024 11:12:31 +0000 (UTC) X-FDA: 82501390902.21.50CBF64 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf13.hostedemail.com (Postfix) with ESMTP id 3F76020018 for ; Wed, 28 Aug 2024 11:12:30 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KFdDRb5p; spf=pass (imf13.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=1724843480; 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=/bfe4L0XyImXMggAeHLRU8xa2GXL/gv2+UK6KiheZSs=; b=8oU9vkVhITQJDs8NLraqyTnnrL5u2dyET0Y6menFRaU5RGj8bJsrzf8+UHrQELKxZPpLmf JmaDp6VR/rhRTjYhz2OBQnb4OewJesFcUerGtdaqHbXNH/1rnvD7xwvyI6uOr+SViV4i6U Xe0ZpgFuKcDBzxW5wOOpI/nSTmrnmgE= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KFdDRb5p; spf=pass (imf13.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=1724843480; a=rsa-sha256; cv=none; b=pIWphOdg8Eu1tgLfSSOkAhw1ahdelpAtvOjp+niWMlfmbKG2hc/X6FC3itTw1AAGYxBwAL LVsfz5a/ZlqgeWEsfgA/T/f91uoCQzOJ5gXhHlL7lmt5mmJvTREu2B/XQ+Kj4uWGRASG6B CBsR0yax5O9OuYxrchRET4TQGb1vPCk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id B0880A43541; Wed, 28 Aug 2024 11:12:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE589C4CAB7; Wed, 28 Aug 2024 10:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724842623; bh=30jtxC8VQgZtD1NmPoRfx+NWuzYQzJ6T6yXQfSWpXBU=; h=From:Subject:Date:To:Cc:From; b=KFdDRb5pWNd/hkQ7AKhObZGrGAiG6B7hGfZ08Z1+an4myKbwfFcWUfgGaD8LcMcyC BAVx9b2Ffrupl1ogCReHSgf7F9CeQIX6JANi9bPBf0eIKRZ9IXWJBz1QKp3tVuRfd+ cr+sWrDqRhwzdCaHDTXus7ohAjy3b5S0N5B+4Nbo6XoIV3i4P3CCZlr4tPvC3oIGFZ lmOJZIGssx+D+RrOVmxHeX3wdAJZ8va+SJXXay2WBMc+bdBkbTvupd2VRA8TsAcvPN qgOBewD82hGSFUlHTp7UcecLq/cOXW+xPenOcenaXZ8C/h/3kZADZCtKzd8FWXeZCc 1DdEwwcukIeCA== From: Christian Brauner Subject: [PATCH v3 0/3] fs,mm: add kmem_cache_create_rcu() Date: Wed, 28 Aug 2024 12:56:22 +0200 Message-Id: <20240828-work-kmem_cache-rcu-v3-0-5460bc1f09f6@kernel.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAFYCz2YC/22OzWrDMBCEXyXo3A2q0vgnp7xHCEVej2OhWgqrW G0JfvfKgUAOve3AfPPtXSWIQ1KHzV0JsksuhhJ2bxvFow0XkOtLVkabD92Ymr6jePITpk+2PIK EZxraGrt9pTVzpQp5FQzu57F6Opfc2QTqxAYe1608pO3kEq/V0aVblN+HP7+vwFNVUfR+vjoIA oXi6hF8OfumsVyZGm3HxzI6B4haLdm84v9/mg1pqjtuudX9HhiOHhLwtY1yUedlWf4Anb3YMhE BAAA= 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=2197; i=brauner@kernel.org; h=from:subject:message-id; bh=30jtxC8VQgZtD1NmPoRfx+NWuzYQzJ6T6yXQfSWpXBU=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaSdZ6rRf3l7kRRTmk10TUNq0+Yv/4T2LjtxUk/2ewL7d 03NKd/PdJSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAEzk72tGhhOXw78Jqno5zDgq +d725b+fsZVHWk+v2HyPsdwsSimoNIeR4cKri99jb/G77J1YpRQTY9yhUb8uk+tv3ayFeneeTvt VxgQA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Stat-Signature: 4ni31cbsu1n1uj94unijg74q74cb9gn7 X-Rspam-User: X-Rspamd-Queue-Id: 3F76020018 X-Rspamd-Server: rspam02 X-HE-Tag: 1724843550-308893 X-HE-Meta: U2FsdGVkX19Qy9vtrAupZK7fg7EKUAN/z4MPtusQQcNTONcnqFtCslNyqL/wy2w2emvhSRLFlZ+etUNtD7KhUaTU4WHHcpRVjPLDjvxbl6wVfevlijVD6AznfzVGkRcCnWVZPinCNAfaKVokcb2QwvXMHvLTMhCKaNTYgleB4PsBtGUJe//e+CLfkLiNh3IVkGkOoBIouyyySa1iidqG4p2xe1ys3PvcrrauL7tUGDSj4kNJG6iQzH6J/uqC/F4KjrbD7xKuJCwH/uBO4LRjOeT7fLZgHz4wQ/zjLh0NOn9Mpk1ESudTihLY5zjDSSPsWiQvbMARWskgnSDl9TVm3tgikO/Q+5COmSm9wjRQCHRO/rrvsY2dt4WNY1gznuLbA5ZVqtWrcVSsrwq/8NoqsL6E64rsMpwgV+3k0/GyeltYFi8z3dV5oaJFXOETaX8vPbBIyo9mfh1r/WsIvXdVzxhsAvnuqKVVqK+91SoJolpREPk6UbepAHQOBS8qzvVyhg2GBqoHPOjqWSS04eAzDKamdWayG/jGdZ7eNHmuvNMT3SXgTxRP7rlwgr8hKnLEYUWo0nfBYfERemRYJH/rw+alC2uInFd+Up9hEnnp84LWz+aOONKg4lS6E3f7EJ406FNez/o+vKBwdMh2K+lyA0rRh6C9XffuI45UJ8D4DDmfGRpLfmOqfuiTQ1dVl9eKAVgZXA6feYe9mwoygaRQJ5oNFXfFPCg6hFjJlapJD4mtWjLXDFvVMRa1mPalcNjn/zQQO/s/jWaPVUfj14ztZ6WYeurQYhQ72UGJg9ViOsqxzst7zo59jr/qERJEj7K4X3HrOgZ/BV+sYzJG1BRUPvYF7J+lrXOC6J8NEfBlzhxL31skySEoF6cqtNk1wOaJicyS7j4uH1bWQ/LZkpDrp5qOrM/d4VejlP2pFBMQORY86FmAi+76tB0bRG3ED6pRNhOkMb6eVoke3uAHTvC /LmwT8ED pmxUwzPbU/NlYEaIV83AVHVmuYNLST9sUkMZ6CfBITqWV/fOQ3t6/2Fmrye2OPU2Fd86N8zzw3feeeWiwa8601Vtsq4nXiPFDp3sM1uw980vN2lnDXA4E+6l6umgavXvTS2BVnuPD/JcOE8BoaXTJwvuJHD+AikNU1q/BEyGQpbGWm7tXzf3cTXDmQtGy1fFcLV0k2wNVWU9YkxVdyjNCzf4Rc4P6gw4k/FeCdbf+q1PPxrV8RDmZ/hykj0DfItVb9JS8jyYX91fdmHhdmkI+VfoytAGbAuky5Z2JM7QOL9/aEsoHTtymBrenUKX962x0NfSZ 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. Before this series cat /proc/slabinfo: filp 1198 1248 256 32 2 : tunables 0 0 0 : slabdata 39 39 0 ^^^ After this series cat /proc/slabinfo: filp 1323 1323 192 21 1 : tunables 0 0 0 : slabdata 63 63 0 ^^^ I was hoping to get something to this effect into v6.12. Thanks! Christian Signed-off-by: Christian Brauner --- Changes in v3: - Check for alignment of freeptr. - Minor documentation fixes. - Fix freeptr validation. - Link to v2: https://lore.kernel.org/r/20240827-work-kmem_cache-rcu-v2-0-7bc9c90d5eef@kernel.org Changes in v2: - Export freeptr_t. - Remove boolean. - Various other fixes - Link to v1: https://lore.kernel.org/r/20240826-okkupieren-nachdenken-d88ac627e9bc@brauner --- Christian Brauner (3): mm: remove unused root_cache argument mm: add kmem_cache_create_rcu() fs: use kmem_cache_create_rcu() fs/file_table.c | 6 +-- include/linux/fs.h | 2 + include/linux/slab.h | 9 ++++ mm/slab.h | 2 + mm/slab_common.c | 139 ++++++++++++++++++++++++++++++++++++--------------- mm/slub.c | 20 +++++--- 6 files changed, 127 insertions(+), 51 deletions(-) --- base-commit: 766508e7e2c5075eb744cb29b8cef6fa835b0344 change-id: 20240827-work-kmem_cache-rcu-f97e35600cc6