[PATCH v12 09/25] fs/resctrl: Remove redundant calls to resctrl_{alloc,mon}_capable()
From: Tony Luck
Date: Wed Sep 16 2026 - 19:21:08 EST
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. 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.
3) is_closid_match()
The call to resctrl_alloc_capable() is not just redundant, it is wrong.
On systems that only support monitoring it results in no tasks reported
in the "tasks" file of the resctrl root directory.
Remove the call to resctrl_{alloc,mon}_capable() from each of these functions.
Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
---
v12:
updated is_closid_match() per report by Sashiko
s/resctrl_arch_mon_capable/resctrl_mon_capable/
Removed unnecessary line break.
---
fs/resctrl/monitor.c | 2 +-
fs/resctrl/rdtgroup.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index 362737e13cd3..02e81fc82b14 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -888,7 +888,7 @@ void mbm_handle_overflow(struct work_struct *work)
* If the filesystem has been unmounted this work no longer needs to
* run.
*/
- if (!resctrl_mounted || !resctrl_mon_capable())
+ if (!resctrl_mounted)
goto out_unlock;
/*
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 79977200b1a0..c0b86ce05e50 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -685,13 +685,13 @@ static int __rdtgroup_move_task(struct task_struct *tsk,
static bool is_closid_match(struct task_struct *t, struct rdtgroup *r)
{
- return (resctrl_alloc_capable() && (r->type == RDTCTRL_GROUP) &&
+ return (r->type == RDTCTRL_GROUP &&
resctrl_arch_match_closid(t, r->closid));
}
static bool is_rmid_match(struct task_struct *t, struct rdtgroup *r)
{
- return (resctrl_mon_capable() && (r->type == RDTMON_GROUP) &&
+ return (r->type == RDTMON_GROUP &&
resctrl_arch_match_rmid(t, r->mon.parent->closid,
r->mon.rmid));
}
--
2.55.0