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

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Babu Moger and committed by
Borislav Petkov (AMD)
556d2892 7923ae76

+66
+40
arch/x86/kernel/cpu/resctrl/ctrlmondata.c
··· 91 91 92 92 return hw_dom->ctrl_val[idx]; 93 93 } 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 + }
+5
arch/x86/kernel/cpu/resctrl/internal.h
··· 46 46 #define ABMC_EXTENDED_EVT_ID BIT(31) 47 47 #define ABMC_EVT_ID BIT(0) 48 48 49 + /* Setting bit 1 in MSR_IA32_L3_QOS_EXT_CFG enables the SDCIAE feature. */ 50 + #define SDCIAE_ENABLE_BIT 1 51 + 49 52 /** 50 53 * struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs that share 51 54 * a resource for a control function ··· 115 112 * @mbm_width: Monitor width, to detect and correct for overflow. 116 113 * @cdp_enabled: CDP state of this resource 117 114 * @mbm_cntr_assign_enabled: ABMC feature is enabled 115 + * @sdciae_enabled: SDCIAE feature (backing "io_alloc") is enabled. 118 116 * 119 117 * Members of this structure are either private to the architecture 120 118 * e.g. mbm_width, or accessed via helpers that provide abstraction. e.g. ··· 130 126 unsigned int mbm_width; 131 127 bool cdp_enabled; 132 128 bool mbm_cntr_assign_enabled; 129 + bool sdciae_enabled; 133 130 }; 134 131 135 132 static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resource *r)
+21
include/linux/resctrl.h
··· 657 657 u32 closid, u32 rmid, int cntr_id, 658 658 enum resctrl_event_id eventid); 659 659 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 + 660 681 extern unsigned int resctrl_rmid_realloc_threshold; 661 682 extern unsigned int resctrl_rmid_realloc_limit; 662 683