mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baokun Li <libaokun@linux.alibaba.com>
To: Christian Brauner <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
	jack@suse.cz, tj@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] writeback: use a per-sb counter to drain inode wb switches at umount
Date: Mon, 18 May 2026 19:52:37 +0800	[thread overview]
Message-ID: <e1308815-c650-4b8e-bdf4-0e36d0e2458f@linux.alibaba.com> (raw)
In-Reply-To: <177910456953.488929.2169908940676707307.b4-review@b4>

在 2026/5/18 19:42, Christian Brauner 写道:
> On Sun, 17 May 2026 22:21:32 +0800, Baokun Li <libaokun@linux.alibaba.com> wrote:
>> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
>> index 9ae290547eb2..4282fcfe027b 100644
>> --- a/fs/fs-writeback.c
>> +++ b/fs/fs-writeback.c
>> @@ -1215,38 +1209,30 @@ int cgroup_writeback_by_id(u64 bdi_id, int memcg_id,
>> [ ... skip 38 lines ... ]
>> -		 * in-flight switcher that already passed the SB_ACTIVE check
>> -		 * to finish queueing its work, so flush_workqueue() below
>> -		 * will then drain it.
>> -		 */
>> -		synchronize_rcu();
>> +	while (atomic_read(&sb->s_isw_nr_in_flight)) {
> Would probably be a bit nicer to just wait until the count is zero?
> We have that pattern for inode_dio_wait(). So something like (untested):
>
> static bool cgroup_writeback_finished(const struct super_block *sb)
> {
> 	if (atomic_read(&sb->s_isw_nr_in_flight) == 0)
> 		return true;
>
>    	flush_workqueue(isw_wq);
> 	return false;
> }
>
> void cgroup_writeback_wait(const struct super_block *sb)
> {
> 	wait_var_event(&sb->s_isw_nr_in_flight, cgroup_writeback_finished(sb));
> }
>
> void cgroup_writeback_finish(const struct super_block *sb)
> {
> 	if (atomic_dec_and_test(&sb->s_isw_nr_in_flight))
> 		wake_up_var(&sb->s_isw_nr_in_flight);
> }
>

Thank you for your suggestion!

Totally agree. sashiko also raised similar opinions, and
I will send out the v3 patch using this proposal right away.


Cheers,
Baokun


      reply	other threads:[~2026-05-18 11:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-17 14:21 [PATCH v2 0/3] writeback: fix race between cgroup_writeback_umount() and inode_switch_wbs() Baokun Li
2026-05-17 14:21 ` [PATCH v2 1/3] " Baokun Li
2026-05-18 12:58   ` Jan Kara
2026-05-17 14:21 ` [PATCH v2 2/3] writeback: drop now-unnecessary rcu_barrier() in cgroup_writeback_umount() Baokun Li
2026-05-18 13:01   ` Jan Kara
2026-05-18 13:10     ` Baokun Li
2026-05-18 15:11       ` Jan Kara
2026-05-17 14:21 ` [PATCH v2 3/3] writeback: use a per-sb counter to drain inode wb switches at umount Baokun Li
2026-05-18 11:14   ` Baokun Li
2026-05-18 11:42   ` Christian Brauner
2026-05-18 11:52     ` Baokun Li [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=e1308815-c650-4b8e-bdf4-0e36d0e2458f@linux.alibaba.com \
    --to=libaokun@linux.alibaba.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

Powered by JetHome