From: sashiko-bot@kernel.org
To: "Qiliang Yuan" <odys.yuan@gmail.com>
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org
Subject: Re: [PATCH v3 1/2] ext4: fix shrinker scan budget accounting in ext4_es_scan()
Date: Wed, 30 Sep 2026 07:21:55 +0000 [thread overview]
Message-ID: <20260930072155.9483F1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260930-fix-ext4-es-scan-nr-scanned-v3-1-9aef0be87d21@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] ext4: premature SHRINK_STOP in ext4_es_scan() breaks LRU reclaim
--
commit 38269e532034036f670a12b2f9dedde4248280c0
Author: Qiliang Yuan <odys.yuan@gmail.com>
ext4: fix shrinker scan budget accounting in ext4_es_scan()
The extents_status shrinker's count_objects() callback reports the number of
shrinkable extent_status objects via a percpu counter. This patch returns
SHRINK_STOP when __es_shrink() frees nothing to prevent burning through the
scan budget against a stale freeable count.
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index 6e4a191e82191..d88af807d36e7 100644
> --- a/fs/ext4/extents_status.c
> +++ b/fs/ext4/extents_status.c
> @@ -1783,6 +1783,16 @@ static unsigned long ext4_es_scan(struct shrinker *shrink,
>
> ret = percpu_counter_read_positive(&sbi->s_es_stats.es_stats_shk_cnt);
> trace_ext4_es_shrink_scan_exit(sbi->s_sb, nr_shrunk, ret);
> +
> + /*
> + * es_stats_shk_cnt is a percpu counter, so it can stay positive
> + * after sbi->s_es_list has nothing left to give. Stop this reclaim
> + * pass once a call frees nothing, instead of burning through
> + * do_shrink_slab()'s scan budget against a stale count.
> + */
> + if (nr_shrunk == 0)
> + return SHRINK_STOP;
[Severity: High]
Does this prematurely abort the shrinker when scanning referenced items?
If __es_shrink() processes a full batch (e.g., 128 items) but all of them are
referenced, it clears their referenced bit (aging them) but frees none,
resulting in nr_shrunk == 0.
For example, in es_do_reclaim_extents():
(*nr_to_scan)--;
node = rb_next(&es->rb_node);
if (ext4_es_must_keep(es))
goto next;
if (ext4_es_is_referenced(es)) {
ext4_es_clear_referenced(es);
goto next;
}
Because scanning referenced or unfreeable extents correctly consumes the scan
budget without incrementing nr_shrunk, won't this conflate "scanned a batch of
hot items" with "the cache is empty", breaking the second-chance LRU algorithm
under memory pressure?
> return nr_shrunk;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260930-fix-ext4-es-scan-nr-scanned-v3-0-9aef0be87d21@gmail.com?part=1
next prev parent reply other threads:[~2026-09-30 7:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 7:11 [PATCH v3 0/2] ext4: fix shrinker scan budget accounting, plus a related cleanup Qiliang Yuan
2026-09-30 7:11 ` [PATCH v3 1/2] ext4: fix shrinker scan budget accounting in ext4_es_scan() Qiliang Yuan
2026-09-30 7:21 ` sashiko-bot [this message]
2026-09-30 17:42 ` Jan Kara
2026-09-30 7:11 ` [PATCH v3 2/2] ext4: remove unused locked_ei parameter from __es_shrink() Qiliang Yuan
2026-09-30 7:17 ` sashiko-bot
2026-09-30 17:34 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260930072155.9483F1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=odys.yuan@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox