From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Boris Burkov <boris@bur.io>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v4 4/4] btrfs: cap shrink_delalloc iterations to 128M
Date: Sat, 25 Apr 2026 08:29:43 +0930 [thread overview]
Message-ID: <3be1e1b5-ad4a-41bc-86e5-2be616b17352@gmx.com> (raw)
In-Reply-To: <8bf661bc-2536-4310-a5cc-638b5cd9d25c@gmx.com>
在 2026/4/25 07:51, Qu Wenruo 写道:
>
>
> 在 2026/4/25 07:40, Boris Burkov 写道:
>> On Sat, Apr 25, 2026 at 07:36:49AM +0930, Qu Wenruo wrote:
> [...]
>>> At least we got something that both of us can reproduce.
>>>
>>> Another thing is, for g/027 on arm64 I'm also actively monitoring the
>>> CPU
>>> usage through top.
>>>
>>> Have you experienced very high (~100%) CPU usage on a kworker during
>>> g/027?
>>>
>>
>> No :(
>> As far as I can tell the system is stuck waiting on a commit. I'll keep
>> trying to repro your symptom.
>>
>> I'm curious if it goes away for you with Sun's proposed fix, something
>> like setting pages to at least 1 after those to min() operations.
>
> I go with the following diff:
>
> diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
> index e931deb3d013..2c5214b24239 100644
> --- a/fs/btrfs/space-info.c
> +++ b/fs/btrfs/space-info.c
> @@ -770,6 +770,9 @@ static void shrink_delalloc(struct btrfs_space_info
> *space_info,
> u64 items = calc_reclaim_items_nr(fs_info,
> iter_reclaim) * 2;
> int async_pages;
>
> + if (nr_pages == 0)
> + nr_pages = 1;
> +
> btrfs_start_delalloc_roots(fs_info, nr_pages, true);
>
> /*
>
>
> It solves the dead looping kworker on arm64, now the it's several
> different kworkers taking around 5~15% along with 027 itself taking CPU
> time.
>
> But unfortunately the test case itself still seems not to end any time
> soon.
>
> I believe the old 3 loops limit is really what makes the difference.
> It's ugly, but at least it seems to work.
Not an expert on the space reclaim part, but as far as I understand,
there can be some cases where the only dirty folios that can be flushed
is the folios that are being written back.
E.g. we have a large folio (256KiB) dirty, and that's the only dirty
data folio in the whole fs.
Then at delalloc time, we are reserving metadata, and we are waiting for
the ticket to shrink delalloc.
Although the ticket is trying to flush delalloc, the 256KiB dirty folio
is already under write back, thus it will reclaim no space.
Thus the loop never progresses.
This will cause a semi-deadlock, as we want to reserve metadata to do
the folio writeback, but the metadata reserving is trying to flush the
same folio to progress.
And the recent huge folio feature is making the problem more obvious, as
the folios grow larger, we have higher chance to hit such situation.
With that said, it means delalloc shrinking is never guaranteed to make
any progress under extreme ENOSPC situation.
Thus a proper way to break out the loop is highly recommended, when
there is no progress to be done.
Hopes this educated guess would help to explain the problem.
Thanks,
Qu
>
> Thanks,
> Qu
>
next prev parent reply other threads:[~2026-04-24 22:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 17:48 [PATCH v4 0/4] btrfs: improve stalls under sudden writeback Boris Burkov
2026-04-09 17:48 ` [PATCH v4 1/4] btrfs: reserve space for delayed_refs in delalloc Boris Burkov
2026-04-10 16:07 ` Filipe Manana
2026-04-09 17:48 ` [PATCH v4 2/4] btrfs: account for compression in delalloc extent reservation Boris Burkov
2026-04-09 17:48 ` [PATCH v4 3/4] btrfs: make inode->outstanding_extents a u64 Boris Burkov
2026-04-13 18:43 ` David Sterba
2026-04-09 17:48 ` [PATCH v4 4/4] btrfs: cap shrink_delalloc iterations to 128M Boris Burkov
2026-04-24 6:38 ` Qu Wenruo
2026-04-24 9:48 ` Sun YangKai
2026-04-24 10:07 ` Qu Wenruo
2026-04-24 15:26 ` Boris Burkov
2026-04-24 20:11 ` Boris Burkov
2026-04-24 22:06 ` Qu Wenruo
2026-04-24 22:10 ` Boris Burkov
2026-04-24 22:21 ` Qu Wenruo
2026-04-24 22:23 ` Boris Burkov
2026-04-24 22:59 ` Qu Wenruo [this message]
2026-04-13 18:41 ` [PATCH v4 0/4] btrfs: improve stalls under sudden writeback David Sterba
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=3be1e1b5-ad4a-41bc-86e5-2be616b17352@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=boris@bur.io \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/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