From: Zhang Yi <yizhang089@gmail.com>
To: Jan Kara <jack@suse.cz>, Zhang Yi <yi.zhang@huaweicloud.com>
Cc: Qiliang Yuan <odys.yuan@gmail.com>, Theodore Ts'o <tytso@mit.edu>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Baokun Li <libaokun@linux.alibaba.com>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
Ojaswin Mujoo <ojaswin@linux.ibm.com>,
Zhang Yi <yi.zhang@huawei.com>,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] ext4: fix shrinker scan budget accounting in ext4_es_scan()
Date: Thu, 1 Oct 2026 21:03:01 +0800 [thread overview]
Message-ID: <eb3d1d25-dfeb-4bf5-bd66-95216a5cb87b@gmail.com> (raw)
In-Reply-To: <shfd6lmgopxqvcwaq6dqrm2x4ovlnzvspmatpqxtaf6wmb7z5p@lqog5ma575x7>
On 9/30/2026 7:48 PM, Jan Kara wrote:
> On Wed 30-09-26 09:45:26, Zhang Yi wrote:
>> On 9/29/2026 10:20 AM, Qiliang Yuan wrote:
>>> @@ -1774,15 +1777,41 @@ static unsigned long ext4_es_scan(struct shrinker *shrink,
>>> {
>>> struct ext4_sb_info *sbi = shrink->private_data;
>>> int nr_to_scan = sc->nr_to_scan;
>>> - int ret, nr_shrunk;
>>> + int ret, nr_shrunk, nr_scanned;
>>>
>>> ret = percpu_counter_read_positive(&sbi->s_es_stats.es_stats_shk_cnt);
>>> trace_ext4_es_shrink_scan_enter(sbi->s_sb, nr_to_scan, ret);
>>>
>>> - nr_shrunk = __es_shrink(sbi, nr_to_scan, NULL);
>>> + nr_shrunk = __es_shrink(sbi, nr_to_scan, NULL, &nr_scanned);
>>> + sc->nr_scanned = nr_scanned;
>>
>>
>> I'm a bit concerned that modifying sc->nr_scanned here could actually
>> end up increasing the number of scan_objects() calls in real-world
>> usage. If there are other background processes running and continuously
>> accessing certain files, they may keep producing a small number of new
>> reclaimable extent caches. That would mean nr_scanned stays at a
>> relatively small value on each iteration and never drops to 0, so
>> shrinker->scan_objects() may end up going through more loops because it
>> can't return SHRINK_STOP. So I'd tend to leave shrinkctl->nr_scanned
>> alone. What do you think?
>
> Well, I agree but lying to upper layers about the number of objects we have
> scanned doesn't look like a proper solution? We could return SHRINK_STOP
> when we scanned everything before nr_to_walk dropped to 0. It isn't perfect
> but would somewhat address your concern...
>
> Honza
>
Yeah, that sounds good to me.
Thanks,
Yi.
prev parent reply other threads:[~2026-10-01 13:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 2:20 Qiliang Yuan
2026-09-30 1:45 ` Zhang Yi
2026-09-30 11:48 ` Jan Kara
2026-10-01 13:03 ` Zhang Yi [this message]
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=eb3d1d25-dfeb-4bf5-bd66-95216a5cb87b@gmail.com \
--to=yizhang089@gmail.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=libaokun@linux.alibaba.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=odys.yuan@gmail.com \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.com \
--cc=yi.zhang@huaweicloud.com \
/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
all inboxes | Powered by JetHome®