file: mostly eliminate spurious relocking in __range_close
authorMateusz Guzik <mjguzik@gmail.com>
Thu, 27 Jul 2023 11:38:09 +0000 (13:38 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 4 Aug 2023 15:57:56 +0000 (17:57 +0200)
commited192c59f86910f089d061e635f6c1129bb14064
tree11f1942619856d9622d30da633eebaab0ae52704
parentee042cdb9f0f8a802fc6497ca921e8863f090f6e
file: mostly eliminate spurious relocking in __range_close

Stock code takes a lock trip for every fd in range, but this can be
trivially avoided and real-world consumers do have plenty of already
closed cases.

Just booting Debian 12 with a debug printk shows:
(sh) min 3 max 17 closed 15 empty 0
(sh) min 19 max 63 closed 31 empty 14
(sh) min 4 max 63 closed 0 empty 60
(spawn) min 3 max 63 closed 13 empty 48
(spawn) min 3 max 63 closed 13 empty 48
(mount) min 3 max 17 closed 15 empty 0
(mount) min 19 max 63 closed 32 empty 13

and so on.

While here use more idiomatic naming.

An avoidable relock is left in place to avoid uglifying the code.
The code was not switched to bitmap traversal for the same reason.

Tested with ltp kernel/syscalls/close_range

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Message-Id: <20230727113809.800067-1-mjguzik@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/file.c