Add a no_stats_accounting bitfield to wbc that callers can set. Hook this up to __folio_clear_dirty_for_io() when preparing writeback. Signed-off-by: Joanne Koong <joannelkoong@xxxxxxxxx> --- include/linux/writeback.h | 3 +++ mm/page-writeback.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 34afa6912a1c..000795a47cb3 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -72,6 +72,9 @@ struct writeback_control { */ unsigned no_cgroup_owner:1; + /* Do not do any stats accounting. The caller will do this themselves */ + unsigned no_stats_accounting:1; + /* To enable batching of swap writes to non-block-device backends, * "plug" can be set point to a 'struct swap_iocb *'. When all swap * writes have been submitted, if with swap_iocb is not NULL, diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 77a46bf8052f..c1fec76ee869 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2404,6 +2404,7 @@ void tag_pages_for_writeback(struct address_space *mapping, } EXPORT_SYMBOL(tag_pages_for_writeback); +static bool __folio_clear_dirty_for_io(struct folio *folio, bool update_stats); static bool folio_prepare_writeback(struct address_space *mapping, struct writeback_control *wbc, struct folio *folio) { @@ -2430,7 +2431,7 @@ static bool folio_prepare_writeback(struct address_space *mapping, } BUG_ON(folio_test_writeback(folio)); - if (!folio_clear_dirty_for_io(folio)) + if (!__folio_clear_dirty_for_io(folio, !wbc->no_stats_accounting)) return false; return true; -- 2.47.3