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/resctrl: Add energy/perf choices to rdt boot option

Legacy resctrl features are enumerated by X86_FEATURE_* flags. These may be
overridden by quirks to disable features in the case of errata. Users can use
kernel command line options to either disable a feature, or to force enable
a feature that was disabled by a quirk.

A different approach is needed for hardware features that do not have an
X86_FEATURE_* flag.

Update parsing of the "rdt=" boot parameter to call the telemetry driver
directly to handle new "perf" and "energy" options that controls activation of
telemetry monitoring of the named type. By itself a "perf" or "energy" option
controls the forced enabling or disabling (with ! prefix) of all event groups
of the named type. A ":guid" suffix allows for fine grained control per event
group.

[ bp: s/intel_aet_option/intel_handle_aet_option/g ]

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)
842e7f97 f4e0cd80

+48 -1
+6 -1
Documentation/admin-guide/kernel-parameters.txt
··· 6325 6325 rdt= [HW,X86,RDT] 6326 6326 Turn on/off individual RDT features. List is: 6327 6327 cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp, 6328 - mba, smba, bmec, abmc, sdciae. 6328 + mba, smba, bmec, abmc, sdciae, energy[:guid], 6329 + perf[:guid]. 6329 6330 E.g. to turn on cmt and turn off mba use: 6330 6331 rdt=cmt,!mba 6332 + To turn off all energy telemetry monitoring and ensure that 6333 + perf telemetry monitoring associated with guid 0x12345 6334 + is enabled use: 6335 + rdt=!energy,perf:0x12345 6331 6336 6332 6337 reboot= [KNL] 6333 6338 Format (x86 or x86_64):
+2
arch/x86/kernel/cpu/resctrl/core.c
··· 814 814 force_off = *tok == '!'; 815 815 if (force_off) 816 816 tok++; 817 + if (intel_handle_aet_option(force_off, tok)) 818 + continue; 817 819 for (o = rdt_options; o < &rdt_options[NUM_RDT_OPTIONS]; o++) { 818 820 if (strcmp(tok, o->name) == 0) { 819 821 if (force_off)
+38
arch/x86/kernel/cpu/resctrl/intel_aet.c
··· 52 52 /** 53 53 * struct event_group - Events with the same feature type ("energy" or "perf") and GUID. 54 54 * @pfname: PMT feature name ("energy" or "perf") of this event group. 55 + * Used by boot rdt= option. 55 56 * @pfg: Points to the aggregated telemetry space information 56 57 * returned by the intel_pmt_get_regions_by_feature() 57 58 * call to the INTEL_PMT_TELEMETRY driver that contains 58 59 * data for all telemetry regions of type @pfname. 59 60 * Valid if the system supports the event group, 60 61 * NULL otherwise. 62 + * @force_off: True when "rdt" command line or architecture code disables 63 + * this event group. 64 + * @force_on: True when "rdt" command line overrides disable of this 65 + * event group. 61 66 * @guid: Unique number per XML description file. 62 67 * @mmio_size: Number of bytes of MMIO registers for this group. 63 68 * @num_events: Number of events in this group. ··· 72 67 /* Data fields for additional structures to manage this group. */ 73 68 const char *pfname; 74 69 struct pmt_feature_group *pfg; 70 + bool force_off, force_on; 75 71 76 72 /* Remaining fields initialized from XML file. */ 77 73 u32 guid; ··· 127 121 _peg < &known_event_groups[ARRAY_SIZE(known_event_groups)]; \ 128 122 _peg++) 129 123 124 + bool intel_handle_aet_option(bool force_off, char *tok) 125 + { 126 + struct event_group **peg; 127 + bool ret = false; 128 + u32 guid = 0; 129 + char *name; 130 + 131 + if (!tok) 132 + return false; 133 + 134 + name = strsep(&tok, ":"); 135 + if (tok && kstrtou32(tok, 16, &guid)) 136 + return false; 137 + 138 + for_each_event_group(peg) { 139 + if (strcmp(name, (*peg)->pfname)) 140 + continue; 141 + if (guid && (*peg)->guid != guid) 142 + continue; 143 + if (force_off) 144 + (*peg)->force_off = true; 145 + else 146 + (*peg)->force_on = true; 147 + ret = true; 148 + } 149 + 150 + return ret; 151 + } 152 + 130 153 static bool skip_telem_region(struct telemetry_region *tr, struct event_group *e) 131 154 { 132 155 if (tr->guid != e->guid) ··· 202 167 { 203 168 struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_resctrl; 204 169 int skipped_events = 0; 170 + 171 + if (e->force_off) 172 + return false; 205 173 206 174 if (!group_has_usable_regions(e, p)) 207 175 return false;
+2
arch/x86/kernel/cpu/resctrl/internal.h
··· 236 236 int intel_aet_read_event(int domid, u32 rmid, void *arch_priv, u64 *val); 237 237 void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_resource *r, 238 238 struct list_head *add_pos); 239 + bool intel_handle_aet_option(bool force_off, char *tok); 239 240 #else 240 241 static inline bool intel_aet_get_events(void) { return false; } 241 242 static inline void __exit intel_aet_exit(void) { } ··· 247 246 248 247 static inline void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_resource *r, 249 248 struct list_head *add_pos) { } 249 + static inline bool intel_handle_aet_option(bool force_off, char *tok) { return false; } 250 250 #endif 251 251 252 252 #endif /* _ASM_X86_RESCTRL_INTERNAL_H */