[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z8seJ5QV4nxGMf-T@casper.infradead.org>
Date: Fri, 7 Mar 2025 16:26:15 +0000
From: Matthew Wilcox <willy@...radead.org>
To: Mateusz Guzik <mjguzik@...il.com>
Cc: brauner@...nel.org, viro@...iv.linux.org.uk, jack@...e.cz,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
io-uring@...r.kernel.org, audit@...r.kernel.org, axboe@...nel.dk
Subject: Re: [PATCH] fs: support filename refcount without atomics
On Fri, Mar 07, 2025 at 05:11:55PM +0100, Mateusz Guzik wrote:
> +++ b/include/linux/fs.h
> @@ -2765,11 +2765,19 @@ struct audit_names;
> struct filename {
> const char *name; /* pointer to actual string */
> const __user char *uptr; /* original userland pointer */
> - atomic_t refcnt;
> + union {
> + atomic_t refcnt_atomic;
> + int refcnt;
> + };
> +#ifdef CONFIG_DEBUG_VFS
> + struct task_struct *owner;
> +#endif
> + bool is_atomic;
> struct audit_names *aname;
> const char iname[];
> };
7 (or 3) byte hole; try to pad.
Would it make more sense to put the bool between aname and iname where
it will only take one byte instead of 8? Actually, maybe do it as:
struct filename {
const char *name; /* pointer to actual string */
const __user char *uptr; /* original userland pointer */
- atomic_t refcnt;
struct audit_names *aname;
+#ifdef CONFIG_DEBUG_VFS
+ struct task_struct *owner;
+#endif
+ union {
+ atomic_t refcnt_atomic;
+ int refcnt;
+ };
+ bool is_atomic;
const char iname[];
};
and (on 64-bit), you're packed even more efficiently than right now.
Powered by blists - more mailing lists