]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
dm-bufio: avoid redundant buffer_tree lookups
authorEric Biggers <ebiggers@kernel.org>
Sun, 11 Jan 2026 21:38:21 +0000 (13:38 -0800)
committerMikulas Patocka <mpatocka@redhat.com>
Mon, 19 Jan 2026 14:39:21 +0000 (15:39 +0100)
commitbe9badced98f89cf5c6f7690f7d9739a213c4502
treea3ddcf06be2b97d16438b659eac9a3491ab4ab09
parent1bf7ba4ca342ada012e7ef88274fb306e88917ad
dm-bufio: avoid redundant buffer_tree lookups

dm-bufio's map from block number to buffer is organized as a hash table
of red-black trees.  It does far more lookups in this hash table than
necessary: typically one lookup to lock the tree, one lookup to search
the tree, and one lookup to unlock the tree.  Only one of those lookups
is needed.  Optimize it to do only the minimum number of lookups.

This improves performance.   It also reduces the object code size,
considering that the redundant hash table lookups were being inlined.
For example, the size of the text section of dm-bufio.o decreases from
15599 to 15070 bytes with gcc 15 and x86_64, or from 20652 to 20244
bytes with clang 21 and arm64.

Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-bufio.c