Files
linux/fs
Qiliang Yuan fc94368bce fs/file: optimize close_range() complexity from O(N) to O(Sparse)
In close_range(), the kernel traditionally performs a linear scan over the
[fd, max_fd] range, resulting in O(N) complexity where N is the range size.
For processes with sparse FD tables, this is inefficient as it checks many
unallocated slots.

This patch optimizes __range_close() by using find_next_bit() on the
open_fds bitmap to skip holes. This shifts the algorithmic complexity from
O(Range Size) to O(Active FDs), providing a significant performance boost
for large-range close operations on sparse file descriptor tables.

Signed-off-by: Qiliang Yuan <realwujing@gmail.com>
Signed-off-by: Qiliang Yuan <yuanql9@chinatelecom.cn>
Link: https://patch.msgid.link/20260123081221.659125-1-realwujing@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
2026-01-23 11:31:49 +01:00
..
2025-11-16 01:35:04 -05:00
2025-11-16 01:35:03 -05:00
2025-09-16 23:59:38 -04:00
2025-11-04 12:36:33 +01:00
2025-11-28 12:42:31 +01:00
2025-11-12 09:38:34 +01:00
2025-09-01 13:08:01 +02:00
2025-11-05 09:51:30 +01:00
2025-11-12 09:38:34 +01:00