Message ID | 20240429034738.138609-5-shikemeng@huaweicloud.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Add helper functions to remove repeated code and | expand |
Hello, On Mon, Apr 29, 2024 at 11:47:32AM +0800, Kemeng Shi wrote: > Use [global/wb]_domain_dirty_avail helper in cgwb_calc_thresh to remove > repeated code. Maybe fold this into the patch to factor out domain_dirty_avail()? > + global_domain_dirty_avail(&gdtc, false); > + wb_domain_dirty_avail(&mdtc, false); I'd just use domain_dirty_avail(). The compiler should be able to figure out the branches and eliminate them and it removes an unnecessary source of error. Thanks.
on 5/2/2024 12:56 AM, Tejun Heo wrote: > Hello, > > On Mon, Apr 29, 2024 at 11:47:32AM +0800, Kemeng Shi wrote: >> Use [global/wb]_domain_dirty_avail helper in cgwb_calc_thresh to remove >> repeated code. > > Maybe fold this into the patch to factor out domain_dirty_avail()? > >> + global_domain_dirty_avail(&gdtc, false); >> + wb_domain_dirty_avail(&mdtc, false); > > I'd just use domain_dirty_avail(). The compiler should be able to figure out > the branches and eliminate them and it removes an unnecessary source of > error. Sure, will this do this in next version. Thanks. > > Thanks. >
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 28a29180fc9f..a1d48e8387ed 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -934,16 +934,9 @@ unsigned long cgwb_calc_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 = 0, headroom = 0, writeback = 0; - - 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); + global_domain_dirty_avail(&gdtc, false); + wb_domain_dirty_avail(&mdtc, false); domain_dirty_limits(&mdtc); return __wb_calc_thresh(&mdtc, mdtc.thresh);
Use [global/wb]_domain_dirty_avail helper in cgwb_calc_thresh to remove repeated code. Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> --- mm/page-writeback.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)