Skip to content

Commit 6c2282d

Browse files
James Morsebp3tk0v
authored andcommitted
x86/resctrl: Handle throttle_mode for SMBA resources
Now that the visibility of throttle_mode is being managed by resctrl, it should consider resources other than MBA that may have a throttle_mode. SMBA is one such resource. Extend thread_throttle_mode_init() to check SMBA for a throttle_mode. Adding support for multiple resources means it is possible for a platform with both MBA and SMBA, but an undefined throttle_mode on one of them to make the file visible. Add the 'undefined' case to rdt_thread_throttle_mode_show(). Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com> Reviewed-by: Babu Moger <babu.moger@amd.com> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Amit Singh Tomar <amitsinght@marvell.com> # arm64 Tested-by: Shanker Donthineni <sdonthineni@nvidia.com> # arm64 Tested-by: Babu Moger <babu.moger@amd.com> Link: https://lore.kernel.org/r/20250311183715.16445-29-james.morse@arm.com
1 parent 373af4e commit 6c2282d

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

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

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,10 +1188,19 @@ static int rdt_thread_throttle_mode_show(struct kernfs_open_file *of,
11881188
struct resctrl_schema *s = of->kn->parent->priv;
11891189
struct rdt_resource *r = s->res;
11901190

1191-
if (r->membw.throttle_mode == THREAD_THROTTLE_PER_THREAD)
1191+
switch (r->membw.throttle_mode) {
1192+
case THREAD_THROTTLE_PER_THREAD:
11921193
seq_puts(seq, "per-thread\n");
1193-
else
1194+
return 0;
1195+
case THREAD_THROTTLE_MAX:
11941196
seq_puts(seq, "max\n");
1197+
return 0;
1198+
case THREAD_THROTTLE_UNDEFINED:
1199+
seq_puts(seq, "undefined\n");
1200+
return 0;
1201+
}
1202+
1203+
WARN_ON_ONCE(1);
11951204

11961205
return 0;
11971206
}
@@ -2066,12 +2075,24 @@ static struct rftype *rdtgroup_get_rftype_by_name(const char *name)
20662075

20672076
static void thread_throttle_mode_init(void)
20682077
{
2069-
struct rdt_resource *r_mba;
2078+
enum membw_throttle_mode throttle_mode = THREAD_THROTTLE_UNDEFINED;
2079+
struct rdt_resource *r_mba, *r_smba;
20702080

20712081
r_mba = resctrl_arch_get_resource(RDT_RESOURCE_MBA);
2072-
if (r_mba->membw.throttle_mode != THREAD_THROTTLE_UNDEFINED)
2073-
resctrl_file_fflags_init("thread_throttle_mode",
2074-
RFTYPE_CTRL_INFO | RFTYPE_RES_MB);
2082+
if (r_mba->alloc_capable &&
2083+
r_mba->membw.throttle_mode != THREAD_THROTTLE_UNDEFINED)
2084+
throttle_mode = r_mba->membw.throttle_mode;
2085+
2086+
r_smba = resctrl_arch_get_resource(RDT_RESOURCE_SMBA);
2087+
if (r_smba->alloc_capable &&
2088+
r_smba->membw.throttle_mode != THREAD_THROTTLE_UNDEFINED)
2089+
throttle_mode = r_smba->membw.throttle_mode;
2090+
2091+
if (throttle_mode == THREAD_THROTTLE_UNDEFINED)
2092+
return;
2093+
2094+
resctrl_file_fflags_init("thread_throttle_mode",
2095+
RFTYPE_CTRL_INFO | RFTYPE_RES_MB);
20752096
}
20762097

20772098
void resctrl_file_fflags_init(const char *config, unsigned long fflags)

0 commit comments

Comments
 (0)