mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Xin Yin" <yinxin.x@bytedance.com>
To: "Alexander Viro" <viro@zeniv.linux.org.uk>,
	 "Christian Brauner" <brauner@kernel.org>,
	"Jan Kara" <jack@suse.cz>
Cc: "Tejun Heo" <tj@kernel.org>, "Jens Axboe" <axboe@kernel.dk>,
	 <linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	 "Xin Yin" <yinxin.x@bytedance.com>
Subject: [PATCH v1 0/2] writeback: bound foreign dirty flushing
Date: Tue,  8 Sep 2026 11:23:50 +0800	[thread overview]
Message-ID: <cover.1788836830.git.yinxin.x@bytedance.com> (raw)

Hi,

We have seen production stalls where syncfs() and other writeback waiters
are blocked behind long-running WB_REASON_FOREIGN_FLUSH work on the same
bdi_writeback.  The foreign work is best-effort writeback for memcg
foreign dirtying, but on busy multi-device systems it can be much larger
or longer-lived than the dirty pages that are actually relevant to the
selected target wb.

There are two parts to the problem.  First, the foreign flush budget is
currently sized from the target memcg's global dirty counter, while the
queued work writes only one target wb.  This can over-size a single-bdi
flush when the target memcg has dirty pages on other devices, or under-size
it when dirty pages on the target wb are charged to other memcgs.

Second, the work can keep extending itself under sustained dirtying.  Even
though foreign flushes are best-effort WB_SYNC_NONE work, a large budget
plus continued dirtying can keep the target wb busy long enough to delay
later writeback work, including syncfs() on the same backing device.

This series keeps foreign flushing aligned with its best-effort reclaim
role:

  1. size the work from the selected wb's reclaimable pages, with the
     existing 25% headroom;
  2. make each foreign flush operate on a bounded snapshot of dirty
     inodes/pages, while preserving WB_SYNC_NONE semantics and the finite
     work budget.

Later dirtying remains the responsibility of later foreign flushes, kupdate,
or background writeback.  The changes are intended to bound one
foreign-flush work item without turning it into a data-integrity operation.

Xin Yin (2):
  writeback: size foreign flushes by target wb dirty pages
  writeback: snapshot foreign flush pages

 fs/fs-writeback.c         | 74 +++++++++++++++++++++++++++------------
 include/linux/writeback.h |  1 +
 2 files changed, 52 insertions(+), 23 deletions(-)


base-commit: 46b513250491a7bfc97d98791dbe6a10bcc8129d
-- 
2.20.1

             reply	other threads:[~2026-09-08  3:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08  3:23 Xin Yin [this message]
2026-09-08  3:23 ` [PATCH v1 1/2] writeback: size foreign flushes by target wb dirty pages Xin Yin
2026-09-08 10:44   ` Jan Kara
2026-09-08 19:47   ` Tejun Heo
2026-09-08  3:23 ` [PATCH v1 2/2] writeback: snapshot foreign flush pages Xin Yin
2026-09-08 11:01   ` Jan Kara
2026-09-09  2:08     ` 尹欣
2026-09-11 11:08       ` Jan Kara
2026-09-11 13:43         ` 尹欣

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=cover.1788836830.git.yinxin.x@bytedance.com \
    --to=yinxin.x@bytedance.com \
    --cc=axboe@kernel.dk \
    --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

all inboxes | Powered by JetHome®