Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Tony Luck and committed by
Borislav Petkov (AMD)
ab0308ae dd110880

+15 -5
+3 -3
arch/x86/kernel/cpu/resctrl/core.c
··· 902 902 bool ret = false; 903 903 904 904 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); 906 906 ret = true; 907 907 } 908 908 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); 910 910 ret = true; 911 911 } 912 912 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); 914 914 ret = true; 915 915 } 916 916 if (rdt_cpu_has(X86_FEATURE_ABMC))
+6
fs/resctrl/ctrlmondata.c
··· 578 578 } 579 579 } 580 580 581 + if (evt->any_cpu) { 582 + mon_event_count(rr); 583 + goto out_ctx_free; 584 + } 585 + 581 586 cpu = cpumask_any_housekeeping(cpumask, RESCTRL_PICK_ANY_CPU); 582 587 583 588 /* ··· 596 591 else 597 592 smp_call_on_cpu(cpu, smp_mon_event_count, rr, false); 598 593 594 + out_ctx_free: 599 595 if (rr->arch_mon_ctx) 600 596 resctrl_arch_mon_ctx_free(r, evt->evtid, rr->arch_mon_ctx); 601 597 }
+2
fs/resctrl/internal.h
··· 61 61 * READS_TO_REMOTE_MEM) being tracked by @evtid. 62 62 * Only valid if @evtid is an MBM event. 63 63 * @configurable: true if the event is configurable 64 + * @any_cpu: true if the event can be read from any CPU 64 65 * @enabled: true if the event is enabled 65 66 */ 66 67 struct mon_evt { ··· 70 69 char *name; 71 70 u32 evt_cfg; 72 71 bool configurable; 72 + bool any_cpu; 73 73 bool enabled; 74 74 }; 75 75
+3 -1
fs/resctrl/monitor.c
··· 518 518 { 519 519 switch (rr->r->rid) { 520 520 case RDT_RESOURCE_L3: 521 + WARN_ON_ONCE(rr->evt->any_cpu); 521 522 if (rr->hdr) 522 523 return __l3_mon_event_count(rdtgrp, rr); 523 524 else ··· 988 987 }, 989 988 }; 990 989 991 - void resctrl_enable_mon_event(enum resctrl_event_id eventid) 990 + void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu) 992 991 { 993 992 if (WARN_ON_ONCE(eventid < QOS_FIRST_EVENT || eventid >= QOS_NUM_EVENTS)) 994 993 return; ··· 997 996 return; 998 997 } 999 998 999 + mon_event_all[eventid].any_cpu = any_cpu; 1000 1000 mon_event_all[eventid].enabled = true; 1001 1001 } 1002 1002
+1 -1
include/linux/resctrl.h
··· 412 412 u32 resctrl_arch_system_num_rmid_idx(void); 413 413 int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid); 414 414 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); 416 416 417 417 bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid); 418 418