Re: [PATCH v5 04/29] x86,fs/resctrl: Prepare for more monitor events

From: Luck, Tony
Date: Sun Jun 08 2025 - 18:00:12 EST


On Fri, Jun 06, 2025 at 05:45:58PM -0700, Fenghua Yu wrote:
[SNIP]

> > diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
> > index 819bc7a09327..4403a820db12 100644
> > --- a/arch/x86/kernel/cpu/resctrl/core.c
> > +++ b/arch/x86/kernel/cpu/resctrl/core.c
> > @@ -364,8 +364,8 @@ static void ctrl_domain_free(struct rdt_hw_ctrl_domain *hw_dom)
> > static void mon_domain_free(struct rdt_hw_mon_domain *hw_dom)
> > {
> > - kfree(hw_dom->arch_mbm_total);
> > - kfree(hw_dom->arch_mbm_local);
> > + for (int i = 0; i < QOS_NUM_L3_MBM_EVENTS; i++)
> > + kfree(hw_dom->arch_mbm_states[i]);
>
> Is it better to define a helper for_each_mon_event_idx(i)?
>
> #define for_each_mbm_event_idx(i) \
>
>     for (int i = 0; i < QOS_NUM_L3_MBM_EVENTS; i++)
>
> Then the above for loop can be simplified to:
>
>     for_each_mbm_event_idxd(i)
>
> kfree(hw_dom->arch_mbm_states[i]);
>
> The helper can be used in other places as well (see below).

I think there are only two places total. So maybe?

-Tony