[RESEND PATCH v4 11/15] fs/resctrl: Program kernel-mode binding when CPU comes online

From: Babu Moger

Date: Tue Jul 07 2026 - 17:56:56 EST


Kernel-mode resctrl associations are programmed per CPU. When a
global-assign kernel-mode policy is selected, all CPUs that are online at
that time are configured; however, CPUs that come online later are not
automatically updated.

As a result, hot-added CPUs, or CPUs that were offline when the policy was
selected, can run without the active kernel-mode association even though
the resctrl policy is still in effect.

Add resctrl_kmode_online_cpu() and call it from resctrl_online_cpu(). When
a global-assign policy is active, add the newly online CPU to the bound
group's kmode_cpu_mask and program the kernel-mode association on that CPU.

Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
v4: New patch in the series. Patch taken from:
https://lore.kernel.org/lkml/20260611111706.1981788-5-qinyuntan@xxxxxxxxxxxxxxxxx/
Updated the code to enable kernel-mode by default whenever a CPU comes online when
one of global-assign mode is enabled.
---
fs/resctrl/rdtgroup.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 21659fd75850..413d3ff14546 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -4722,11 +4722,40 @@ int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_domain_hdr *hdr
return err;
}

+/*
+ * resctrl_kmode_online_cpu() - Configure kernel-mode binding for a CPU that
+ * comes online
+ * @cpu: CPU that has just been brought online.
+ *
+ * Kernel-mode associations are maintained per CPU. When a CPU becomes
+ * online after a global-assign policy has been applied, it is updated
+ * with the current kernel-mode configuration. The CPU is then added to
+ * the bound group's kmode_cpu_mask, and the appropriate association is
+ * programmed for it.
+ */
+static void resctrl_kmode_online_cpu(unsigned int cpu)
+{
+ struct rdtgroup *rdtgrp = resctrl_kcfg.k_rdtgrp;
+ bool assign_mon = false;
+
+ if (resctrl_kcfg.kmode_cur == INHERIT_CTRL_AND_MON || !rdtgrp)
+ return;
+
+ assign_mon = (resctrl_kcfg.kmode_cur == GLOBAL_ASSIGN_CTRL_ASSIGN_MON_PER_CPU);
+
+ cpumask_set_cpu(cpu, &rdtgrp->kmode_cpu_mask);
+
+ resctrl_arch_configure_kmode(cpumask_of(cpu), rdtgrp->closid, rdtgrp->mon.rmid,
+ assign_mon, true);
+}
+
void resctrl_online_cpu(unsigned int cpu)
{
mutex_lock(&rdtgroup_mutex);
/* The CPU is set in default rdtgroup after online. */
cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask);
+ /* Program any active kernel-mode binding on this CPU. */
+ resctrl_kmode_online_cpu(cpu);
mutex_unlock(&rdtgroup_mutex);
}

--
2.43.0