Skip to content

Commit 0f1576e

Browse files
babumogerbp3tk0v
authored andcommitted
x86/resctrl: Configure mbm_event mode if supported
Configure mbm_event mode on AMD platforms. On AMD platforms, it is recommended to use the mbm_event mode, if supported, to prevent the hardware from resetting counters between reads. This can result in misleading values or display "Unavailable" if no counter is assigned to the event. Enable mbm_event mode, known as ABMC (Assignable Bandwidth Monitoring Counters) on AMD, by default if the system supports it. Update ABMC across all logical processors within the resctrl domain to ensure proper functionality. Signed-off-by: Babu Moger <babu.moger@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Link: https://lore.kernel.org/cover.1757108044.git.babu.moger@amd.com
1 parent 8004ea0 commit 0f1576e

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

arch/x86/kernel/cpu/resctrl/core.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,9 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)
520520
d = container_of(hdr, struct rdt_mon_domain, hdr);
521521

522522
cpumask_set_cpu(cpu, &d->hdr.cpu_mask);
523+
/* Update the mbm_assign_mode state for the CPU if supported */
524+
if (r->mon.mbm_cntr_assignable)
525+
resctrl_arch_mbm_cntr_assign_set_one(r);
523526
return;
524527
}
525528

@@ -539,6 +542,10 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)
539542
d->ci_id = ci->id;
540543
cpumask_set_cpu(cpu, &d->hdr.cpu_mask);
541544

545+
/* Update the mbm_assign_mode state for the CPU if supported */
546+
if (r->mon.mbm_cntr_assignable)
547+
resctrl_arch_mbm_cntr_assign_set_one(r);
548+
542549
arch_mon_domain_online(r, d);
543550

544551
if (arch_domain_mbm_alloc(r->mon.num_rmid, hw_dom)) {

arch/x86/kernel/cpu/resctrl/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,6 @@ bool rdt_cpu_has(int flag);
215215
void __init intel_rdt_mbm_apply_quirk(void);
216216

217217
void rdt_domain_reconfigure_cdp(struct rdt_resource *r);
218+
void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r);
218219

219220
#endif /* _ASM_X86_RESCTRL_INTERNAL_H */

arch/x86/kernel/cpu/resctrl/monitor.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
456456
r->mon.mbm_cntr_assignable = true;
457457
cpuid_count(0x80000020, 5, &eax, &ebx, &ecx, &edx);
458458
r->mon.num_mbm_cntrs = (ebx & GENMASK(15, 0)) + 1;
459+
hw_res->mbm_cntr_assign_enabled = true;
459460
}
460461

461462
r->mon_capable = true;
@@ -557,3 +558,10 @@ void resctrl_arch_config_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,
557558
if (am)
558559
memset(am, 0, sizeof(*am));
559560
}
561+
562+
void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r)
563+
{
564+
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
565+
566+
resctrl_abmc_set_one_amd(&hw_res->mbm_cntr_assign_enabled);
567+
}

0 commit comments

Comments
 (0)