Skip to content

Commit fae3a13

Browse files
babumogersuryasaimadhu
authored andcommitted
x86/resctrl: Fix AMD L3 QOS CDP enable/disable
When the AMD QoS feature CDP (code and data prioritization) is enabled or disabled, the CDP bit in MSR 0000_0C81 is written on one of the CPUs in an L3 domain (core complex). That is not correct - the CDP bit needs to be updated on all the logical CPUs in the domain. This was not spelled out clearly in the spec earlier. The specification has been updated and the updated document, "AMD64 Technology Platform Quality of Service Extensions Publication # 56375 Revision: 1.02 Issue Date: October 2020" is available now. Refer the section: Code and Data Prioritization. Fix the issue by adding a new flag arch_has_per_cpu_cfg in rdt_cache data structure. The documentation can be obtained at: https://developer.amd.com/wp-content/resources/56375.pdf Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537 [ bp: Massage commit message. ] Fixes: 4d05bf7 ("x86/resctrl: Introduce AMD QOS feature") Signed-off-by: Babu Moger <babu.moger@amd.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Link: https://lkml.kernel.org/r/160675180380.15628.3309402017215002347.stgit@bmoger-ubuntu
1 parent 25bc65d commit fae3a13

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r)
570570

571571
if (d) {
572572
cpumask_set_cpu(cpu, &d->cpu_mask);
573+
if (r->cache.arch_has_per_cpu_cfg)
574+
rdt_domain_reconfigure_cdp(r);
573575
return;
574576
}
575577

@@ -923,6 +925,7 @@ static __init void rdt_init_res_defs_intel(void)
923925
r->rid == RDT_RESOURCE_L2CODE) {
924926
r->cache.arch_has_sparse_bitmaps = false;
925927
r->cache.arch_has_empty_bitmaps = false;
928+
r->cache.arch_has_per_cpu_cfg = false;
926929
} else if (r->rid == RDT_RESOURCE_MBA) {
927930
r->msr_base = MSR_IA32_MBA_THRTL_BASE;
928931
r->msr_update = mba_wrmsr_intel;
@@ -943,6 +946,7 @@ static __init void rdt_init_res_defs_amd(void)
943946
r->rid == RDT_RESOURCE_L2CODE) {
944947
r->cache.arch_has_sparse_bitmaps = true;
945948
r->cache.arch_has_empty_bitmaps = true;
949+
r->cache.arch_has_per_cpu_cfg = true;
946950
} else if (r->rid == RDT_RESOURCE_MBA) {
947951
r->msr_base = MSR_IA32_MBA_BW_BASE;
948952
r->msr_update = mba_wrmsr_amd;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ struct msr_param {
360360
* executing entities
361361
* @arch_has_sparse_bitmaps: True if a bitmap like f00f is valid.
362362
* @arch_has_empty_bitmaps: True if the '0' bitmap is valid.
363+
* @arch_has_per_cpu_cfg: True if QOS_CFG register for this cache
364+
* level has CPU scope.
363365
*/
364366
struct rdt_cache {
365367
unsigned int cbm_len;
@@ -369,6 +371,7 @@ struct rdt_cache {
369371
unsigned int shareable_bits;
370372
bool arch_has_sparse_bitmaps;
371373
bool arch_has_empty_bitmaps;
374+
bool arch_has_per_cpu_cfg;
372375
};
373376

374377
/**

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,8 +1909,13 @@ static int set_cache_qos_cfg(int level, bool enable)
19091909

19101910
r_l = &rdt_resources_all[level];
19111911
list_for_each_entry(d, &r_l->domains, list) {
1912-
/* Pick one CPU from each domain instance to update MSR */
1913-
cpumask_set_cpu(cpumask_any(&d->cpu_mask), cpu_mask);
1912+
if (r_l->cache.arch_has_per_cpu_cfg)
1913+
/* Pick all the CPUs in the domain instance */
1914+
for_each_cpu(cpu, &d->cpu_mask)
1915+
cpumask_set_cpu(cpu, cpu_mask);
1916+
else
1917+
/* Pick one CPU from each domain instance to update MSR */
1918+
cpumask_set_cpu(cpumask_any(&d->cpu_mask), cpu_mask);
19141919
}
19151920
cpu = get_cpu();
19161921
/* Update QOS_CFG MSR on this cpu if it's in cpu_mask. */

0 commit comments

Comments
 (0)