diff options
| author | Jori Koolstra <jkoolstra@xs4all.nl> | 2026-04-20 13:18:01 +0300 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-05-21 10:32:47 +0300 |
| commit | 80008c75f4523076a0ada0ac883ad8890b830ec9 (patch) | |
| tree | 2b0029fa6e6a9ea9dedc38ea30ecb8cc9dddcb93 /scripts/mod | |
| parent | 30beced6ec4931db201b77493d41d0df7d7eb5aa (diff) | |
| download | linux-80008c75f4523076a0ada0ac883ad8890b830ec9.tar.xz | |
vfs: remove always taken if-branch in find_next_fd()
find_next_fd() finds the next free fd slot in the passed fdtable's
bitmap. It does so in two steps: first it checks whether the bitmap
has a free entry in the word containing start. If not, it looks at
second level bitmap that registers which words in the first level bitmap
are full and then looks at the first level bitmap at the first non-full
word.
In the current code the second level lookup is done by:
bitbit = find_next_zero_bit(fdt->full_fds_bits, maxbit, bitbit) *
BITS_PER_LONG;
where bitbit = start / BITS_PER_LONG. However, in the fast path (first
step) we already checked the word at bitbit, so we can skip that word bit
and start at bitbit+1. This also means that we can get rid of the branch
if (bitbit > start)
start = bitbit;
since if we set
bitbit = find_next_zero_bit(fdt->full_fds_bits, maxbit, bitbit+1) *
BITS_PER_LONG;
the reassigned bitbit can never be less than
((start/BITS_PER_LONG)+1) * BITS_PER_LONG > start
So the branch is always taken.
Obviously the reuse of the variable name bitbit (and the name itself) is
quite confusing, so change that as well.
Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
Link: https://patch.msgid.link/20260420101801.806785-1-jkoolstra@xs4all.nl
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'scripts/mod')
0 files changed, 0 insertions, 0 deletions
