Re: [RFC PATCH] fs: elide the smp_rmb fence in fd_install()
From: Al Viro
Date: Thu Dec 05 2024 - 09:20:16 EST
On Thu, Dec 05, 2024 at 01:03:32PM +0100, Mateusz Guzik wrote:
> void fd_install(unsigned int fd, struct file *file)
> {
> - struct files_struct *files = current->files;
> + struct files_struct *files;
> struct fdtable *fdt;
>
> if (WARN_ON_ONCE(unlikely(file->f_mode & FMODE_BACKING)))
> return;
>
> + /*
> + * Synchronized with expand_fdtable(), see that routine for an
> + * explanation.
> + */
> rcu_read_lock_sched();
> + files = READ_ONCE(current->files);
What are you trying to do with that READ_ONCE()? current->files
itself is *not* changed by any of that code; current->files->fdtab is.