Re: [PATCH 6/6] writeback: remove unneeded GDTC_INIT_NO_WB

From: Jan Kara
Date: Tue Mar 26 2024 - 08:35:23 EST


On Wed 20-03-24 19:02:22, Kemeng Shi wrote:
> We never use gdtc->dom set with GDTC_INIT_NO_WB, just remove unneeded
> GDTC_INIT_NO_WB
>
> Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>

Please no, this leaves a trap for the future. If anything, I'd teach
GDTC_INIT() that 'wb' can be NULL and replace GDTC_INIT_NO_WB with
GDTC_INIT(NULL).

Honza

> ---
> mm/page-writeback.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 481b6bf34c21..09b2b0754cc5 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -154,8 +154,6 @@ struct dirty_throttle_control {
> .dom = &global_wb_domain, \
> .wb_completions = &(__wb)->completions
>
> -#define GDTC_INIT_NO_WB .dom = &global_wb_domain
> -
> #define MDTC_INIT(__wb, __gdtc) .wb = (__wb), \
> .dom = mem_cgroup_wb_domain(__wb), \
> .wb_completions = &(__wb)->memcg_completions, \
> @@ -210,7 +208,6 @@ static void wb_min_max_ratio(struct bdi_writeback *wb,
>
> #define GDTC_INIT(__wb) .wb = (__wb), \
> .wb_completions = &(__wb)->completions
> -#define GDTC_INIT_NO_WB
> #define MDTC_INIT(__wb, __gdtc)
>
> static bool mdtc_valid(struct dirty_throttle_control *dtc)
> @@ -438,7 +435,7 @@ static void domain_dirty_limits(struct dirty_throttle_control *dtc)
> */
> void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty)
> {
> - struct dirty_throttle_control gdtc = { GDTC_INIT_NO_WB };
> + struct dirty_throttle_control gdtc = { };
>
> gdtc.avail = global_dirtyable_memory();
> domain_dirty_limits(&gdtc);
> @@ -895,7 +892,7 @@ unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh)
>
> unsigned long wb_calc_cg_thresh(struct bdi_writeback *wb)
> {
> - struct dirty_throttle_control gdtc = { GDTC_INIT_NO_WB };
> + struct dirty_throttle_control gdtc = { };
> struct dirty_throttle_control mdtc = { MDTC_INIT(wb, &gdtc) };
> unsigned long filepages, headroom, writeback;
>
> --
> 2.30.0
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR