[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 3/5] x86/mwait-idle: add AlderLake support


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 18 Aug 2022 15:04:28 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h9X+XMAiX9Z2/4F6tWFKbA2kUecCTVCdhQW9aZDeJlQ=; b=X53v8JUgmQ8B2HSt3c5z+q7fcxj3P7L65ub9zhRgof7FqSPYJt/LAFf5AN6zlWrA6hGdhbFPaq/FkO70ZE7fImYdTWWw6hKYy9WS8ieiAOfQGoh4Ah4PtUhvVFEhEU7BPOGwD3/fkCugo+GA7LYRaS+Bipu1DrLhpK/4MI4vfBus4euv5UAEiM9B4r09L31tmw1hpQ2yxVMJDOXn5EvduAFnnAQQL/i/2lz1dRcUx/n8eVutJzhfAzeiQRd/fevikTl+U4GPq5Tuw5n5cRQLo4HGqzBXLfBDrvB2JDqr4wjfBbnky1hQas/jBa/rQUg6U/2s7rEI2Y6CBu7pYhOywQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d+jvnZ8muiIRzUeYLyORqxCzoLjA4q7DZPqaVESFX8WSJ1KNasXJOeZeTRDop4wwibtA5PsyByOYbCiZq3iaOH+mrJ77mDHkYb1R/2/IWVqALM/rNJpTDzun7rcIQWlVUFsXZ0dPsekG0nmYAgwE6yfF5uYfkI6tBVuK3UB6/hHHwNfOq6vW+vcJVixYf5S215PfampiKih5oXH81O71d1mRUY4qDcyppH7/tkFI+BKNxKyXiuyTKJlfI+k9KGohnkMx3rM2UVxGLzlYXNk3IowqJDHlkqEx8JfZrhCjhOoLPZ/WBzY0wKHaviBsxfPmbS0JCtbDgB5c2RuMytzGPw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Thu, 18 Aug 2022 13:04:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Zhang Rui <rui.zhang@xxxxxxxxx>

Similar to SPR, the C1 and C1E states on ADL are mutually exclusive.
Only one of them can be enabled at a time.

But contrast to SPR, which usually has a strong latency requirement
as a Xeon processor, C1E is preferred on ADL for better energy
efficiency.

Add custom C-state tables for ADL with both C1 and C1E, and

 1. Enable the "C1E promotion" bit in MSR_IA32_POWER_CTL and mark C1
    with the CPUIDLE_FLAG_UNUSABLE flag, so C1 is not available by
    default.

 2. Add support for the "preferred_cstates" module parameter, so that
    users can choose to use C1 instead of C1E by booting with
    "intel_idle.preferred_cstates=2".

Separate custom C-state tables are introduced for the ADL mobile and
desktop processors, because of the exit latency differences between
these two variants, especially with respect to PC10.

Signed-off-by: Zhang Rui <rui.zhang@xxxxxxxxx>
[ rjw: Changelog edits, code rearrangement ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
d1cf8bbfed1e
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v3: New.

--- a/xen/arch/x86/cpu/mwait-idle.c
+++ b/xen/arch/x86/cpu/mwait-idle.c
@@ -606,6 +606,84 @@ static const struct cpuidle_state icx_cs
 };
 
 /*
+ * On AlderLake C1 has to be disabled if C1E is enabled, and vice versa.
+ * C1E is enabled only if "C1E promotion" bit is set in MSR_IA32_POWER_CTL.
+ * But in this case there is effectively no C1, because C1 requests are
+ * promoted to C1E. If the "C1E promotion" bit is cleared, then both C1
+ * and C1E requests end up with C1, so there is effectively no C1E.
+ *
+ * By default we enable C1E and disable C1 by marking it with
+ * 'CPUIDLE_FLAG_DISABLED'.
+ */
+static struct cpuidle_state __read_mostly adl_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 = 220,
+               .target_residency = 600,
+       },
+       {
+               .name = "C8",
+               .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
+               .exit_latency = 280,
+               .target_residency = 800,
+       },
+       {
+               .name = "C10",
+               .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
+               .exit_latency = 680,
+               .target_residency = 2000,
+       },
+       {}
+};
+
+static struct cpuidle_state __read_mostly adl_l_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 = 170,
+               .target_residency = 500,
+       },
+       {
+               .name = "C8",
+               .flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
+               .exit_latency = 200,
+               .target_residency = 600,
+       },
+       {
+               .name = "C10",
+               .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
+               .exit_latency = 230,
+               .target_residency = 700,
+       },
+       {}
+};
+
+/*
  * On Sapphire Rapids Xeon C1 has to be disabled if C1E is enabled, and vice
  * versa. On SPR C1E is enabled only if "C1E promotion" bit is set in
  * MSR_IA32_POWER_CTL. But in this case there effectively no C1, because C1
@@ -1032,6 +1110,14 @@ static const struct idle_cpu idle_cpu_ic
        .c1e_promotion = C1E_PROMOTION_DISABLE,
 };
 
+static struct idle_cpu __read_mostly idle_cpu_adl = {
+       .state_table = adl_cstates,
+};
+
+static struct idle_cpu __read_mostly idle_cpu_adl_l = {
+       .state_table = adl_l_cstates,
+};
+
 static struct idle_cpu __read_mostly idle_cpu_spr = {
        .state_table = spr_cstates,
        .c1e_promotion = C1E_PROMOTION_DISABLE,
@@ -1099,6 +1185,8 @@ static const struct x86_cpu_id intel_idl
        ICPU(SKYLAKE_X,                 skx),
        ICPU(ICELAKE_X,                 icx),
        ICPU(ICELAKE_D,                 icx),
+       ICPU(ALDERLAKE,                 adl),
+       ICPU(ALDERLAKE_L,               adl_l),
        ICPU(SAPPHIRERAPIDS_X,          spr),
        ICPU(XEON_PHI_KNL,              knl),
        ICPU(XEON_PHI_KNM,              knl),
@@ -1269,6 +1357,30 @@ static void __init skx_idle_state_table_
 }
 
 /*
+ * adl_idle_state_table_update - Adjust AlderLake idle states table.
+ */
+static void __init adl_idle_state_table_update(void)
+{
+       /* Check if user prefers C1 over C1E. */
+       if ((preferred_states_mask & BIT(1, U)) &&
+           !(preferred_states_mask & BIT(2, U))) {
+               adl_cstates[0].flags &= ~CPUIDLE_FLAG_DISABLED;
+               adl_cstates[1].flags |= CPUIDLE_FLAG_DISABLED;
+               adl_l_cstates[0].flags &= ~CPUIDLE_FLAG_DISABLED;
+               adl_l_cstates[1].flags |= CPUIDLE_FLAG_DISABLED;
+
+               /* Disable C1E by clearing the "C1E promotion" bit. */
+               idle_cpu_adl.c1e_promotion = C1E_PROMOTION_DISABLE;
+               idle_cpu_adl_l.c1e_promotion = C1E_PROMOTION_DISABLE;
+               return;
+       }
+
+       /* Make sure C1E is enabled by default */
+       idle_cpu_adl.c1e_promotion = C1E_PROMOTION_ENABLE;
+       idle_cpu_adl_l.c1e_promotion = C1E_PROMOTION_ENABLE;
+}
+
+/*
  * spr_idle_state_table_update - Adjust Sapphire Rapids idle states table.
  */
 static void __init spr_idle_state_table_update(void)
@@ -1324,6 +1436,10 @@ static void __init mwait_idle_state_tabl
        case INTEL_FAM6_SAPPHIRERAPIDS_X:
                spr_idle_state_table_update();
                break;
+       case INTEL_FAM6_ALDERLAKE:
+       case INTEL_FAM6_ALDERLAKE_L:
+               adl_idle_state_table_update();
+               break;
        }
 }
 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.