]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs/resctrl: Add monitor property 'mbm_cntr_assign_fixed'
authorBen Horgan <ben.horgan@arm.com>
Wed, 6 May 2026 08:28:52 +0000 (09:28 +0100)
committerBorislav Petkov (AMD) <bp@alien8.de>
Thu, 7 May 2026 14:29:14 +0000 (16:29 +0200)
Commit

  3b497c3f4f04 ("fs/resctrl: Introduce the interface to display monitoring modes")

introduced CONFIG_RESCTRL_ASSIGN_FIXED but left adding the Kconfig
entry until it was necessary. The counter assignment mode is fixed in
MPAM, even when there are assignable counters, and so addressing this
is needed to support MPAM.

To avoid the burden of another Kconfig entry, replace
CONFIG_RESCTRL_ASSIGN_FIXED with a new property in 'struct resctrl_mon',
'mbm_cntr_assign_fixed' to be set by the architecture.

Do not request the architecture to change the counter assignment mode if it
does not support doing so. Provide insight to user space about why such a
request fails.

Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Babu Moger <babu.moger@amd.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lore.kernel.org/20260506082855.3694761-1-ben.horgan@arm.com
fs/resctrl/monitor.c
include/linux/resctrl.h

index 916f7a9d56581ffbfef5431a159359d61870c6ab..5fbcc64e50ce71c5c969fb242d569eb8f6db22d6 100644 (file)
@@ -1456,7 +1456,7 @@ int resctrl_mbm_assign_mode_show(struct kernfs_open_file *of,
                else
                        seq_puts(s, "[default]\n");
 
-               if (!IS_ENABLED(CONFIG_RESCTRL_ASSIGN_FIXED)) {
+               if (!r->mon.mbm_cntr_assign_fixed) {
                        if (enabled)
                                seq_puts(s, "default\n");
                        else
@@ -1507,6 +1507,12 @@ ssize_t resctrl_mbm_assign_mode_write(struct kernfs_open_file *of, char *buf,
        }
 
        if (enable != resctrl_arch_mbm_cntr_assign_enabled(r)) {
+               if (r->mon.mbm_cntr_assign_fixed) {
+                       ret = -EINVAL;
+                       rdt_last_cmd_puts("Counter assignment mode is not configurable\n");
+                       goto out_unlock;
+               }
+
                ret = resctrl_arch_mbm_cntr_assign_set(r, enable);
                if (ret)
                        goto out_unlock;
index 06e8c72e8660f2aaef0d425b97edd1103d0b8216..73ff522448a02db196a374cf17e75d5e5b47a4f8 100644 (file)
@@ -294,6 +294,7 @@ enum resctrl_schema_fmt {
  * @mbm_assign_on_mkdir:       True if counters should automatically be assigned to MBM
  *                             events of monitor groups created via mkdir.
  * @mbm_cntr_configurable:     True if assignable counters are configurable.
+ * @mbm_cntr_assign_fixed:     True if the counter assignment mode is fixed.
  */
 struct resctrl_mon {
        u32                     num_rmid;
@@ -302,6 +303,7 @@ struct resctrl_mon {
        bool                    mbm_cntr_assignable;
        bool                    mbm_assign_on_mkdir;
        bool                    mbm_cntr_configurable;
+       bool                    mbm_cntr_assign_fixed;
 };
 
 /**