x86/mwait-idle: (mainly) imports from Linux
cover x86/mwait-idle: (mainly) imports from Linux
... with the exception of patch 1, which first tidies a few places. (As it turns out, we've been lagging quite significantly.)
1: adjust section annotations 2: Add AlderLake-N support
3: add Emerald Rapids Xeon support 4: Add Meteorlake support
5: add Grand Ridge SoC support 6: add Sierra Forest SoC support 7: add Granite Rapids Xeon support 8: add Granite Rapids Xeon D support 9: add Clearwater Forest SoC support
Jan
PATCH 1/9 x86/mwait-idle: adjust section annotations
idle_cpu_spr was bogusly non-const. Several other objects can be changed from __read_mostly to __ro_after_init, for being altered from __init functions only.
xen/arch/x86/cpu/mwait-idle.c +11 -11
@@ -106,14 +106,14 @@ struct idle_cpu {enum c1e_promotion c1e_promotion; }; -static const struct idle_cpu *icpu; +static const struct idle_cpu *__ro_after_init icpu;static const struct cpuidle_state {char name[16 ];unsigned int flags;unsigned int exit_latency;/* in US */ unsigned int target_residency;/* in US */ -} *cpuidle_state_table; +} *__ro_after_init cpuidle_state_table;#define CPUIDLE_FLAG_DISABLED 0x1/*
@@ -504,7 +504,7 @@ static const struct cpuidle_state bdw_cs {} }; -static struct cpuidle_state __read_mostly skl_cstates[] = { +static struct cpuidle_state __ro_after_init skl_cstates[] = { { .name ="C1" , .flags =MWAIT2flg (0x00 ),
@@ -556,7 +556,7 @@ static struct cpuidle_state __read_mostl {} }; -static struct cpuidle_state __read_mostly skx_cstates[] = { +static struct cpuidle_state __ro_after_init skx_cstates[] = { { .name ="C1" , .flags =MWAIT2flg (0x00 ) |CPUIDLE_FLAG_IRQ_ENABLE ,
@@ -610,7 +610,7 @@ static const struct cpuidle_state icx_cs* By default we enable C1E and disable C1 by marking it with * 'CPUIDLE_FLAG_DISABLED'. */ -static struct cpuidle_state __read_mostly adl_cstates[] = { +static struct cpuidle_state __ro_after_init adl_cstates[] = { { .name ="C1" , .flags =MWAIT2flg (0x00 ) |CPUIDLE_FLAG_DISABLED ,
@@ -644,7 +644,7 @@ static struct cpuidle_state __read_mostl {} }; -static struct cpuidle_state __read_mostly adl_l_cstates[] = { +static struct cpuidle_state __ro_after_init adl_l_cstates[] = { { .name ="C1" , .flags =MWAIT2flg (0x00 ) |CPUIDLE_FLAG_DISABLED ,
@@ -678,7 +678,7 @@ static struct cpuidle_state __read_mostl {} }; -static struct cpuidle_state __read_mostly spr_cstates[] = { +static struct cpuidle_state __ro_after_init spr_cstates[] = { { .name ="C1" , .flags =MWAIT2flg (0x00 ),
@@ -778,7 +778,7 @@ static const struct cpuidle_state avn_cs {} }; -static struct cpuidle_state __read_mostly bxt_cstates[] = { +static struct cpuidle_state __ro_after_init bxt_cstates[] = { { .name ="C1" , .flags =MWAIT2flg (0x00 ),
@@ -1075,15 +1075,15 @@ static const struct idle_cpu idle_cpu_ic .c1e_promotion = C1E_PROMOTION_DISABLE, }; -static struct idle_cpu __read_mostly idle_cpu_adl = { +static struct idle_cpu __ro_after_init idle_cpu_adl = { .state_table = adl_cstates, }; -static struct idle_cpu __read_mostly idle_cpu_adl_l = { +static struct idle_cpu __ro_after_init idle_cpu_adl_l = { .state_table = adl_l_cstates, }; -static struct idle_cpu __read_mostly idle_cpu_spr = { +static const struct idle_cpu idle_cpu_spr = { .state_table = spr_cstates, .c1e_promotion =C1E_PROMOTION_DISABLE , };
PATCH 2/9 x86/mwait-idle: Add AlderLake-N support
In reply to Jan BeulichSimilar to the other other AlderLake platforms, the C1 and C1E states on ADL-N are mutually exclusive. Only one of them can be enabled at a time.
C1E is preferred on ADL-N for better energy efficiency.
C6S is also supported on this platform. Its latency is far bigger than C6, but really close to C8 (PC8), thus it is not exposed as a separate state.
Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 65c0c2367e9e
x86/cpu: Fix Gracemont uarch
Alderlake N is an E-core only product using Gracemont micro-architecture. It fits the pre-existing naming scheme perfectly fine, adhere to it.
Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 882cdb06b668
xen/arch/x86/cpu/mwait-idle.c +40 -0
@@ -678,6 +678,40 @@ static struct cpuidle_state __ro_after_i {} }; +static const struct cpuidle_state gmt_cstates[] = { + { + .name ="C1" , + .flags =MWAIT2flg (0x00 ) |CPUIDLE_FLAG_DISABLED , + .exit_latency =1 , + .target_residency =1 , + }, + { + .name ="C1E" , + .flags =MWAIT2flg (0x01 ), + .exit_latency =2 , + .target_residency =4 , + }, + { + .name ="C6" , + .flags =MWAIT2flg (0x20 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =195 , + .target_residency =585 , + }, + { + .name ="C8" , + .flags =MWAIT2flg (0x40 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =260 , + .target_residency =1040 , + }, + { + .name ="C10" , + .flags =MWAIT2flg (0x60 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =660 , + .target_residency =1980 , + }, + {} +}; +static struct cpuidle_state __ro_after_init spr_cstates[] = { { .name ="C1" ,
@@ -1083,6 +1117,10 @@ static struct idle_cpu __ro_after_init i .state_table = adl_l_cstates, }; +static const struct idle_cpu idle_cpu_gmt = { + .state_table = gmt_cstates, +}; +static const struct idle_cpu idle_cpu_spr = { .state_table = spr_cstates, .c1e_promotion =C1E_PROMOTION_DISABLE ,
@@ -1148,6 +1186,7 @@ static const struct x86_cpu_id intel_idlICPU (ICELAKE_D , icx),ICPU (ALDERLAKE , adl),ICPU (ALDERLAKE_L , adl_l), +ICPU (ATOM_GRACEMONT , gmt),ICPU (SAPPHIRERAPIDS_X , spr),ICPU (ATOM_GOLDMONT , bxt), ICPU(ATOM_GOLDMONT_PLUS, bxt),
@@ -1386,6 +1425,7 @@ static void __init mwait_idle_state_tablbreak ;case INTEL_FAM6_ALDERLAKE :case INTEL_FAM6_ALDERLAKE_L : +case INTEL_FAM6_ATOM_GRACEMONT :adl_idle_state_table_update ();break ; }
PATCH 3/9 x86/mwait-idle: add Emerald Rapids Xeon support
In reply to Jan BeulichEmerald Rapids (EMR) is the next Intel Xeon processor after Sapphire Rapids (SPR).
EMR C-states are the same as SPR C-states, and we expect that EMR C-state characteristics (latency and target residency) will be the same as in SPR. Therefore, add EMR support by using SPR C-states table.
Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 74528edfbc66
xen/arch/x86/cpu/mwait-idle.c +2 -0
@@ -1188,6 +1188,7 @@ static const struct x86_cpu_id intel_idlICPU (ALDERLAKE_L , adl_l),ICPU (ATOM_GRACEMONT , gmt),ICPU (SAPPHIRERAPIDS_X , spr), +ICPU (EMERALDRAPIDS_X , spr),ICPU (ATOM_GOLDMONT , bxt),ICPU (ATOM_GOLDMONT_PLUS , bxt), ICPU(ATOM_GOLDMONT_D, dnv),
@@ -1421,6 +1422,7 @@ static void __init mwait_idle_state_tablskx_idle_state_table_update ();break ;case INTEL_FAM6_SAPPHIRERAPIDS_X : +case INTEL_FAM6_EMERALDRAPIDS_X :spr_idle_state_table_update ();break ;case INTEL_FAM6_ALDERLAKE :
PATCH 4/9 x86/mwait-idle: Add Meteorlake support
In reply to Jan BeulichAdd intel_idle support for MeteorLake.
C1 and C1E states on Meteorlake are mutually exclusive, like Alderlake and Raptorlake, but they have little latency difference with measureable power difference, so always enable "C1E promotion" bit and expose C1E only.
Expose C6 because it has less power compared with C1E, and smaller latency compared with C8/C10.
Ignore C8 and expose C10, because C8 does not show latency advantage compared with C10.
Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git eeae55ed9c0a
xen/arch/x86/cpu/mwait-idle.c +27 -0
@@ -678,6 +678,28 @@ static struct cpuidle_state __ro_after_i {} }; +static const struct cpuidle_state mtl_l_cstates[] = { + { + .name ="C1E" , + .flags =MWAIT2flg (0x01 ), + .exit_latency =1 , + .target_residency =1 , + }, + { + .name ="C6" , + .flags =MWAIT2flg (0x20 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =140 , + .target_residency =420 , + }, + { + .name ="C10" , + .flags =MWAIT2flg (0x60 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =310 , + .target_residency =930 , + }, + {} +}; +static const struct cpuidle_state gmt_cstates[] = { { .name ="C1" ,
@@ -1117,6 +1139,10 @@ static struct idle_cpu __ro_after_init i .state_table = adl_l_cstates, }; +static const struct idle_cpu idle_cpu_mtl_l = { + .state_table = mtl_l_cstates, +}; +static const struct idle_cpu idle_cpu_gmt = { .state_table = gmt_cstates, };
@@ -1186,6 +1212,7 @@ static const struct x86_cpu_id intel_idlICPU (ICELAKE_D , icx),ICPU (ALDERLAKE , adl),ICPU (ALDERLAKE_L , adl_l), +ICPU (METEORLAKE_L , mtl_l),ICPU (ATOM_GRACEMONT , gmt),ICPU (SAPPHIRERAPIDS_X , spr), ICPU(EMERALDRAPIDS_X, spr),
Re: [PATCH 4/9] x86/mwait-idle: Add Meteorlake support
Quoted 69 lines
Add
intel_idlesupport for MeteorLake.C1 and C1E states on Meteorlake are mutually exclusive, like Alderlake and Raptorlake, but they have little latency difference with measureable power difference, so always enable "C1E promotion" bit and expose C1E only.
Expose C6 because it has less power compared with C1E, and smaller latency compared with C8/C10.
Ignore C8 and expose C10, because C8 does not show latency advantage compared with C10.
Signed-off-by Zhang Rui <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>Origin:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.giteeae55ed9c0aSigned-off-by Jan Beulich <[email protected]>xen/arch/x86/cpu/mwait-idle.c +27
-0@@ -678,6 +678,28 @@ static struct cpuidle_state __ro_after_i {} }; +static const struct cpuidle_state mtl_l_cstates[] = { + { + .name ="C1E" , + .flags =MWAIT2flg (0x01 ), + .exit_latency =1 , + .target_residency =1 , + }, + { + .name ="C6" , + .flags =MWAIT2flg (0x20 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =140 , + .target_residency =420 , + }, + { + .name ="C10" , + .flags =MWAIT2flg (0x60 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =310 , + .target_residency =930 , + }, + {} +}; +static const struct cpuidle_state gmt_cstates[] = { { .name ="C1" ,@@ -1117,6 +1139,10 @@ static struct idle_cpu __ro_after_init i .state_table = adl_l_cstates, }; +static const struct idle_cpu idle_cpu_mtl_l = { + .state_table = mtl_l_cstates, +}; +static const struct idle_cpu idle_cpu_gmt = { .state_table = gmt_cstates, };@@ -1186,6 +1212,7 @@ static const struct x86_cpu_id intel_idlICPU (ICELAKE_D , icx),ICPU (ALDERLAKE , adl),ICPU (ALDERLAKE_L , adl_l), +ICPU (METEORLAKE_L , mtl_l),ICPU (ATOM_GRACEMONT , gmt),ICPU (SAPPHIRERAPIDS_X , spr), ICPU(EMERALDRAPIDS_X, spr),
PATCH 5/9 x86/mwait-idle: add Grand Ridge SoC support
In reply to Jan BeulichAdd Intel Grand Ridge SoC C-states, which are C1, C1E, and C6S.
The Grand Ridge SoC is built with modules, each module includes 4 cores (Crestmont microarchitecture). There is one L2 cache per module, shared between the 4 cores.
There is no core C6 state, but there is C6S state, which has module
scope: when all 4 cores request C6S, the entire module (4 cores + L2 cache) enters the low power state.
Package C6 is not supported by Grand Ridge SoC.
Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git ac89d11b93cc
xen/arch/x86/cpu/mwait-idle.c +28 -0
@@ -928,6 +928,28 @@ static const struct cpuidle_state snr_cs {} }; +static const struct cpuidle_state grr_cstates[] = { + { + .name ="C1" , + .flags =MWAIT2flg (0x00 ), + .exit_latency =1 , + .target_residency =1 , + }, + { + .name ="C1E" , + .flags =MWAIT2flg (0x01 ), + .exit_latency =2 , + .target_residency =10 , + }, + { + .name ="C6S" , + .flags =MWAIT2flg (0x22 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =140 , + .target_residency =500 , + }, + {} +}; + static void cf_check mwait_idle(void) {unsigned int cpu =smp_processor_id ();
@@ -1172,6 +1194,11 @@ static const struct idle_cpu idle_cpu_sn .c1e_promotion = C1E_PROMOTION_DISABLE, }; +static const struct idle_cpu idle_cpu_grr = { + .state_table = grr_cstates, + .c1e_promotion =C1E_PROMOTION_DISABLE , +}; +#define ICPU (model, cpu) \ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ ## model, X86_FEATURE_ALWAYS, \ &idle_cpu_ ## cpu}
@@ -1220,6 +1247,7 @@ static const struct x86_cpu_id intel_idlICPU (ATOM_GOLDMONT_PLUS , bxt),ICPU (ATOM_GOLDMONT_D , dnv),ICPU (ATOM_TREMONT_D , snr), + ICPU(ATOM_CRESTMONT, grr), {} };
PATCH 6/9 x86/mwait-idle: add Sierra Forest SoC support
In reply to Jan BeulichAdd Sierra Forest SoC C-states, which are C1, C1E, C6S, and C6SP.
Sierra Forest SoC is built with modules, each module includes 4 cores (Crestmont microarchitecture). There is one L2 cache per module, shared between the 4 cores.
There is no core C6 state, but there is C6S state, which has module scope:
when all 4 cores request C6S, the entire module (4 cores + L2 cache) enters the low power state.
C6SP state has package scope - when all modules in the package enter C6S, the package enters the power state mode.
Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 92813fd5b156
xen/arch/x86/cpu/mwait-idle.c +34 -0
@@ -950,6 +950,34 @@ static const struct cpuidle_state grr_cs {} }; +static const struct cpuidle_state srf_cstates[] = { + { + .name ="C1" , + .flags =MWAIT2flg (0x00 ), + .exit_latency =1 , + .target_residency =1 , + }, + { + .name ="C1E" , + .flags =MWAIT2flg (0x01 ), + .exit_latency =2 , + .target_residency =10 , + }, + { + .name ="C6S" , + .flags =MWAIT2flg (0x22 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =270 , + .target_residency =700 , + }, + { + .name ="C6SP" , + .flags =MWAIT2flg (0x23 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =310 , + .target_residency =900 , + }, + {} +}; + static void cf_check mwait_idle(void) {unsigned int cpu =smp_processor_id ();
@@ -1199,6 +1227,11 @@ static const struct idle_cpu idle_cpu_gr .c1e_promotion = C1E_PROMOTION_DISABLE, }; +static const struct idle_cpu idle_cpu_srf = { + .state_table = srf_cstates, + .c1e_promotion =C1E_PROMOTION_DISABLE , +}; +#define ICPU (model, cpu) \ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ ## model, X86_FEATURE_ALWAYS, \ &idle_cpu_ ## cpu}
@@ -1248,6 +1281,7 @@ static const struct x86_cpu_id intel_idlICPU (ATOM_GOLDMONT_D , dnv),ICPU (ATOM_TREMONT_D , snr),ICPU (ATOM_CRESTMONT , grr), + ICPU(ATOM_CRESTMONT_X, srf), {} };
PATCH 7/9 x86/mwait-idle: add Granite Rapids Xeon support
In reply to Jan BeulichAdd Granite Rapids Xeon C-states, which are C1, C1E, C6, and C6P.
Comparing to previous Xeon Generations (e.g., Emerald Rapids), C6 requests end up only in core C6 state, and no package C-state promotion takes place even if all cores in the package are in core C6.
C6P requests also end up in core C6, but if all cores have requested C6P, the SoC will enter the package C6 state.
Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 370406bf5738
xen/arch/x86/cpu/mwait-idle.c +34 -0
@@ -756,6 +756,34 @@ static struct cpuidle_state __ro_after_i {} }; +static const struct cpuidle_state gnr_cstates[] = { + { + .name ="C1" , + .flags =MWAIT2flg (0x00 ), + .exit_latency =1 , + .target_residency =1 , + }, + { + .name ="C1E" , + .flags =MWAIT2flg (0x01 ), + .exit_latency =4 , + .target_residency =4 , + }, + { + .name ="C6" , + .flags =MWAIT2flg (0x20 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =170 , + .target_residency =650 , + }, + { + .name ="C6P" , + .flags =MWAIT2flg (0x21 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =210 , + .target_residency =1000 , + }, + {} +}; +static const struct cpuidle_state atom_cstates[] = { { .name ="C1E" ,
@@ -1202,6 +1230,11 @@ static const struct idle_cpu idle_cpu_sp .c1e_promotion = C1E_PROMOTION_DISABLE, }; +static const struct idle_cpu idle_cpu_gnr = { + .state_table = gnr_cstates, + .c1e_promotion =C1E_PROMOTION_DISABLE , +}; +static const struct idle_cpu idle_cpu_avn = { .state_table = avn_cstates, .c1e_promotion =C1E_PROMOTION_DISABLE ,
@@ -1276,6 +1309,7 @@ static const struct x86_cpu_id intel_idlICPU (ATOM_GRACEMONT , gmt),ICPU (SAPPHIRERAPIDS_X , spr),ICPU (EMERALDRAPIDS_X , spr), +ICPU (GRANITERAPIDS_X , gnr),ICPU (ATOM_GOLDMONT , bxt),ICPU (ATOM_GOLDMONT_PLUS , bxt), ICPU(ATOM_GOLDMONT_D, dnv),
PATCH 8/9 x86/mwait-idle: add Granite Rapids Xeon D support
In reply to Jan BeulichAdd Granite Rapids Xeon D C-states support: C1, C1E, C6, and C6P.
The C-states are basically the same as in Granite Rapids Xeon SP/AP, but characteristics (latency, target residency) are a bit different.
Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git f557e0d1c2e6
xen/arch/x86/cpu/mwait-idle.c +34 -0
@@ -784,6 +784,34 @@ static const struct cpuidle_state gnr_cs {} }; +static const struct cpuidle_state gnrd_cstates[] = { + { + .name ="C1" , + .flags =MWAIT2flg (0x00 ), + .exit_latency =1 , + .target_residency =1 , + }, + { + .name ="C1E" , + .flags =MWAIT2flg (0x01 ), + .exit_latency =4 , + .target_residency =4 , + }, + { + .name ="C6" , + .flags =MWAIT2flg (0x20 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =220 , + .target_residency =650 , + }, + { + .name ="C6P" , + .flags =MWAIT2flg (0x21 ) |CPUIDLE_FLAG_TLB_FLUSHED , + .exit_latency =240 , + .target_residency =750 , + }, + {} +}; +static const struct cpuidle_state atom_cstates[] = { { .name ="C1E" ,
@@ -1235,6 +1263,11 @@ static const struct idle_cpu idle_cpu_gn .c1e_promotion = C1E_PROMOTION_DISABLE, }; +static const struct idle_cpu idle_cpu_gnrd = { + .state_table = gnrd_cstates, + .c1e_promotion =C1E_PROMOTION_DISABLE , +}; +static const struct idle_cpu idle_cpu_avn = { .state_table = avn_cstates, .c1e_promotion =C1E_PROMOTION_DISABLE ,
@@ -1310,6 +1343,7 @@ static const struct x86_cpu_id intel_idlICPU (SAPPHIRERAPIDS_X , spr),ICPU (EMERALDRAPIDS_X , spr),ICPU (GRANITERAPIDS_X , gnr), +ICPU (GRANITERAPIDS_D , gnrd),ICPU (ATOM_GOLDMONT , bxt),ICPU (ATOM_GOLDMONT_PLUS , bxt), ICPU(ATOM_GOLDMONT_D, dnv),
PATCH 9/9 x86/mwait-idle: add Clearwater Forest SoC support
In reply to Jan BeulichClearwater Forest (CWF) SoC has the same C-states as Sierra Forest (SRF) SoC. Add CWF support by re-using the SRF C-states table.
Note: it is expected that CWF C-states will have same or very similar characteristics as SRF C-states (latency and target residency).
However, there is a possibility that the characteristics will end up being different enough when the CWF platform development is finished. In that case, a separate CWF C-states table will be created and populated with the CWF-specific characteristics (latency and target residency).
Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git eeed4bfbe9b9
xen/arch/x86/cpu/mwait-idle.c +1 -0
@@ -1350,6 +1350,7 @@ static const struct x86_cpu_id intel_idlICPU (ATOM_TREMONT_D , snr),ICPU (ATOM_CRESTMONT , grr),ICPU (ATOM_CRESTMONT_X , srf), + ICPU(ATOM_DARKMONT_X, srf), {} };
Quoted 12 lines · Jan Beulich
... with the exception of patch 1, which first tidies a few places. (As it turns out, we've been lagging quite significantly.)
1: adjust section annotations 2: Add AlderLake-N support
3: add Emerald Rapids Xeon support 4: Add Meteorlake support
5: add Grand Ridge SoC support 6: add Sierra Forest SoC support 7: add Granite Rapids Xeon support 8: add Granite Rapids Xeon D support 9: add Clearwater Forest SoC support