Re: [PATCH v13 10/25] fs/resctrl: Remove redundant calls to resctrl_mon_capable()

From: Luck, Tony

Date: Mon Oct 19 2026 - 15:37:12 EST


Hi Chenyu,

Thanks for looking at this.

On Mon, Oct 19, 2026 at 11:31:40PM +0800, Chen Yu wrote:
> Hi Tony,
>
> On Mon, Sep 28, 2026 at 03:14:54PM -0700, Tony Luck wrote:
> > resctrl_mon_capable() indicates whether any monitoring resources
> > are enabled on the system. It does this by scanning all resources.
> >
> > Redundant calls to resctrl_mon_capable() in hot code paths should
> > be eliminated. There are two prime examples:
> >
> > 1) mbm_handle_overflow()
> > This function is called once per second from worker threads running on
> > each L3 domain. resctrl_mon_capable() is clearly redundant because worker
> > threads are only created if the MBM monitoring feature is enabled.
> >
> > 2) is_rmid_match()
> > This is called for every task on the system so making it less expensive is
> > appealing.
>
> Nit: since patch 7 turns resctrl_mon_capable() into a resource scan and this
> patch then drops it, would it be worth moving this patch before patch 7 so
> there's no intermediate window between these two commits where these callers
> pay the extra cost?

Before patch 7 the overhead (on x86) was negligible so not a good reason
to make this change. Agreed that there is extra overhead until this
patch is applied. But since the series will go in together, that would
only be seen by an unlucky bisection that picks a commit in between
patches 7 and 10.

> thanks,
> Chenyu
>
> > resctrl_mon_capable() is redundant because the function also
> > checks "r->type == RDTMON_GROUP" and this type of group can only be created
> > on systems that support monitoring.
> >
> > Remove the call to resctrl_mon_capable() from each of these functions.
> >
> > Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>

-Tony