Skip to content

Commit 842e7f9

Browse files
aeglbp3tk0v
authored andcommitted
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
1 parent f4e0cd8 commit 842e7f9

4 files changed

Lines changed: 48 additions & 1 deletion

File tree

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6325,9 +6325,14 @@ Kernel parameters
63256325
rdt= [HW,X86,RDT]
63266326
Turn on/off individual RDT features. List is:
63276327
cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp,
6328-
mba, smba, bmec, abmc, sdciae.
6328+
mba, smba, bmec, abmc, sdciae, energy[:guid],
6329+
perf[:guid].
63296330
E.g. to turn on cmt and turn off mba use:
63306331
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
63316336

63326337
reboot= [KNL]
63336338
Format (x86 or x86_64):

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,8 @@ static int __init set_rdt_options(char *str)
814814
force_off = *tok == '!';
815815
if (force_off)
816816
tok++;
817+
if (intel_handle_aet_option(force_off, tok))
818+
continue;
817819
for (o = rdt_options; o < &rdt_options[NUM_RDT_OPTIONS]; o++) {
818820
if (strcmp(tok, o->name) == 0) {
819821
if (force_off)

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,17 @@ struct pmt_event {
5252
/**
5353
* struct event_group - Events with the same feature type ("energy" or "perf") and GUID.
5454
* @pfname: PMT feature name ("energy" or "perf") of this event group.
55+
* Used by boot rdt= option.
5556
* @pfg: Points to the aggregated telemetry space information
5657
* returned by the intel_pmt_get_regions_by_feature()
5758
* call to the INTEL_PMT_TELEMETRY driver that contains
5859
* data for all telemetry regions of type @pfname.
5960
* Valid if the system supports the event group,
6061
* 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.
6166
* @guid: Unique number per XML description file.
6267
* @mmio_size: Number of bytes of MMIO registers for this group.
6368
* @num_events: Number of events in this group.
@@ -67,6 +72,7 @@ struct event_group {
6772
/* Data fields for additional structures to manage this group. */
6873
const char *pfname;
6974
struct pmt_feature_group *pfg;
75+
bool force_off, force_on;
7076

7177
/* Remaining fields initialized from XML file. */
7278
u32 guid;
@@ -121,6 +127,35 @@ static struct event_group *known_event_groups[] = {
121127
_peg < &known_event_groups[ARRAY_SIZE(known_event_groups)]; \
122128
_peg++)
123129

130+
bool intel_handle_aet_option(bool force_off, char *tok)
131+
{
132+
struct event_group **peg;
133+
bool ret = false;
134+
u32 guid = 0;
135+
char *name;
136+
137+
if (!tok)
138+
return false;
139+
140+
name = strsep(&tok, ":");
141+
if (tok && kstrtou32(tok, 16, &guid))
142+
return false;
143+
144+
for_each_event_group(peg) {
145+
if (strcmp(name, (*peg)->pfname))
146+
continue;
147+
if (guid && (*peg)->guid != guid)
148+
continue;
149+
if (force_off)
150+
(*peg)->force_off = true;
151+
else
152+
(*peg)->force_on = true;
153+
ret = true;
154+
}
155+
156+
return ret;
157+
}
158+
124159
static bool skip_telem_region(struct telemetry_region *tr, struct event_group *e)
125160
{
126161
if (tr->guid != e->guid)
@@ -168,6 +203,9 @@ static bool enable_events(struct event_group *e, struct pmt_feature_group *p)
168203
struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_PERF_PKG].r_resctrl;
169204
int skipped_events = 0;
170205

206+
if (e->force_off)
207+
return false;
208+
171209
if (!group_has_usable_regions(e, p))
172210
return false;
173211

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ void __exit intel_aet_exit(void);
236236
int intel_aet_read_event(int domid, u32 rmid, void *arch_priv, u64 *val);
237237
void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_resource *r,
238238
struct list_head *add_pos);
239+
bool intel_handle_aet_option(bool force_off, char *tok);
239240
#else
240241
static inline bool intel_aet_get_events(void) { return false; }
241242
static inline void __exit intel_aet_exit(void) { }
@@ -246,6 +247,7 @@ static inline int intel_aet_read_event(int domid, u32 rmid, void *arch_priv, u64
246247

247248
static inline void intel_aet_mon_domain_setup(int cpu, int id, struct rdt_resource *r,
248249
struct list_head *add_pos) { }
250+
static inline bool intel_handle_aet_option(bool force_off, char *tok) { return false; }
249251
#endif
250252

251253
#endif /* _ASM_X86_RESCTRL_INTERNAL_H */

0 commit comments

Comments
 (0)