Re: [PATCH 3/6] md/raid5: scale the stripe_cache_size limit with system memory
From: yu kuai
Date: Thu Jul 30 2026 - 17:02:19 EST
Hi,
在 2026/7/10 21:23, Hiroshi Nishida 写道:
> raid5_set_cache_size() caps how far the per-array stripe_cache_size sysfs
> knob may be raised at a fixed 32768 stripes. The stripe cache costs
> roughly max_nr_stripes * (sizeof(stripe_head) + pool_size * (sizeof(bio) +
> PAGE_SIZE)), so 32768 stripes is about 1.5GB on a 12-disk array. That
> fixed limit is wrong at both ends: a host with hundreds of GB of RAM
> backing a wide array cannot grow the cache past ~1.5GB even though it has
> the memory to spare, while on a small box 32768 stripes can already exceed
> total RAM.
Firstly, I have no idea how this magic number is chosen, and I don't like it either.
However, in theory, 32768 stripes means 4k * 32768 = 128 MB, is there really such
device that can handle so much IO in the hardware queue? For example, if IO size is
128k, you'll have to issue 1024 IO to disk at a time. I don't think this is possible
for now, or even for a long time in the future.
>
> Derive the limit from memory instead. When the new stripe_cache_size_max
> module parameter is 0 (the default), the ceiling is the stripe count that
> fits in at most 1/8 of RAM for this array's width, but never less than the
> historical 32768 -- so the limit only ever grows relative to today and
> small systems are unchanged. A non-zero stripe_cache_size_max pins a fixed
> ceiling for administrators who want one.
>
> The default stripe count (256), and thus the default memory footprint, is
> unchanged; this only changes how high an administrator may raise
> stripe_cache_size.
>
> Signed-off-by: Hiroshi Nishida <nishidafmly@xxxxxxxxx>
> ---
> drivers/md/raid5.c | 37 ++++++++++++++++++++++++++++++++++++-
> 1 file changed, 36 insertions(+), 1 deletion(-)
>
--
Thanks,
Kuai