All of lore.kernel.org
 help / color / mirror / Atom feed
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 v7 3/3] writeback: switch a replaced cgwb's inodes to its successor
Date: Fri, 16 Oct 2026 12:43:04 -1000	[thread overview]
Message-ID: <97f9db644113ce22a7e302d1b79bcfd3@kernel.org> (raw)
In-Reply-To: <20261015-wb-dying-cgwb-flush-v7-3-9278d9ebaf5d@honeycomb.io>

On Thu, Oct 15, 2026 at 11:40:49AM +0000, Liz Fong-Jones wrote:
> When a live memcg's blkcg association changes, cgwb_create() replaces
> its killed wb in bdi->cgwb_tree. Foreign flushes for the memcg then
> find the new wb, but the inodes, dirty or not, are still attached to the
> old one, and they only move over as they are written back (see
> wbc_attach_and_unlock_inode()). Until then, other memcgs appending to
> those inodes stall in balance_dirty_pages().
>
> After the takeover, queue a work item that switches all inodes on the
> old wb's lists to the wb foreign flushes now find, like
> cleanup_offline_cgwb() does for b_attached and b_dirty_time, but
> including b_dirty, b_io and b_more_io. The switch carries the dirty and
> writeback page counts, so nothing needs to be written back first.
> cgwb_create() can run with interrupts disabled (folio_account_dirtied()
> -> inode_attach_wb()), so it only queues the work. A switch to the old
> wb that was queued before it was replaced can land after the work ran,
> so inode_switch_wbs_work_fn() queues the work again when the wb it
> switched inodes to is dying and no longer owns its slot. Inodes attached
> to the old wb but on none of its lists, such as one attached as the wb
> is replaced (see __inode_attach_wb()) or a clean one switched over from
> the root wb, still move over only when written back. If the successor is
> already gone, fall back like cleanup_offline_cgwb() does, to the nearest
> live ancestor's wb or the root wb.
>
> Since commit f6988c90671e ("writeback: bound cleanup_offline_cgwb()
> rescans by rotating scanned inodes"), the scan moves the inodes it walks
> to the newest end of each list, so hold wb_switch_rwsem for read across
> it, like the switches themselves. Otherwise a sync that has fixed its
> cutoff but not yet queued inodes can find older dirty inodes moved
> behind a newer one on b_dirty and return without writing them.
>
> Test: a live cgroup appends to 5000 files on XFS at 250MiB/s, io is
> disabled on its parent so its wb is killed, it creates a file (the
> takeover), and a sibling keeps appending to its files under a 4G parent
> limit. Worst lag of the sibling behind schedule over 30s, in three runs:
>
>   without this patch    9.1s   4.0s   1.0s
>   with this patch       1.7s   1.3s   1.0s
>
> Without this patch, moving the old wb's inodes over took up to 11s,
> first switch to last; with it, all 5001 were switched in a 23-35ms
> window, with up to 98MiB of the old cgroup's pages dirty.
>
> Suggested-by: Tejun Heo <tj@kernel.org>
> Assisted-by: Claude:claude-opus-5-5 checkpatch sparse
> Assisted-by: Claude:claude-fable-5-1
> Reviewed-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Liz Fong-Jones <lizf@honeycomb.io>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

      reply	other threads:[~2026-10-16 22:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 11:40 [PATCH v7 0/3] writeback: let foreign flushes reach dying cgwbs Liz Fong-Jones
2026-10-15 11:40 ` Liz Fong-Jones
2026-10-15 11:40 ` [PATCH v7 1/3] writeback: clear the old wb's dirty IO state after switching inodes Liz Fong-Jones
2026-10-15 11:40   ` Liz Fong-Jones
2026-10-15 11:40 ` [PATCH v7 2/3] writeback: let foreign flushes reach dying cgwbs Liz Fong-Jones
2026-10-15 11:40 ` [PATCH v7 3/3] writeback: switch a replaced cgwb's inodes to its successor Liz Fong-Jones
2026-10-16 22:43   ` Tejun Heo [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=97f9db644113ce22a7e302d1b79bcfd3@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.