Skip to content

Commit 556d289

Browse files
babumogerbp3tk0v
authored andcommitted
x86,fs/resctrl: Implement "io_alloc" enable/disable handlers
"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
1 parent 7923ae7 commit 556d289

3 files changed

Lines changed: 66 additions & 0 deletions

File tree

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,43 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
9191

9292
return hw_dom->ctrl_val[idx];
9393
}
94+
95+
bool resctrl_arch_get_io_alloc_enabled(struct rdt_resource *r)
96+
{
97+
return resctrl_to_arch_res(r)->sdciae_enabled;
98+
}
99+
100+
static void resctrl_sdciae_set_one_amd(void *arg)
101+
{
102+
bool *enable = arg;
103+
104+
if (*enable)
105+
msr_set_bit(MSR_IA32_L3_QOS_EXT_CFG, SDCIAE_ENABLE_BIT);
106+
else
107+
msr_clear_bit(MSR_IA32_L3_QOS_EXT_CFG, SDCIAE_ENABLE_BIT);
108+
}
109+
110+
static void _resctrl_sdciae_enable(struct rdt_resource *r, bool enable)
111+
{
112+
struct rdt_ctrl_domain *d;
113+
114+
/* Walking r->ctrl_domains, ensure it can't race with cpuhp */
115+
lockdep_assert_cpus_held();
116+
117+
/* Update MSR_IA32_L3_QOS_EXT_CFG MSR on all the CPUs in all domains */
118+
list_for_each_entry(d, &r->ctrl_domains, hdr.list)
119+
on_each_cpu_mask(&d->hdr.cpu_mask, resctrl_sdciae_set_one_amd, &enable, 1);
120+
}
121+
122+
int resctrl_arch_io_alloc_enable(struct rdt_resource *r, bool enable)
123+
{
124+
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
125+
126+
if (hw_res->r_resctrl.cache.io_alloc_capable &&
127+
hw_res->sdciae_enabled != enable) {
128+
_resctrl_sdciae_enable(r, enable);
129+
hw_res->sdciae_enabled = enable;
130+
}
131+
132+
return 0;
133+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ struct arch_mbm_state {
4646
#define ABMC_EXTENDED_EVT_ID BIT(31)
4747
#define ABMC_EVT_ID BIT(0)
4848

49+
/* Setting bit 1 in MSR_IA32_L3_QOS_EXT_CFG enables the SDCIAE feature. */
50+
#define SDCIAE_ENABLE_BIT 1
51+
4952
/**
5053
* struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs that share
5154
* a resource for a control function
@@ -112,6 +115,7 @@ struct msr_param {
112115
* @mbm_width: Monitor width, to detect and correct for overflow.
113116
* @cdp_enabled: CDP state of this resource
114117
* @mbm_cntr_assign_enabled: ABMC feature is enabled
118+
* @sdciae_enabled: SDCIAE feature (backing "io_alloc") is enabled.
115119
*
116120
* Members of this structure are either private to the architecture
117121
* e.g. mbm_width, or accessed via helpers that provide abstraction. e.g.
@@ -126,6 +130,7 @@ struct rdt_hw_resource {
126130
unsigned int mbm_width;
127131
bool cdp_enabled;
128132
bool mbm_cntr_assign_enabled;
133+
bool sdciae_enabled;
129134
};
130135

131136
static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resource *r)

include/linux/resctrl.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,27 @@ void resctrl_arch_reset_cntr(struct rdt_resource *r, struct rdt_mon_domain *d,
657657
u32 closid, u32 rmid, int cntr_id,
658658
enum resctrl_event_id eventid);
659659

660+
/**
661+
* resctrl_arch_io_alloc_enable() - Enable/disable io_alloc feature.
662+
* @r: The resctrl resource.
663+
* @enable: Enable (true) or disable (false) io_alloc on resource @r.
664+
*
665+
* This can be called from any CPU.
666+
*
667+
* Return:
668+
* 0 on success, <0 on error.
669+
*/
670+
int resctrl_arch_io_alloc_enable(struct rdt_resource *r, bool enable);
671+
672+
/**
673+
* resctrl_arch_get_io_alloc_enabled() - Get io_alloc feature state.
674+
* @r: The resctrl resource.
675+
*
676+
* Return:
677+
* true if io_alloc is enabled or false if disabled.
678+
*/
679+
bool resctrl_arch_get_io_alloc_enabled(struct rdt_resource *r);
680+
660681
extern unsigned int resctrl_rmid_realloc_threshold;
661682
extern unsigned int resctrl_rmid_realloc_limit;
662683

0 commit comments

Comments
 (0)