News: 0001614107

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Linux 7.0 Merges "Significant Improvement" For close_range System Call

([Linux Kernel] 4 Hours Ago close_range)


The close_range system call for closing all file descriptors "FDs" in a given range should enjoy a nice speed boost with the in-development [1]Linux 7.0 kernel.

Last week saw all the feature-heavy VFS pull requests that brought [2]nullfs and open_tree_namespace , [3]standardized generic I/O error reporting , non-blocking timestamps, and other improvements. Sent out on Monday were some lingering VFS patches mailed out by Christian Brauner.

Notable with the [4]vfs misc 2 pull is optimizing the close_range system call. The close_range usage drops from O(range size) to O(active FDs) with now being more efficient to provide a "significant improvement" for large range close operations on sparse file descriptor tables. Brauner summed it up as:

"Optimize close_range() from O(range size) to O(active FDs) by using find_next_bit() on the open_fds bitmap instead of linearly scanning the entire requested range. This is a significant improvement for large-range close operations on sparse file descriptor tables."

The close_range system call is used to close all file descriptors in a given range on the system.

Qiliang Yuan of China Telecom who authored this patch had similarly [5]wrote :

"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."

The code was merged today to Linux Git. A lot of nice work building up for Linux 7.0.



[1] https://www.phoronix.com/search/Linux+7.0

[2] https://www.phoronix.com/news/Linux-7.0-NULLFS-Namespace

[3] https://www.phoronix.com/news/Linux-7.0-VFS

[4] https://lore.kernel.org/lkml/20260216-vfs-misc-2-v70-fd637c6f249a@brauner/

[5] https://lore.kernel.org/all/20260123081221.659125-1-realwujing@gmail.com/



Before he became a hermit, Zarathud was a young Priest, and
took great delight in making fools of his opponents in front of
his followers.
One day Zarathud took his students to a pleasant pasture and
there he confronted The Sacred Chao while She was contentedly grazing.
"Tell me, you dumb beast," demanded the Priest in his
commanding voice, "why don't you do something worthwhile? What is your
Purpose in Life, anyway?"
Munching the tasty grass, The Sacred Chao replied "MU". (The
Chinese ideogram for NO-THING.)
Upon hearing this, absolutely nobody was enlightened.
Primarily because nobody understood Chinese.
-- Camden Benares, "Zen Without Zen Masters"