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: Add architectural event pointer

The resctrl file system layer passes the domain, RMID, and event id to the
architecture to fetch an event counter.

Fetching a telemetry event counter requires additional information that is
private to the architecture, for example, the offset into MMIO space from
where the counter should be read.

Add mon_evt::arch_priv that architecture can use for any private data related
to the event. The resctrl filesystem initializes mon_evt::arch_priv when the
architecture enables the event and passes it back to architecture when needing
to fetch an event counter.

Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
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)
8ccb1f8f 8f6b6ad6

+23 -10
+3 -3
arch/x86/kernel/cpu/resctrl/core.c
··· 918 918 bool ret = false; 919 919 920 920 if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) { 921 - resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, false, 0); 921 + resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, false, 0, NULL); 922 922 ret = true; 923 923 } 924 924 if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) { 925 - resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID, false, 0); 925 + resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID, false, 0, NULL); 926 926 ret = true; 927 927 } 928 928 if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) { 929 - resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID, false, 0); 929 + resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID, false, 0, NULL); 930 930 ret = true; 931 931 } 932 932 if (rdt_cpu_has(X86_FEATURE_ABMC))
+1 -1
arch/x86/kernel/cpu/resctrl/monitor.c
··· 240 240 241 241 int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *hdr, 242 242 u32 unused, u32 rmid, enum resctrl_event_id eventid, 243 - u64 *val, void *ignored) 243 + void *arch_priv, u64 *val, void *ignored) 244 244 { 245 245 struct rdt_hw_l3_mon_domain *hw_dom; 246 246 struct rdt_l3_mon_domain *d;
+4
fs/resctrl/internal.h
··· 66 66 * @binary_bits: number of fixed-point binary bits from architecture, 67 67 * only valid if @is_floating_point is true 68 68 * @enabled: true if the event is enabled 69 + * @arch_priv: Architecture private data for this event. 70 + * The @arch_priv provided by the architecture via 71 + * resctrl_enable_mon_event(). 69 72 */ 70 73 struct mon_evt { 71 74 enum resctrl_event_id evtid; ··· 80 77 bool is_floating_point; 81 78 unsigned int binary_bits; 82 79 bool enabled; 80 + void *arch_priv; 83 81 }; 84 82 85 83 extern struct mon_evt mon_event_all[QOS_NUM_EVENTS];
+10 -4
fs/resctrl/monitor.c
··· 137 137 struct rmid_entry *entry; 138 138 u32 idx, cur_idx = 1; 139 139 void *arch_mon_ctx; 140 + void *arch_priv; 140 141 bool rmid_dirty; 141 142 u64 val = 0; 142 143 144 + arch_priv = mon_event_all[QOS_L3_OCCUP_EVENT_ID].arch_priv; 143 145 arch_mon_ctx = resctrl_arch_mon_ctx_alloc(r, QOS_L3_OCCUP_EVENT_ID); 144 146 if (IS_ERR(arch_mon_ctx)) { 145 147 pr_warn_ratelimited("Failed to allocate monitor context: %ld", ··· 162 160 163 161 entry = __rmid_entry(idx); 164 162 if (resctrl_arch_rmid_read(r, &d->hdr, entry->closid, entry->rmid, 165 - QOS_L3_OCCUP_EVENT_ID, &val, 163 + QOS_L3_OCCUP_EVENT_ID, arch_priv, &val, 166 164 arch_mon_ctx)) { 167 165 rmid_dirty = true; 168 166 } else { ··· 458 456 rr->evt->evtid, &tval); 459 457 else 460 458 rr->err = resctrl_arch_rmid_read(rr->r, rr->hdr, closid, rmid, 461 - rr->evt->evtid, &tval, rr->arch_mon_ctx); 459 + rr->evt->evtid, rr->evt->arch_priv, 460 + &tval, rr->arch_mon_ctx); 462 461 if (rr->err) 463 462 return rr->err; 464 463 ··· 504 501 if (d->ci_id != rr->ci->id) 505 502 continue; 506 503 err = resctrl_arch_rmid_read(rr->r, &d->hdr, closid, rmid, 507 - rr->evt->evtid, &tval, rr->arch_mon_ctx); 504 + rr->evt->evtid, rr->evt->arch_priv, 505 + &tval, rr->arch_mon_ctx); 508 506 if (!err) { 509 507 rr->val += tval; 510 508 ret = 0; ··· 997 993 MON_EVENT(PMT_EVENT_UOPS_RETIRED, "uops_retired", RDT_RESOURCE_PERF_PKG, false), 998 994 }; 999 995 1000 - void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu, unsigned int binary_bits) 996 + void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu, 997 + unsigned int binary_bits, void *arch_priv) 1001 998 { 1002 999 if (WARN_ON_ONCE(eventid < QOS_FIRST_EVENT || eventid >= QOS_NUM_EVENTS || 1003 1000 binary_bits > MAX_BINARY_BITS)) ··· 1014 1009 1015 1010 mon_event_all[eventid].any_cpu = any_cpu; 1016 1011 mon_event_all[eventid].binary_bits = binary_bits; 1012 + mon_event_all[eventid].arch_priv = arch_priv; 1017 1013 mon_event_all[eventid].enabled = true; 1018 1014 } 1019 1015
+5 -2
include/linux/resctrl.h
··· 415 415 int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid); 416 416 417 417 void resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu, 418 - unsigned int binary_bits); 418 + unsigned int binary_bits, void *arch_priv); 419 419 420 420 bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid); 421 421 ··· 532 532 * only. 533 533 * @rmid: rmid of the counter to read. 534 534 * @eventid: eventid to read, e.g. L3 occupancy. 535 + * @arch_priv: Architecture private data for this event. 536 + * The @arch_priv provided by the architecture via 537 + * resctrl_enable_mon_event(). 535 538 * @val: result of the counter read in bytes. 536 539 * @arch_mon_ctx: An architecture specific value from 537 540 * resctrl_arch_mon_ctx_alloc(), for MPAM this identifies ··· 552 549 */ 553 550 int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *hdr, 554 551 u32 closid, u32 rmid, enum resctrl_event_id eventid, 555 - u64 *val, void *arch_mon_ctx); 552 + void *arch_priv, u64 *val, void *arch_mon_ctx); 556 553 557 554 /** 558 555 * resctrl_arch_rmid_read_context_check() - warn about invalid contexts