]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs/resctrl: Introduce event configuration field in struct mon_evt
authorBabu Moger <babu.moger@amd.com>
Fri, 5 Sep 2025 21:34:14 +0000 (16:34 -0500)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 15 Sep 2025 10:18:31 +0000 (12:18 +0200)
When supported, mbm_event counter assignment mode allows the user to configure
events to track specific types of memory transactions.

Introduce an evt_cfg field in struct mon_evt to define the type of memory
transactions tracked by a monitoring event. Also add a helper function to get
the evt_cfg value.

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/cover.1757108044.git.babu.moger@amd.com
fs/resctrl/internal.h
fs/resctrl/monitor.c
include/linux/resctrl.h

index 4f372e80bf373835fc830e3405e315289ffb6374..1cddfff007a24f4f4d2a450053dac5ea2c273273 100644 (file)
@@ -56,6 +56,10 @@ static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc)
  * @evtid:             event id
  * @rid:               resource id for this event
  * @name:              name of the event
+ * @evt_cfg:           Event configuration value that represents the
+ *                     memory transactions (e.g., READS_TO_LOCAL_MEM,
+ *                     READS_TO_REMOTE_MEM) being tracked by @evtid.
+ *                     Only valid if @evtid is an MBM event.
  * @configurable:      true if the event is configurable
  * @enabled:           true if the event is enabled
  */
@@ -63,6 +67,7 @@ struct mon_evt {
        enum resctrl_event_id   evtid;
        enum resctrl_res_level  rid;
        char                    *name;
+       u32                     evt_cfg;
        bool                    configurable;
        bool                    enabled;
 };
index 1fa82a62b2e570fbd7758089d74465ce5da75762..f714e7baaea65082cecc1f1dddbccb43ca12d581 100644 (file)
@@ -882,6 +882,11 @@ bool resctrl_is_mon_event_enabled(enum resctrl_event_id eventid)
               mon_event_all[eventid].enabled;
 }
 
+u32 resctrl_get_mon_evt_cfg(enum resctrl_event_id evtid)
+{
+       return mon_event_all[evtid].evt_cfg;
+}
+
 int resctrl_mbm_assign_mode_show(struct kernfs_open_file *of,
                                 struct seq_file *s, void *v)
 {
@@ -1023,6 +1028,11 @@ int resctrl_mon_resource_init(void)
                        resctrl_enable_mon_event(QOS_L3_MBM_TOTAL_EVENT_ID);
                if (!resctrl_is_mon_event_enabled(QOS_L3_MBM_LOCAL_EVENT_ID))
                        resctrl_enable_mon_event(QOS_L3_MBM_LOCAL_EVENT_ID);
+               mon_event_all[QOS_L3_MBM_TOTAL_EVENT_ID].evt_cfg = r->mon.mbm_cfg_mask;
+               mon_event_all[QOS_L3_MBM_LOCAL_EVENT_ID].evt_cfg = r->mon.mbm_cfg_mask &
+                                                                  (READS_TO_LOCAL_MEM |
+                                                                   READS_TO_LOCAL_S_MEM |
+                                                                   NON_TEMP_WRITE_TO_LOCAL_MEM);
                resctrl_file_fflags_init("num_mbm_cntrs",
                                         RFTYPE_MON_INFO | RFTYPE_RES_CACHE);
                resctrl_file_fflags_init("available_mbm_cntrs",
index e013caba664147b8feafb4defe9a4dc6323b326e..87daa4ca312ddf1728e8809fbac04769e4d094c1 100644 (file)
@@ -409,6 +409,8 @@ static inline bool resctrl_is_mbm_event(enum resctrl_event_id eventid)
                eventid <= QOS_L3_MBM_LOCAL_EVENT_ID);
 }
 
+u32 resctrl_get_mon_evt_cfg(enum resctrl_event_id eventid);
+
 /* Iterate over all memory bandwidth events */
 #define for_each_mbm_event_id(eventid)                         \
        for (eventid = QOS_L3_MBM_TOTAL_EVENT_ID;               \