on 3/26/2024 8:24 PM, Jan Kara wrote: > On Wed 20-03-24 19:02:18, Kemeng Shi wrote: >> Add /sys/kernel/debug/bdi/xxx/wb_stats to show per group writeback stats >> of bdi. >> >> Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx> > > ... > >> +unsigned long wb_calc_cg_thresh(struct bdi_writeback *wb) >> +{ >> + struct dirty_throttle_control gdtc = { GDTC_INIT_NO_WB }; >> + struct dirty_throttle_control mdtc = { MDTC_INIT(wb, &gdtc) }; >> + unsigned long filepages, headroom, writeback; >> + >> + gdtc.avail = global_dirtyable_memory(); >> + gdtc.dirty = global_node_page_state(NR_FILE_DIRTY) + >> + global_node_page_state(NR_WRITEBACK); >> + >> + mem_cgroup_wb_stats(wb, &filepages, &headroom, >> + &mdtc.dirty, &writeback); >> + mdtc.dirty += writeback; >> + mdtc_calc_avail(&mdtc, filepages, headroom); >> + domain_dirty_limits(&mdtc); >> + >> + return __wb_calc_thresh(&mdtc, mdtc.thresh); >> +} > > I kind of wish we didn't replicate this logic from balance_dirty_pages() > and wb_over_bg_thresh() into yet another place. But the refactoring would > be kind of difficult. So OK. Thanks for review the code. I have considered about this. It's difficult and will introduce a lot change to non-debug code which make this series uneasy to review. I will submit another patch for refactoring if I could find a way to clean the code. Kemeng > > Honza >