Re: [PATCH][CFT][experimental] net/socket.c: use straight fdget/fdput (resend)

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

 



On Mon, 27 May 2024 at 12:20, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> With just a couple of helpers it would be mostly a cleanup.

Looking around, I think we could even take four bits. Without any
debugging, 'struct file' is 160 bytes on 32-bit, it would not hurt at
all to just force a 16-byte alignment.

In fact, in practice it is aligned more than that - we already use
SLAB_HWCACHE_ALIGN, which in most cases means that it's 64-byte
aligned.

But to be safe, we should specify the 16 bytes in the
kmem_cache_create() call, and we should just make this all very
explicit:

  --- a/fs/file_table.c
  +++ b/fs/file_table.c
  @@ -512,7 +512,7 @@ EXPORT_SYMBOL(__fput_sync);

   void __init files_init(void)
   {
  -     filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0,
  +     filp_cachep = kmem_cache_create("filp", sizeof(struct file), 16,
                                SLAB_TYPESAFE_BY_RCU | SLAB_HWCACHE_ALIGN |
                                SLAB_PANIC | SLAB_ACCOUNT, NULL);
        percpu_counter_init(&nr_files, 0, GFP_KERNEL);
  --- a/include/linux/fs.h
  +++ b/include/linux/fs.h
  @@ -1025,7 +1025,7 @@ struct file {
        errseq_t                f_wb_err;
        errseq_t                f_sb_err; /* for syncfs */
   } __randomize_layout
  -  __attribute__((aligned(4)));       /* lest something weird
decides that 2 is OK */
  +  __attribute__((aligned(16))); /* Up to four tag bits */

   struct file_handle {
        __u32 handle_bytes;

and while four tag bits isn't something to waste, it looks pretty
reasonable here.

               Linus




[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