Skip to content

Commit 0202a0e

Browse files
author
Ian Kent
committed
fs/file.c: conditionally clear full_fds
JIRA: https://issues.redhat.com/browse/RHEL-38570 Upstream status: Linus commit c9a3019 Author: Yu Ma <yu.ma@intel.com> Date: Wed Jul 17 10:50:17 2024 -0400 fs/file.c: conditionally clear full_fds 64 bits in open_fds are mapped to a common bit in full_fds_bits. It is very likely that a bit in full_fds_bits has been cleared before in __clear_open_fds()'s operation. Check the clear bit in full_fds_bits before clearing to avoid unnecessary write and cache bouncing. See commit fc90888 ("vfs: conditionally clear close-on-exec flag") for a similar optimization. take stock kernel with patch 1 as baseline, it improves pts/blogbench-1.1.0 read for 13%, and write for 5% on Intel ICX 160 cores configuration with v6.10-rc7. Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Tim Chen <tim.c.chen@linux.intel.com> Signed-off-by: Yu Ma <yu.ma@intel.com> Link: https://lore.kernel.org/r/20240717145018.3972922-3-yu.ma@intel.com Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Ian Kent <ikent@redhat.com>
1 parent 4647ea5 commit 0202a0e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ static inline void __set_open_fd(unsigned int fd, struct fdtable *fdt)
252252
static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt)
253253
{
254254
__clear_bit(fd, fdt->open_fds);
255-
__clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits);
255+
fd /= BITS_PER_LONG;
256+
if (test_bit(fd, fdt->full_fds_bits))
257+
__clear_bit(fd, fdt->full_fds_bits);
256258
}
257259

258260
static unsigned int count_open_files(struct fdtable *fdt)

0 commit comments

Comments
 (0)