Skip to content

Commit ab0308a

Browse files
aeglbp3tk0v
authored andcommitted
x86,fs/resctrl: Handle events that can be read from any CPU
resctrl assumes that monitor events can only be read from a CPU in the cpumask_t set of each domain. This is true for x86 events accessed with an MSR interface, but may not be true for other access methods such as MMIO. Introduce and use flag mon_evt::any_cpu, settable by architecture, that indicates there are no restrictions on which CPU can read that event. This flag is not supported by the L3 event reading that requires to be run on a CPU that belongs to the L3 domain of the event being read. Signed-off-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Link: https://lore.kernel.org/20251217172121.12030-1-tony.luck@intel.com
1 parent dd11088 commit ab0308a

5 files changed

Lines changed: 15 additions & 5 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -902,15 +902,15 @@ static __init bool get_rdt_mon_resources(void)
902902
bool ret = false;
903903

904904
if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) {
905-
resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID);
905+
resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, false);
906906
ret = true;
907907
}
908908
if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) {
909-
resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID);
909+
resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID, false);
910910
ret = true;
911911
}
912912
if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) {
913-
resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID);
913+
resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID, false);
914914
ret = true;
915915
}
916916
if (rdt_cpu_has(X86_FEATURE_ABMC))

fs/resctrl/ctrlmondata.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,11 @@ void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
578578
}
579579
}
580580

581+
if (evt->any_cpu) {
582+
mon_event_count(rr);
583+
goto out_ctx_free;
584+
}
585+
581586
cpu = cpumask_any_housekeeping(cpumask, RESCTRL_PICK_ANY_CPU);
582587

583588
/*
@@ -591,6 +596,7 @@ void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
591596
else
592597
smp_call_on_cpu(cpu, smp_mon_event_count, rr, false);
593598

599+
out_ctx_free:
594600
if (rr->arch_mon_ctx)
595601
resctrl_arch_mon_ctx_free(r, evt->evtid, rr->arch_mon_ctx);
596602
}

fs/resctrl/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc)
6161
* READS_TO_REMOTE_MEM) being tracked by @evtid.
6262
* Only valid if @evtid is an MBM event.
6363
* @configurable: true if the event is configurable
64+
* @any_cpu: true if the event can be read from any CPU
6465
* @enabled: true if the event is enabled
6566
*/
6667
struct mon_evt {
@@ -69,6 +70,7 @@ struct mon_evt {
6970
char *name;
7071
u32 evt_cfg;
7172
bool configurable;
73+
bool any_cpu;
7274
bool enabled;
7375
};
7476

fs/resctrl/monitor.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ static int __mon_event_count(struct rdtgroup *rdtgrp, struct rmid_read *rr)
518518
{
519519
switch (rr->r->rid) {
520520
case RDT_RESOURCE_L3:
521+
WARN_ON_ONCE(rr->evt->any_cpu);
521522
if (rr->hdr)
522523
return __l3_mon_event_count(rdtgrp, rr);
523524
else
@@ -987,7 +988,7 @@ struct mon_evt mon_event_all[QOS_NUM_EVENTS] = {
987988
},
988989
};
989990

990-
void resctrl_enable_mon_event(enum resctrl_event_id eventid)
991+
void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu)
991992
{
992993
if (WARN_ON_ONCE(eventid < QOS_FIRST_EVENT || eventid >= QOS_NUM_EVENTS))
993994
return;
@@ -996,6 +997,7 @@ void resctrl_enable_mon_event(enum resctrl_event_id eventid)
996997
return;
997998
}
998999

1000+
mon_event_all[eventid].any_cpu = any_cpu;
9991001
mon_event_all[eventid].enabled = true;
10001002
}
10011003

include/linux/resctrl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *r);
412412
u32 resctrl_arch_system_num_rmid_idx(void);
413413
int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid);
414414

415-
void resctrl_enable_mon_event(enum resctrl_event_id eventid);
415+
void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu);
416416

417417
bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid);
418418

0 commit comments

Comments
 (0)