The per-bdi_writeback WB_DONTCACHE_DIRTY counter drives how much the flusher writes back in response to an IOCB_DONTCACHE kick, but it is not reported anywhere, so the DONTCACHE dirty backlog can only be inferred from MemFree/Cached movement. Report it as BdiDontcacheDirty in /sys/kernel/debug/bdi//stats and as WbDontcacheDirty in the per-wb stats, next to the Reclaimable line. Use wb_stat_sum() rather than wb_stat() to fold in the per-cpu batches: the flusher targets the summed value and small backlogs would otherwise read as zero. Fixes: 88d6f128d06d ("mm: track DONTCACHE dirty pages per bdi_writeback") Cc: Jeff Layton Cc: Jens Axboe Cc: Matthew Wilcox (Oracle) Cc: linux-mm@kvack.org Assisted-by: LLM Signed-off-by: Mike Snitzer --- mm/backing-dev.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 18e999053bae..b8a2c27e07fa 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -46,6 +46,7 @@ struct wb_stats { unsigned long nr_dirty_time; unsigned long nr_writeback; unsigned long nr_reclaimable; + unsigned long nr_dontcache_dirty; unsigned long nr_dirtied; unsigned long nr_written; unsigned long dirty_thresh; @@ -78,6 +79,12 @@ static void collect_wb_stats(struct wb_stats *stats, stats->nr_writeback += wb_stat(wb, WB_WRITEBACK); stats->nr_reclaimable += wb_stat(wb, WB_RECLAIMABLE); + /* + * Sum the per-cpu batches: the dontcache flusher targets this + * counter via wb_stat_sum() and small backlogs would otherwise + * read as zero here. + */ + stats->nr_dontcache_dirty += wb_stat_sum(wb, WB_DONTCACHE_DIRTY); stats->nr_dirtied += wb_stat(wb, WB_DIRTIED); stats->nr_written += wb_stat(wb, WB_WRITTEN); stats->wb_thresh += wb_calc_thresh(wb, stats->dirty_thresh); @@ -125,6 +132,7 @@ static int bdi_debug_stats_show(struct seq_file *m, void *v) seq_printf(m, "BdiWriteback: %10lu kB\n" "BdiReclaimable: %10lu kB\n" + "BdiDontcacheDirty: %10lu kB\n" "BdiDirtyThresh: %10lu kB\n" "DirtyThresh: %10lu kB\n" "BackgroundThresh: %10lu kB\n" @@ -139,6 +147,7 @@ static int bdi_debug_stats_show(struct seq_file *m, void *v) "state: %10lx\n", K(stats.nr_writeback), K(stats.nr_reclaimable), + K(stats.nr_dontcache_dirty), K(stats.wb_thresh), K(dirty_thresh), K(background_thresh), @@ -163,6 +172,7 @@ static void wb_stats_show(struct seq_file *m, struct bdi_writeback *wb, "WbCgIno: %10lu\n" "WbWriteback: %10lu kB\n" "WbReclaimable: %10lu kB\n" + "WbDontcacheDirty: %10lu kB\n" "WbDirtyThresh: %10lu kB\n" "WbDirtied: %10lu kB\n" "WbWritten: %10lu kB\n" @@ -179,6 +189,7 @@ static void wb_stats_show(struct seq_file *m, struct bdi_writeback *wb, #endif K(stats->nr_writeback), K(stats->nr_reclaimable), + K(stats->nr_dontcache_dirty), K(stats->wb_thresh), K(stats->nr_dirtied), K(stats->nr_written), -- 2.52.0