]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86,fs/resctrl: Implement "io_alloc" enable/disable handlers
authorBabu Moger <babu.moger@amd.com>
Thu, 13 Nov 2025 00:57:30 +0000 (18:57 -0600)
committerBorislav Petkov (AMD) <bp@alien8.de>
Fri, 21 Nov 2025 21:35:22 +0000 (22:35 +0100)
"io_alloc" is the generic name of the new resctrl feature that enables system
software to configure the portion of cache allocated for I/O traffic. On AMD
systems, "io_alloc" resctrl feature is backed by AMD's L3 Smart Data Cache
Injection Allocation Enforcement (SDCIAE).

Introduce the architecture-specific functions that resctrl fs should call to
enable, disable, or check status of the "io_alloc" feature. Change SDCIAE state
by setting (to enable) or clearing (to disable) bit 1 of
MSR_IA32_L3_QOS_EXT_CFG on all logical processors within the cache domain.

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://patch.msgid.link/9e9070100c320eab5368e088a3642443dee95ed7.1762995456.git.babu.moger@amd.com
arch/x86/kernel/cpu/resctrl/ctrlmondata.c
arch/x86/kernel/cpu/resctrl/internal.h
include/linux/resctrl.h

index 1189c0df4ad763c176d61b1de7b223f1cea3ac91..b20e705606b8fbf10f99de11c1a993516442d07a 100644 (file)
@@ -91,3 +91,43 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
 
        return hw_dom->ctrl_val[idx];
 }
+
+bool resctrl_arch_get_io_alloc_enabled(struct rdt_resource *r)
+{
+       return resctrl_to_arch_res(r)->sdciae_enabled;
+}
+
+static void resctrl_sdciae_set_one_amd(void *arg)
+{
+       bool *enable = arg;
+
+       if (*enable)
+               msr_set_bit(MSR_IA32_L3_QOS_EXT_CFG, SDCIAE_ENABLE_BIT);
+       else
+               msr_clear_bit(MSR_IA32_L3_QOS_EXT_CFG, SDCIAE_ENABLE_BIT);
+}
+
+static void _resctrl_sdciae_enable(struct rdt_resource *r, bool enable)
+{
+       struct rdt_ctrl_domain *d;
+
+       /* Walking r->ctrl_domains, ensure it can't race with cpuhp */
+       lockdep_assert_cpus_held();
+
+       /* Update MSR_IA32_L3_QOS_EXT_CFG MSR on all the CPUs in all domains */
+       list_for_each_entry(d, &r->ctrl_domains, hdr.list)
+               on_each_cpu_mask(&d->hdr.cpu_mask, resctrl_sdciae_set_one_amd, &enable, 1);
+}
+
+int resctrl_arch_io_alloc_enable(struct rdt_resource *r, bool enable)
+{
+       struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
+
+       if (hw_res->r_resctrl.cache.io_alloc_capable &&
+           hw_res->sdciae_enabled != enable) {
+               _resctrl_sdciae_enable(r, enable);
+               hw_res->sdciae_enabled = enable;
+       }
+
+       return 0;
+}
index 9f4c2f0aaf5c805bfa37e1eb6449925d49925292..4a916c84a322068906e66a953f7444b5f6ed7aa5 100644 (file)
@@ -46,6 +46,9 @@ struct arch_mbm_state {
 #define ABMC_EXTENDED_EVT_ID           BIT(31)
 #define ABMC_EVT_ID                    BIT(0)
 
+/* Setting bit 1 in MSR_IA32_L3_QOS_EXT_CFG enables the SDCIAE feature. */
+#define SDCIAE_ENABLE_BIT              1
+
 /**
  * struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs that share
  *                            a resource for a control function
@@ -112,6 +115,7 @@ struct msr_param {
  * @mbm_width:         Monitor width, to detect and correct for overflow.
  * @cdp_enabled:       CDP state of this resource
  * @mbm_cntr_assign_enabled:   ABMC feature is enabled
+ * @sdciae_enabled:    SDCIAE feature (backing "io_alloc") is enabled.
  *
  * Members of this structure are either private to the architecture
  * e.g. mbm_width, or accessed via helpers that provide abstraction. e.g.
@@ -126,6 +130,7 @@ struct rdt_hw_resource {
        unsigned int            mbm_width;
        bool                    cdp_enabled;
        bool                    mbm_cntr_assign_enabled;
+       bool                    sdciae_enabled;
 };
 
 static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resource *r)
index 533f240dbe21eb9fcb7c5be3520bd222501b712b..54701668b3dfc0363811bd8174908e1e7af76c6f 100644 (file)
@@ -657,6 +657,27 @@ void resctrl_arch_reset_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,
                             u32 closid, u32 rmid, int cntr_id,
                             enum resctrl_event_id eventid);
 
+/**
+ * resctrl_arch_io_alloc_enable() - Enable/disable io_alloc feature.
+ * @r:         The resctrl resource.
+ * @enable:    Enable (true) or disable (false) io_alloc on resource @r.
+ *
+ * This can be called from any CPU.
+ *
+ * Return:
+ * 0 on success, <0 on error.
+ */
+int resctrl_arch_io_alloc_enable(struct rdt_resource *r, bool enable);
+
+/**
+ * resctrl_arch_get_io_alloc_enabled() - Get io_alloc feature state.
+ * @r:         The resctrl resource.
+ *
+ * Return:
+ * true if io_alloc is enabled or false if disabled.
+ */
+bool resctrl_arch_get_io_alloc_enabled(struct rdt_resource *r);
+
 extern unsigned int resctrl_rmid_realloc_threshold;
 extern unsigned int resctrl_rmid_realloc_limit;