On Fri, 20 Nov 2026, Yongpeng Yang wrote:

> On Thu, Nov 19, 2026, Mikulas Patocka wrote:
> > Is the kernel dropping dm-bufio buffers too aggressively? Or is it not
> > dropping them so that they consume too much memory?
> 
> Both, and the tension is why one global value cannot work. Our hash
> areas run from 0.x MB to 40+ MB: the 256 KiB default makes large devices
> re-read evicted hash blocks, while a uniformly large value makes every
> cold, idle device hold memory forever -- and most verity devices are
> cold most of the time, which is what small-memory systems complain about.

What about improving the shrinker memory management?

The problem with shrinkers is that the generic memory management code 
doesn't know how old are objects in the registered shrinkers. So, it may 
ask the shrinkers that have only recently used objects to free memory.

Maybe we could add an upcall that returns the last used time of the oldest 
object in a given shrinker, select the shrinker with the oldest object and 
shrink from it? Would this be feasible?

> > Could it be fixed through other means that are more general? (for
> > example, having a global dm-bufio shrinker and dropping buffers from
> > the client that has the longest unused buffer)
> 
> A global LRU shrinker would tell hot from cold given time, but:
> 
> - Our userspace already knows which device will be used and when, so
>   it does not need the heuristic, it can drop exactly that device's
>   hash blocks, precisely and immediately.

Please, show some numbers - how much does this patchset improve Android 
boot time (if you are prefetching blocks that will be needed at boot) or 
application load time?

Would prefetching with the readahead() syscall be better? (it would 
prefetch data down to the page cache, so I presume it would be more 
efficient)

Back in the era of mechanical disks, there used to be a daemon that 
prefetched blocks to improve boot time. With SSDs, the idea was abandoned 
because it didn't provide any advantage. Are you implementing something 
like this?

> - On low-memory devices we need the memory back quickly, not when
>   pressure finally ages the buffers out.

I don't see how shrinking bufio should be different from shrinking page 
cache, inodes, dentries or other kernel objects.

Maybe you need to tune /proc/sys/vm/min_free_kbytes if the kernel is not 
shrinking memory fast enough.

> - Verity, thin and cache clients share one pool with very different
>   access patterns; a single LRU lets them fight for it, while
>   per-client floors keep the shares apart.
> 
> Thanks for the review,
> Yongpeng

Mikulas


Reply via email to