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

[PATCH v3 2/5] x86/mwait-idle: add core C6 optimization for SPR


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 18 Aug 2022 15:03:57 +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=Q1xcR1YrekDly/6j+fddD6c7EDtW054iEZ9k6oP7154=; b=XakYcV6iB4EwG13VDy9k8lnm07z+A+jXZBuQQQr5FX5KmDZhLfCZGjsmZJBNWCJh5/t7Hwi1LkC0NrpGTAF1/F+Mi9l/HlhpxlIo1zEBBihCGYUIox7/Zv+ADoa3wLpI6pPrk7HXG/ulI1aet0zs0iclhM8rF8fN8wbLxHZOhVdN6ynJMwRJyL4aAiNdCGjVBhDFFgF0sEhx6q73RoLnEE5ixGWKZ3x+NN1VDlJRbaT+ZPiPF0tr3+qoduubjyy7muHR3R6KEsfW5BA271PBvogclpuLE6G3VqpUgH7ei4PurHsSW6ZsFUTIP5VaStp9CLqo05PNLCQy64Z6rD3Icw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VycxG/A6hA+c7n0s7H7T28xfAxqTr3006kdDywr+qsjCzYWdKb50gcZANSC/08BlSrnjXzVLNd4yV2RmxiQSNRs3GTprHLsO62Y7oXTrbT3ub+0/4UlUyYTOpnYEi0po7DEa/PeMoVJzEHnIux5kptEZeVhE6BXrmn71skXMUp1uHyMK6l2/z55Xz6Iv0yK5Vgi212Q9SKWSFCahlIu285gi4kW23W4kAtX0RnACYqzYOXuSSYWDOGSo4aVLaoFObJzd/fmyDGkuDEwkS85tQQwwptjCRws+yU+BwiNYUXClozvfrxsLCpKqOGu11NRWgBt0HVGLRETLT1mvrd7Rkw==
  • 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:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Artem Bityutskiy <artem.bityutskiy@xxxxxxxxxxxxxxx>

Add a Sapphire Rapids Xeon C6 optimization, similar to what we have for Sky Lake
Xeon: if package C6 is disabled, adjust C6 exit latency and target residency to
match core C6 values, instead of using the default package C6 values.

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 
3a9cf77b60dc

Make sure a contradictory "preferred-cstates" wouldn't cause bypassing
of the added logic.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
v3: Add parentheses.
v2: Sync with the Linux side fix to the noticed issue. Re-base over
    change to earlier patch.

--- a/xen/arch/x86/cpu/mwait-idle.c
+++ b/xen/arch/x86/cpu/mwait-idle.c
@@ -1273,18 +1273,31 @@ static void __init skx_idle_state_table_
  */
 static void __init spr_idle_state_table_update(void)
 {
-       /* Check if user prefers C1E over C1. */
-       if (preferred_states_mask & BIT(2, U)) {
-               if (preferred_states_mask & BIT(1, U))
-                       /* Both can't be enabled, stick to the defaults. */
-                       return;
+       uint64_t msr;
 
+       /* Check if user prefers C1E over C1. */
+       if ((preferred_states_mask & BIT(2, U)) &&
+           !(preferred_states_mask & BIT(1, U))) {
+               /* Disable C1 and enable C1E. */
                spr_cstates[0].flags |= CPUIDLE_FLAG_DISABLED;
                spr_cstates[1].flags &= ~CPUIDLE_FLAG_DISABLED;
 
                /* Request enabling C1E using the "C1E promotion" bit. */
                idle_cpu_spr.c1e_promotion = C1E_PROMOTION_ENABLE;
        }
+
+       /*
+        * By default, the C6 state assumes the worst-case scenario of package
+        * C6. However, if PC6 is disabled, we update the numbers to match
+        * core C6.
+        */
+       rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr);
+
+       /* Limit value 2 and above allow for PC6. */
+       if ((msr & 0x7) < 2) {
+               spr_cstates[2].exit_latency = 190;
+               spr_cstates[2].target_residency = 600;
+       }
 }
 
 /*




 


Rackspace

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