Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/resctrl: Support monitor configuration

Add a new field in struct mon_evt to support Bandwidth Monitoring Event
Configuration (BMEC) and also update the "mon_features" display.

The resctrl file "mon_features" will display the supported events
and files that can be used to configure those events if monitor
configuration is supported.

Before the change:

$ cat /sys/fs/resctrl/info/L3_MON/mon_features
llc_occupancy
mbm_total_bytes
mbm_local_bytes

After the change when BMEC is supported:

$ cat /sys/fs/resctrl/info/L3_MON/mon_features
llc_occupancy
mbm_total_bytes
mbm_total_bytes_config
mbm_local_bytes
mbm_local_bytes_config

Signed-off-by: Babu Moger <babu.moger@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Link: https://lore.kernel.org/r/20230113152039.770054-9-babu.moger@amd.com

authored by

Babu Moger and committed by
Borislav Petkov (AMD)
d507f83c bd334c86

+13 -1
+2
arch/x86/kernel/cpu/resctrl/internal.h
··· 52 52 * struct mon_evt - Entry in the event list of a resource 53 53 * @evtid: event id 54 54 * @name: name of the event 55 + * @configurable: true if the event is configurable 55 56 * @list: entry in &rdt_resource->evt_list 56 57 */ 57 58 struct mon_evt { 58 59 enum resctrl_event_id evtid; 59 60 char *name; 61 + bool configurable; 60 62 struct list_head list; 61 63 }; 62 64
+7
arch/x86/kernel/cpu/resctrl/monitor.c
··· 800 800 if (ret) 801 801 return ret; 802 802 803 + if (rdt_cpu_has(X86_FEATURE_BMEC)) { 804 + if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) 805 + mbm_total_event.configurable = true; 806 + if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) 807 + mbm_local_event.configurable = true; 808 + } 809 + 803 810 l3_mon_evt_init(r); 804 811 805 812 r->mon_capable = true;
+4 -1
arch/x86/kernel/cpu/resctrl/rdtgroup.c
··· 998 998 struct rdt_resource *r = of->kn->parent->priv; 999 999 struct mon_evt *mevt; 1000 1000 1001 - list_for_each_entry(mevt, &r->evt_list, list) 1001 + list_for_each_entry(mevt, &r->evt_list, list) { 1002 1002 seq_printf(seq, "%s\n", mevt->name); 1003 + if (mevt->configurable) 1004 + seq_printf(seq, "%s_config\n", mevt->name); 1005 + } 1003 1006 1004 1007 return 0; 1005 1008 }