linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] fs,mm: add kmem_cache_create_rcu()
@ 2024-08-28 10:56 Christian Brauner
  2024-08-28 10:56 ` [PATCH v3 1/3] mm: remove unused root_cache argument Christian Brauner
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Christian Brauner @ 2024-08-28 10:56 UTC (permalink / raw)
  To: Vlastimil Babka, Jens Axboe, Paul E. McKenney, Roman Gushchin,
	Jann Horn, Linus Torvalds, Mike Rapoport, linux-mm
  Cc: Christian Brauner, linux-fsdevel

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 <brauner@kernel.org>
---
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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-08-29 15:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-28 10:56 [PATCH v3 0/3] fs,mm: add kmem_cache_create_rcu() Christian Brauner
2024-08-28 10:56 ` [PATCH v3 1/3] mm: remove unused root_cache argument Christian Brauner
2024-08-28 15:05   ` Vlastimil Babka
2024-08-29  8:38     ` Christian Brauner
2024-08-28 10:56 ` [PATCH v3 2/3] mm: add kmem_cache_create_rcu() Christian Brauner
2024-08-28 15:16   ` Vlastimil Babka
2024-08-28 16:36   ` Mike Rapoport
2024-08-28 10:56 ` [PATCH v3 3/3] fs: use kmem_cache_create_rcu() Christian Brauner
2024-08-28 15:17   ` Vlastimil Babka
2024-08-29 15:58 ` [PATCH v3 0/3] fs,mm: add kmem_cache_create_rcu() Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).