Linux block layer
 help / color / mirror / Atom feed
* [PATCH v4 0/3] memcg,writeback: flush foreign bdev mappings separately
@ 2026-09-14 10:31 Julian Sun
  2026-09-14 10:31 ` [PATCH v4 1/3] block: introduce bdev_flush_by_dev() Julian Sun
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Julian Sun @ 2026-09-14 10:31 UTC (permalink / raw)
  To: linux-block, linux-fsdevel
  Cc: axboe, hannes, mhocko, roman.gushchin, shakeel.butt, muchun.song,
	willy, jack, rostedt, tj, akpm

Bdev inodes are routinely shared by multiple memcgs. Recording their
owner wb as foreign can cause dirty throttling in one memcg to trigger
writeback of unrelated file data belonging to that wb.

On one production machine, bdev mapping snapshots showed as little
as about 10 MiB of dirty data. A queue snapshot of its owner wb showed
599 foreign-flush works, with an average requested writeback budget of
43 GiB per work.

In other words, a small amount of foreign dirtying in the bdev mapping
can trigger owner-wide writeback requests, whose budgets averaged
43 GiB in this queue snapshot.

Following Jan's suggestion, this series records foreign bdev targets
separately and flushes their mappings instead of their owner wbs. This
preserves a way for dirty throttling to initiate bdev writeback while
avoiding owner-wide writeback triggered by these records. The existing
foreign-wb mechanism remains unchanged for other inodes.

Tracking is best effort: each memcg keeps a bounded set of device
numbers without persistent device or inode references. Closed devices
and devices with a busy open_mutex are skipped. Device removal and
device-number reuse may race with lookup.

Flushes run asynchronously on a dedicated workqueue to isolate these
frequently triggered tasks from existing workqueue users. If workqueue
allocation fails, the existing foreign-wb mechanism remains in use.

Julian Sun (3):
  block: introduce bdev_flush_by_dev()
  memcg,writeback: flush foreign bdev mappings separately from owner wbs
  writeback: record bdev targets in foreign writeback tracepoints

 block/bdev.c                     |  24 +++++++
 include/linux/blkdev.h           |   1 +
 include/linux/memcontrol.h       |  15 ++++
 include/trace/events/writeback.h |  22 +++---
 mm/memcontrol.c                  | 113 ++++++++++++++++++++++++++++---
 5 files changed, 157 insertions(+), 18 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-09-15  6:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-14 10:31 [PATCH v4 0/3] memcg,writeback: flush foreign bdev mappings separately Julian Sun
2026-09-14 10:31 ` [PATCH v4 1/3] block: introduce bdev_flush_by_dev() Julian Sun
2026-09-14 10:31 ` [PATCH v4 2/3] memcg,writeback: flush foreign bdev mappings separately from owner wbs Julian Sun
2026-09-14 10:31 ` [PATCH v4 3/3] writeback: record bdev targets in foreign writeback tracepoints Julian Sun
2026-09-15  3:59 ` [PATCH v4 0/3] memcg,writeback: flush foreign bdev mappings separately Andrew Morton
2026-09-15  5:35   ` Julian Sun
2026-09-15  6:06     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox