From: Tejun Heo <tj@kernel.org>
To: Liz Fong-Jones <lizf@honeycomb.io>
Cc: Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Jens Axboe <axboe@kernel.dk>,
Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Xin Yin <yinxin.x@bytedance.com>,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
ian@honeycomb.io
Subject: Re: [PATCH v2] writeback: let foreign flushes reach dying cgwbs
Date: Mon, 28 Sep 2026 13:30:04 -1000 [thread overview]
Message-ID: <6d0542fc07639c8df7672b12f4ecd906@kernel.org> (raw)
In-Reply-To: <20260928-wb-dying-cgwb-flush-v2-1-56b54cda74f2@honeycomb.io>
Hello, Liz.
On Mon, Sep 28, 2026 at 10:12:59PM +0000, Liz Fong-Jones wrote:
> + /* a newer wb may have taken the slot, see cgwb_create() */
> + spin_lock_irq(&cgwb_lock);
> + radix_tree_delete_item(&bdi->cgwb_tree, wb->memcg_css->id, wb);
> + spin_unlock_irq(&cgwb_lock);
Maybe use scoped_guard() here and move list_del(&wb->offline_node) from
further down into the same block?
> +static bool cgwb_dying(struct bdi_writeback *wb)
> +{
> + lockdep_assert_held(&cgwb_lock);
> +
> + return percpu_ref_is_dying(&wb->refcnt);
> +}
Can you drop this and use wb_dying() instead? Requiring lockdep for testing
an atomic state is a bit odd.
> +/*
> + * A killed wb stays in bdi->cgwb_tree until it is released, so that foreign
> + * flushes can still find it through wb_get_lookup(). Inodes attached to it
"until it is released or replaced in cgwb_create()"?
> wb = radix_tree_lookup(&bdi->cgwb_tree, memcg_css->id);
> - if (wb && wb->blkcg_css != blkcg_css) {
> + if (wb && !cgwb_dying(wb) && wb->blkcg_css != blkcg_css)
> cgwb_kill(wb);
> + if (wb && cgwb_dying(wb))
> wb = NULL;
> - }
Maybe filter out dying wbs right after the lookup and leave the mismatch
block as-is?
wb = radix_tree_lookup(&bdi->cgwb_tree, memcg_css->id);
if (wb && wb_dying(wb))
wb = NULL;
if (wb && wb->blkcg_css != blkcg_css) {
cgwb_kill(wb);
wb = NULL;
}
> + } else if (cgwb_dying(radix_tree_deref_slot_protected(slot,
> + &cgwb_lock))) {
> + radix_tree_replace_slot(&bdi->cgwb_tree, slot, wb);
> + ret = 0;
After the takeover, the old wb is out of foreign flushes' reach while its
inodes may still be dirty. Kicking writeback on it would move them over to
the new wb as they get written back. Can you add that as a separate patch
when posting the next version?
> radix_tree_for_each_slot(slot, &bdi->cgwb_tree, &iter, 0)
> - cgwb_kill(*slot);
> + if (!cgwb_dying(*slot))
> + cgwb_kill(*slot);
Can you add {} around the loop body?
Thanks.
--
tejun
next prev parent reply other threads:[~2026-09-28 23:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 22:12 Liz Fong-Jones
2026-09-28 23:30 ` Tejun Heo [this message]
2026-09-29 1:46 ` Liz Fong-Jones
2026-09-28 23:56 ` Andrew Morton
2026-09-29 1:46 ` Liz Fong-Jones
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=6d0542fc07639c8df7672b12f4ecd906@kernel.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=ian@honeycomb.io \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizf@honeycomb.io \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=viro@zeniv.linux.org.uk \
--cc=yinxin.x@bytedance.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®