Skip to content

Commit 3b49c37

Browse files
aeglbp3tk0v
authored andcommitted
x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
Resctrl uses local memory bandwidth event as input to the feedback loop when the mba_MBps mount option is used. This means that this mount option cannot be used on systems that only support monitoring of total bandwidth. Prepare to allow users to choose the input event independently for each CTRL_MON group by adding a global variable "mba_mbps_default_event" used to set the default event for each CTRL_MON group, and a new field "mba_mbps_event" in struct rdtgroup to track which event is used for each CTRL_MON group. Notes: 1) Both of these are only used when the user mounts the filesystem with the "mba_MBps" option. 2) Only check for support of local bandwidth event when initializing mba_mbps_default_event. Support for total bandwidth event can be added after other routines in resctrl have been updated to handle total bandwidth event. [ bp: Move mba_mbps_default_event extern into the arch header. ] Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Tested-by: Babu Moger <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2937f9c commit 3b49c37

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,9 @@ static __init bool get_rdt_mon_resources(void)
963963
if (!rdt_mon_features)
964964
return false;
965965

966+
if (is_mbm_local_enabled())
967+
mba_mbps_default_event = QOS_L3_MBM_LOCAL_EVENT_ID;
968+
966969
return !rdt_get_mon_l3_config(r);
967970
}
968971

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ struct pseudo_lock_region {
283283
* monitor only or ctrl_mon group
284284
* @mon: mongroup related data
285285
* @mode: mode of resource group
286+
* @mba_mbps_event: input monitoring event id when mba_sc is enabled
286287
* @plr: pseudo-locked region
287288
*/
288289
struct rdtgroup {
@@ -295,6 +296,7 @@ struct rdtgroup {
295296
enum rdt_group_type type;
296297
struct mongroup mon;
297298
enum rdtgrp_mode mode;
299+
enum resctrl_event_id mba_mbps_event;
298300
struct pseudo_lock_region *plr;
299301
};
300302

@@ -508,6 +510,7 @@ extern struct mutex rdtgroup_mutex;
508510
extern struct rdt_hw_resource rdt_resources_all[];
509511
extern struct rdtgroup rdtgroup_default;
510512
extern struct dentry *debugfs_resctrl;
513+
extern enum resctrl_event_id mba_mbps_default_event;
511514

512515
enum resctrl_res_level {
513516
RDT_RESOURCE_L3,
@@ -651,5 +654,4 @@ void resctrl_file_fflags_init(const char *config, unsigned long fflags);
651654
void rdt_staged_configs_clear(void);
652655
bool closid_allocated(unsigned int closid);
653656
int resctrl_find_cleanest_closid(void);
654-
655657
#endif /* _ASM_X86_RESCTRL_INTERNAL_H */

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ static void rdtgroup_destroy_root(void);
6565

6666
struct dentry *debugfs_resctrl;
6767

68+
/*
69+
* Memory bandwidth monitoring event to use for the default CTRL_MON group
70+
* and each new CTRL_MON group created by the user. Only relevant when
71+
* the filesystem is mounted with the "mba_MBps" option so it does not
72+
* matter that it remains uninitialized on systems that do not support
73+
* the "mba_MBps" option.
74+
*/
75+
enum resctrl_event_id mba_mbps_default_event;
76+
6877
static bool resctrl_debug;
6978

7079
void rdt_last_cmd_clear(void)
@@ -2353,6 +2362,8 @@ static int set_mba_sc(bool mba_sc)
23532362

23542363
r->membw.mba_sc = mba_sc;
23552364

2365+
rdtgroup_default.mba_mbps_event = mba_mbps_default_event;
2366+
23562367
list_for_each_entry(d, &r->ctrl_domains, hdr.list) {
23572368
for (i = 0; i < num_closid; i++)
23582369
d->mbps_val[i] = MBA_MAX_MBPS;
@@ -3611,6 +3622,8 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,
36113622
rdt_last_cmd_puts("kernfs subdir error\n");
36123623
goto out_del_list;
36133624
}
3625+
if (is_mba_sc(NULL))
3626+
rdtgrp->mba_mbps_event = mba_mbps_default_event;
36143627
}
36153628

36163629
goto out_unlock;

0 commit comments

Comments
 (0)