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

[PATCH 2/4] mwait-idle: add SPR support


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 26 Apr 2022 12:05:07 +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=hsBeSiMQBYJ8DaiSl7aINKcWykVorNvddkc7DYO2PHw=; b=aP9miXisitKiumBjpUBYEuwJg6BtO/wyqbtZhQJ/OLKNluavjv9cgYux5N1asaWCNWHZXIYYVA9JCBYNgrE+db6OEHthlEL7v8kI8yZWoO3aBVeY5iAAWby/LvYE0AdKDRWMdTCj6XUFDeHfXBC67+bZJlWtV65LBk7C8uiivtjvuKNcXo6Vv95Qyphbpm/FGU1m2lAufhr8s4A3OI71H0XkYpg6zQc3EWQOSnpeuVW+Q7L2EUkKST1oFVKPM/fnn/k4XT31wEPODmmM/zUa9yey3ZagfmWki+0qC656Yb1CsknxGS/PGk6+T+GFheZtsTw22Sb14PHxTjizkjzrVA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XghLsbtarZ+nw6G3zHhyO98g6+2iz88I3rGIIqj28nwMXqiQCuXHKEImXDIKyZ3r/aTH80FnK0l3MfAyG9ebhZWB9xDqHbq8XoUorZZSBsxzWSYVhSs2J35A8drSwtR07krSdJHlJp50DCgElsu2NfkaIPW87WMl6UPmNfrTLvw5J2VZRteROKk5pwYS973vBKiGnqEmDrRJmaIOW6DYXRoXHl8ipLBKHT+b3GOeG9luQGrgRznF+oDP4WbcFXoD5egTMCxvkJgfdurU1XqKnKss9wyF+LI0MYig/AiEoGbS76X4KR+OR+qtc9yYzERJlMk9HEo+zPgacr7cnLnXxQ==
  • 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: Tue, 26 Apr 2022 10:05:15 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Artem Bityutskiy <artem.bityutskiy@xxxxxxxxxxxxxxx>

Add Sapphire Rapids Xeon support.

Up until very recently, the C1 and C1E C-states were independent, but this
has changed in some new chips, including Sapphire Rapids Xeon (SPR). In these
chips the C1 and C1E states cannot be enabled at the same time. The "C1E
promotion" bit in 'MSR_IA32_POWER_CTL' also has its semantics changed a bit.

Here are the C1, C1E, and "C1E promotion" bit rules on Xeons before SPR.

1. If C1E promotion bit is disabled.
   a. C1  requests end up with C1  C-state.
   b. C1E requests end up with C1E C-state.
2. If C1E promotion bit is enabled.
   a. C1  requests end up with C1E C-state.
   b. C1E requests end up with C1E C-state.

Here are the C1, C1E, and "C1E promotion" bit rules on Sapphire Rapids Xeon.
1. If C1E promotion bit is disabled.
   a. C1  requests end up with C1 C-state.
   b. C1E requests end up with C1 C-state.
2. If C1E promotion bit is enabled.
   a. C1  requests end up with C1E C-state.
   b. C1E requests end up with C1E C-state.

Before SPR Xeon, the 'intel_idle' driver was disabling C1E promotion and was
exposing C1 and C1E as independent C-states. But on SPR, C1 and C1E cannot be
enabled at the same time.

This patch adds both C1 and C1E states. However, C1E is marked as with the
"CPUIDLE_FLAG_UNUSABLE" flag, which means that in won't be registered by
default. The C1E promotion bit will be cleared, which means that by default
only C1 and C6 will be registered on SPR.

The next patch will add an option for enabling C1E and disabling C1 on SPR.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@xxxxxxxxxxxxxxx>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
9edf3c0ffef0
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- unstable.orig/xen/arch/x86/cpu/mwait-idle.c 2022-04-25 16:48:58.000000000 
+0200
+++ unstable/xen/arch/x86/cpu/mwait-idle.c      2022-04-25 17:17:05.000000000 
+0200
@@ -586,6 +586,38 @@ static const struct cpuidle_state icx_cs
        {}
 };
 
+/*
+ * 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
+ * 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 C1 and disable C1E by marking it with
+ * 'CPUIDLE_FLAG_DISABLED'.
+ */
+static struct cpuidle_state __read_mostly spr_cstates[] = {
+       {
+               .name = "C1",
+               .flags = MWAIT2flg(0x00),
+               .exit_latency = 1,
+               .target_residency = 1,
+       },
+       {
+               .name = "C1E",
+               .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_DISABLED,
+               .exit_latency = 2,
+               .target_residency = 4,
+       },
+       {
+               .name = "C6",
+               .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
+               .exit_latency = 290,
+               .target_residency = 800,
+       },
+       {}
+};
+
 static const struct cpuidle_state atom_cstates[] = {
        {
                .name = "C1E",
@@ -972,6 +1004,11 @@ static const struct idle_cpu idle_cpu_ic
        .disable_promotion_to_c1e = true,
 };
 
+static struct idle_cpu __read_mostly idle_cpu_spr = {
+       .state_table = spr_cstates,
+       .disable_promotion_to_c1e = true,
+};
+
 static const struct idle_cpu idle_cpu_avn = {
        .state_table = avn_cstates,
        .disable_promotion_to_c1e = true,
@@ -1034,6 +1071,7 @@ static const struct x86_cpu_id intel_idl
        ICPU(SKYLAKE_X,                 skx),
        ICPU(ICELAKE_X,                 icx),
        ICPU(ICELAKE_D,                 icx),
+       ICPU(SAPPHIRERAPIDS_X,          spr),
        ICPU(XEON_PHI_KNL,              knl),
        ICPU(XEON_PHI_KNM,              knl),
        ICPU(ATOM_GOLDMONT,             bxt),




 


Rackspace

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