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

Re: [RFC PATCH] x86/ACPI: optimise C3 entry on AMD CPUs


  • To: Olivier Lambert <olivier.lambert@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Wed, 30 Sep 2026 14:25:41 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vates.tech smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=+NrjXNh/RIPIbOzsCOKY7iAtWSnpj1mura0xwpsM7Ok=; b=EhgMSstyNp2JlpO6QRlMqd6vkkTaokrlsgJ5rEHamMSag/hxY9rBnIflYJq6O8zEmpYJiTCeOvmmODL+9utJakXc15THkGG4ORddIL2eCU9q2T9VWXnO7MdkJOY5GJFUzA9ykCWrQQagMgnj4QBMyjqhEtdKkpLZ6UGoYl1SkpuFFpKU5Vpn1extOuEJhoNrEY8vCx56abLGGk4D0CQ3O7G4KZ2scx4TYJCW1isEys6qOjkMd+miS2LvCU/mWGiACfSf1pyKpf+oBrqYyKB+DkKVfzEyYDQ/k2RW07SElHIH5vp0vkCWwzuKuI3uyU2EbgL8pHDaWzDwKHUrkwYgLw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=agCvhycvPzc9bsxFwfntOIMBx4CXZ4UDTM2hhb7qtQTBXGkV9Wa5TzJ8uxcA6xwfrrCXSQWgZKWglVhb4xU9nXX0vBIWjl5yB0AXHdFSpZAh89sEdFKJ3WJRuIxNDEyty0etTsWOTvLJTGF3QKo+/cwvrjBwEk9bXKcwwgjntTmH23+jxgqq87rOKDrtmeWop8WLCgBE3GSWbI2pLgX0TnIT8/cpoA+nouStyJ/k1tK8e7i8vZUxQcyzYTlGnUeS7/rh/dCq0mkNU79QArtHFqWteA9FSNFr2swlvpy6arPYvCBFlEEcaGfd2yrrkPM/DETTtfhd7jXDWk/WOhCjng==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monn <roger@xxxxxxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Wed, 30 Sep 2026 18:25:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2026-09-30 14:13, Olivier Lambert wrote:
All Zen or newer CPU which support C3 shares cache. Its not necessary to
flush the caches in software before entering C3. This will cause drop in
performance for the cores which share some caches. ARB_DIS is not used
with current AMD C state implementation. So set related flags correctly.
Signed-off-by: Deepak Sharma <deepak.sharma@xxxxxxx>
Acked-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
Origin: https://git.kernel.org/torvalds/p/a8fb40966f19 
[https://git.kernel.org/torvalds/p/a8fb40966f19]
[Port to Xen. Include Hygon.]
Assisted-by: Claude-Code:claude-opus-5-5
Signed-off-by: Olivier Lambert <olivier.lambert@xxxxxxxxxx>

Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>

but...

---
Found on XCP-ng 8.3 (Xen 4.17.6) on a Ryzen 5 7600 (Zen 4, family 0x19)
whose _CST lists C1 (HLT) plus C2 and C3 as SYSIO states (C3 exit
latency 350us). With bm_check == 0, every C3 entry executes WBINVD.
Measured under a VM-to-VM network load, in 25s windows:
- ~140 WBINVD/s, 65-69us each on average, 300us at worst.
- Spinning on each CPU in turn with IRQs off and reading the TSC shows
gaps of up to 222us; none with this change. The SMI count (PMC event
0x2b, validated by counting cycles on the same counter) stayed at 0,
and NMIs didn't line up with the gaps.
- credit1's do_schedule() occasionally took up to 262us, with IRQs
off; at most 4.4us with this change.
- xenpm set-max-cstate 1 removes the stalls too, which points at C3
entry.
This change was booted and measured as a backport on 4.17.6 only. On
staging it is build-tested. It also covers Hygon, as Linux does today
through X86_FEATURE_ZEN; the original Linux commit was AMD-only.
This will conflict trivially with Alejandro's pending "x86/acpi: Migrate
vendor checks to cpu_vendor()"; happy to rebase on top of it.
Possibly a backport candidate.
xen/arch/x86/acpi/cpu_idle.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c
index 56b22a2..b2bca4d 100644
--- a/xen/arch/x86/acpi/cpu_idle.c
+++ b/xen/arch/x86/acpi/cpu_idle.c
@@ -1065,6 +1065,24 @@ static void acpi_processor_power_init_bm_check(struct 
acpi_processor_flags *flag
*/
if ( c->vendor == X86_VENDOR_INTEL )
flags->bm_control = 0;
+
+ if ( (c->vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) &&

... you've lost all indenting.

Regards,
Jason



 


Rackspace

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