public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Mateusz Guzik <mjguzik@gmail.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, torvalds@linux-foundation.org,
	 brauner@kernel.org, jack@suse.cz, paul@paul-moore.com,
	axboe@kernel.dk,  audit@vger.kernel.org,
	io-uring@vger.kernel.org
Subject: Re: [RFC PATCH v2 15/18] struct filename: saner handling of long names
Date: Sat, 29 Nov 2025 18:33:22 +0100	[thread overview]
Message-ID: <CAGudoHFjycOW1ROqsm1_8j47AGawjXC3kVctvWURFvSDvhq2jg@mail.gmail.com> (raw)
In-Reply-To: <20251129170142.150639-16-viro@zeniv.linux.org.uk>

On Sat, Nov 29, 2025 at 6:01 PM Al Viro <viro@zeniv.linux.org.uk> wrote:
>  void __init filename_init(void)
>  {
> -       names_cachep = kmem_cache_create_usercopy("names_cache", PATH_MAX, 0,
> -                       SLAB_HWCACHE_ALIGN|SLAB_PANIC, 0, PATH_MAX, NULL);
> +       names_cachep = kmem_cache_create_usercopy("names_cache", sizeof(struct filename), 0,
> +                       SLAB_HWCACHE_ALIGN|SLAB_PANIC, offsetof(struct filename, iname),
> +                                               EMBEDDED_NAME_MAX, NULL);
>  }
>
[snip]
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 59c5c67985ab..0b01adcfa425 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2833,11 +2833,13 @@ extern struct kobject *fs_kobj;
>
>  /* fs/open.c */
>  struct audit_names;
> +
> +#define EMBEDDED_NAME_MAX      128
>  struct filename {
>         const char              *name;  /* pointer to actual string */
>         atomic_t                refcnt;
>         struct audit_names      *aname;
> -       const char              iname[];
> +       const char              iname[EMBEDDED_NAME_MAX];
>  };
>  static_assert(offsetof(struct filename, iname) % sizeof(long) == 0);
>

This makes sizeof struct filename 152 bytes. At the same time because
of the SLAB_HWCACHE_ALIGN flag, the obj is going to take 192 bytes.

I don't know what would be the nice way to handle this in Linux, but
as is this is just failing to take advantage of memory which is going
to get allocated anyway.

Perhaps the macro could be bumped to 168 and the size checked with a
static assert on 64 bit platforms? Or some magic based on reported
cache line size.

  reply	other threads:[~2025-11-29 17:33 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-29 17:01 [RFC PATCH v2 00/18] io_uring, struct filename and audit Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 01/18] do_faccessat(): import pathname only once Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 02/18] do_fchmodat(): " Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 03/18] do_fchownat(): " Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 04/18] do_utimes_path(): " Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 05/18] chdir(2): " Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 06/18] chroot(2): " Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 07/18] user_statfs(): " Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 08/18] do_sys_truncate(): " Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 09/18] do_readlinkat(): " Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 10/18] get rid of audit_reusename() Al Viro
2025-12-16  2:14   ` Paul Moore
2025-11-29 17:01 ` [RFC PATCH v2 11/18] ntfs: ->d_compare() must not block Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 12/18] getname_flags() massage, part 1 Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 13/18] getname_flags() massage, part 2 Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 14/18] struct filename: use names_cachep only for getname() and friends Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 15/18] struct filename: saner handling of long names Al Viro
2025-11-29 17:33   ` Mateusz Guzik [this message]
2025-11-30  4:06     ` Al Viro
2025-11-30  4:38       ` Mateusz Guzik
2025-11-29 17:01 ` [RFC PATCH v2 16/18] allow incomplete imports of filenames Al Viro
2025-11-29 17:01 ` [RFC PATCH v2 17/18] fs: touch up predicts in putname() Al Viro
2025-11-29 17:34   ` Mateusz Guzik
2025-11-29 17:01 ` [RFC PATCH v2 18/18] struct filename ->refcnt doesn't need to be atomic Al Viro
2025-12-16  2:18   ` Paul Moore
2025-12-10  1:31 ` [RFC PATCH v2 00/18] io_uring, struct filename and audit Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGudoHFjycOW1ROqsm1_8j47AGawjXC3kVctvWURFvSDvhq2jg@mail.gmail.com \
    --to=mjguzik@gmail.com \
    --cc=audit@vger.kernel.org \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=io-uring@vger.kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox