[PATCH v3 0/3] fs,mm: add kmem_cache_create_rcu()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
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@xxxxxxxxxx

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





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux