2024-04-29 03:48:14

by Kemeng Shi

[permalink] [raw]
Subject: [PATCH 04/10] writeback use [global/wb]_domain_dirty_avail helper in cgwb_calc_thresh

Use [global/wb]_domain_dirty_avail helper in cgwb_calc_thresh to remove
repeated code.

Signed-off-by: Kemeng Shi <[email protected]>
---
mm/page-writeback.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)

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);
--
2.30.0



2024-05-01 16:57:36

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH 04/10] writeback use [global/wb]_domain_dirty_avail helper in cgwb_calc_thresh

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.

--
tejun

2024-05-06 01:36:38

by Kemeng Shi

[permalink] [raw]
Subject: Re: [PATCH 04/10] writeback use [global/wb]_domain_dirty_avail helper in cgwb_calc_thresh



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.
>