Skip to content

Commit 0118ad8

Browse files
rchatresuryasaimadhu
authored andcommitted
x86/cpu: Move resctrl CPUID code to resctrl/
The function determining a platform's support and properties of cache occupancy and memory bandwidth monitoring (properties of X86_FEATURE_CQM_LLC) can be found among the common CPU code. After the feature's properties is populated in the per-CPU data the resctrl subsystem is the only consumer (via boot_cpu_data). Move the function that obtains the CPU information used by resctrl to the resctrl subsystem and rename it from init_cqm() to resctrl_cpu_detect(). The function continues to be called from the common CPU code. This move is done in preparation of the addition of some vendor specific code. No functional change. Suggested-by: Borislav Petkov <[email protected]> Signed-off-by: Reinette Chatre <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/38433b99f9d16c8f4ee796f8cc42b871531fa203.1588715690.git.reinette.chatre@intel.com
1 parent 8dd97c6 commit 0118ad8

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

arch/x86/include/asm/resctrl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ static inline void resctrl_sched_in(void)
8484
__resctrl_sched_in();
8585
}
8686

87+
void resctrl_cpu_detect(struct cpuinfo_x86 *c);
88+
8789
#else
8890

8991
static inline void resctrl_sched_in(void) {}
92+
static inline void resctrl_cpu_detect(struct cpuinfo_x86 *c) {}
9093

9194
#endif /* CONFIG_X86_CPU_RESCTRL */
9295

arch/x86/kernel/cpu/common.c

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include <asm/intel-family.h>
5757
#include <asm/cpu_device_id.h>
5858
#include <asm/uv/uv.h>
59+
#include <asm/resctrl.h>
5960

6061
#include "cpu.h"
6162

@@ -854,30 +855,6 @@ static void init_speculation_control(struct cpuinfo_x86 *c)
854855
}
855856
}
856857

857-
static void init_cqm(struct cpuinfo_x86 *c)
858-
{
859-
if (!cpu_has(c, X86_FEATURE_CQM_LLC)) {
860-
c->x86_cache_max_rmid = -1;
861-
c->x86_cache_occ_scale = -1;
862-
return;
863-
}
864-
865-
/* will be overridden if occupancy monitoring exists */
866-
c->x86_cache_max_rmid = cpuid_ebx(0xf);
867-
868-
if (cpu_has(c, X86_FEATURE_CQM_OCCUP_LLC) ||
869-
cpu_has(c, X86_FEATURE_CQM_MBM_TOTAL) ||
870-
cpu_has(c, X86_FEATURE_CQM_MBM_LOCAL)) {
871-
u32 eax, ebx, ecx, edx;
872-
873-
/* QoS sub-leaf, EAX=0Fh, ECX=1 */
874-
cpuid_count(0xf, 1, &eax, &ebx, &ecx, &edx);
875-
876-
c->x86_cache_max_rmid = ecx;
877-
c->x86_cache_occ_scale = ebx;
878-
}
879-
}
880-
881858
void get_cpu_cap(struct cpuinfo_x86 *c)
882859
{
883860
u32 eax, ebx, ecx, edx;
@@ -945,7 +922,7 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
945922

946923
init_scattered_cpuid_features(c);
947924
init_speculation_control(c);
948-
init_cqm(c);
925+
resctrl_cpu_detect(c);
949926

950927
/*
951928
* Clear/Set all flags overridden by options, after probe.

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,30 @@ static __init void rdt_init_res_defs(void)
958958

959959
static enum cpuhp_state rdt_online;
960960

961+
void resctrl_cpu_detect(struct cpuinfo_x86 *c)
962+
{
963+
if (!cpu_has(c, X86_FEATURE_CQM_LLC)) {
964+
c->x86_cache_max_rmid = -1;
965+
c->x86_cache_occ_scale = -1;
966+
return;
967+
}
968+
969+
/* will be overridden if occupancy monitoring exists */
970+
c->x86_cache_max_rmid = cpuid_ebx(0xf);
971+
972+
if (cpu_has(c, X86_FEATURE_CQM_OCCUP_LLC) ||
973+
cpu_has(c, X86_FEATURE_CQM_MBM_TOTAL) ||
974+
cpu_has(c, X86_FEATURE_CQM_MBM_LOCAL)) {
975+
u32 eax, ebx, ecx, edx;
976+
977+
/* QoS sub-leaf, EAX=0Fh, ECX=1 */
978+
cpuid_count(0xf, 1, &eax, &ebx, &ecx, &edx);
979+
980+
c->x86_cache_max_rmid = ecx;
981+
c->x86_cache_occ_scale = ebx;
982+
}
983+
}
984+
961985
static int __init resctrl_late_init(void)
962986
{
963987
struct rdt_resource *r;

0 commit comments

Comments
 (0)