]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
dm-bufio: remove maximum age based eviction
authorEric Biggers <ebiggers@google.com>
Tue, 22 Apr 2025 20:07:35 +0000 (13:07 -0700)
committerMikulas Patocka <mpatocka@redhat.com>
Sun, 4 May 2025 09:35:05 +0000 (11:35 +0200)
commit9769378133bbc4b77458ed0a520b008439a45488
tree0f2f904882878bdba95c34ae03c9d3e5175cd781
parentf9ed31214e2ac43cd38d1e517e774050b613b8da
dm-bufio: remove maximum age based eviction

Every 30 seconds, dm-bufio evicts all buffers that were not accessed
within the last max_age_seconds, except those pinned in memory via
retain_bytes.  By default max_age_seconds is 300 (i.e. 5 minutes), and
retain_bytes is 262144 (i.e. 256 KiB) per dm-bufio client.

This eviction algorithm is much too eager and is also redundant with the
shinker based eviction.

Testing on an Android phone shows that about 30 MB of dm-bufio buffers
(from dm-verity Merkle tree blocks) are loaded at boot time, and then
about 90% of them are suddenly thrown away 5 minutes after boot.  This
results in unnecessary Merkle tree I/O later.

Meanwhile, if the system actually encounters memory pressure, testing
also shows that the shrinker is effective at evicting the buffers.

Other major Linux kernel caches, such as the page cache, do not enforce
a maximum age, instead relying on the shrinker.

For these reasons, Android is now setting max_age_seconds to 86400
(i.e. 1 day), which mostly disables it; see
https://android.googlesource.com/platform/system/core/+/cadad290a79d5b0a30add935aaadab7c1b1ef5e9%5E%21/

That is a much better default, but really the maximum age based eviction
should not exist at all.  Let's remove it.

Note that this also eliminates the need to run work every 30 seconds,
which is beneficial too.

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