All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: K Prateek Nayak <kprateek.nayak@amd.com>, linux-kernel@vger.kernel.org
Cc: rafael@kernel.org, lenb@kernel.org, linux-acpi@vger.kernel.org,
	linux-pm@vger.kernel.org, dave.hansen@linux.intel.com,
	bp@alien8.de, tglx@linutronix.de, andi@lisas.de, puwen@hygon.cn,
	mario.limonciello@amd.com, peterz@infradead.org,
	rui.zhang@intel.com, gpiccoli@igalia.com,
	daniel.lezcano@linaro.org, ananth.narayan@amd.com,
	gautham.shenoy@amd.com, Calvin Ong <calvin.ong@amd.com>,
	stable@vger.kernel.org, regressions@lists.linux.dev
Subject: Re: [PATCH] ACPI: processor_idle: Skip dummy wait for processors based on the Zen microarchitecture
Date: Thu, 22 Sep 2022 10:01:46 -0700	[thread overview]
Message-ID: <88c17568-8694-940a-0f1f-9d345e8dcbdb@intel.com> (raw)
In-Reply-To: <0885eecb-042f-3b74-2965-7d657de59953@amd.com>

[-- Attachment #1: Type: text/plain, Size: 519 bytes --]

On 9/22/22 09:54, K Prateek Nayak wrote:
> 
> On 9/22/2022 10:14 PM, Dave Hansen wrote:
>> On 9/20/22 23:36, K Prateek Nayak wrote:
>>> Cc: stable@vger.kernel.org
>>> Cc: regressions@lists.linux.dev
>> *Is* this a regression?
> On second thought, it is not a regression.
> Will remove the tag on v2.

What were you planning for v2?

Rafael suggested something like the attached patch.  It's not nearly as
fragile as the Zen check you proposed earlier.

Any testing or corrections on the commentary would be appreciated.

[-- Attachment #2: 0001-ACPI-processor-idle-Limit-Dummy-wait-workaround-to-o.patch --]
[-- Type: text/x-patch, Size: 2918 bytes --]

From 54e4668122d447ee80ec465f244b19d968c4a7c6 Mon Sep 17 00:00:00 2001
From: Dave Hansen <dave.hansen@intel.com>
Date: Thu, 22 Sep 2022 09:22:26 -0700
Subject: [PATCH] ACPI: processor idle: Limit "Dummy wait" workaround to old
 Intel systems

Old, circa 2002 chipsets have a bug: they don't go idle when they are
supposed to.  So, a workaround was added to slow the CPU down and
ensure that the CPU waits a bit for the chipset to actually go idle.
This workaround is ancient and has been in place in some form since
the original kernel ACPI implementation.

But, this workaround is very painful on modern systems.  The "inb()"
can take thousands of cycles (see Link: for some more detailed
archaeology).

First and foremost, modern systems should not be using this code.
Typical Intel systems have not used it in over a decade because it
is horribly inferior to MWAIT-based idle.

Despite this, people do seem to be tripping over this workaround on
AMD CPUs today.

Limit the "dummy wait" workaround to Intel systems.  Since this
code is only used on ancient Intel systems, this fix should render it
harmless everywhere else, including the modern AMD ones.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Len Brown <lenb@kernel.org>
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reported-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://lore.kernel.org/all/20220921063638.2489-1-kprateek.nayak@amd.com/
---
 drivers/acpi/processor_idle.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 16a1663d02d4..9f40917c49ef 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -531,10 +531,27 @@ static void wait_for_freeze(void)
 	/* No delay is needed if we are in guest */
 	if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return;
+	/*
+	 * Modern (>=Nehalem) Intel systems use ACPI via intel_idle,
+	 * not this code.  Assume that any Intel systems using this
+	 * are ancient and may need the dummy wait.  This also assumes
+	 * that the motivating chipset issue was Intel-only.
+	 */
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
+		return;
 #endif
-	/* Dummy wait op - must do something useless after P_LVL2 read
-	   because chipsets cannot guarantee that STPCLK# signal
-	   gets asserted in time to freeze execution properly. */
+	/*
+	 * Dummy wait op - must do something useless after P_LVL2 read
+	 * because chipsets cannot guarantee that STPCLK# signal gets
+	 * asserted in time to freeze execution properly
+	 *
+	 * This workaround has been in place since the original ACPI
+	 * implementation was merged, circa 2002.
+	 *
+	 * If a profile is pointing to this instruction, please first
+	 * consider moving your system to a more modern idle
+	 * mechanism.
+	 */
 	inl(acpi_gbl_FADT.xpm_timer_block.address);
 }
 
-- 
2.25.1


  reply	other threads:[~2022-09-22 17:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21  6:36 [PATCH] ACPI: processor_idle: Skip dummy wait for processors based on the Zen microarchitecture K Prateek Nayak
2022-09-21  8:47 ` Borislav Petkov
2022-09-21 10:39   ` K Prateek Nayak
2022-09-21 13:10     ` Borislav Petkov
2022-09-21 14:15 ` Dave Hansen
2022-09-21 19:51   ` Borislav Petkov
2022-09-21 19:55     ` Limonciello, Mario
2022-09-22  3:58     ` Ananth Narayan
2022-09-22  5:44   ` K Prateek Nayak
     [not found]   ` <20220923160106.9297-1-ermorton@ericmoronsm1mbp.amd.com>
2022-09-23 16:15     ` Ananth Narayan
2022-09-21 15:00 ` Peter Zijlstra
2022-09-21 19:48   ` Borislav Petkov
2022-09-22  8:17     ` Peter Zijlstra
2022-09-22 15:21       ` Rafael J. Wysocki
2022-09-22 15:36         ` Borislav Petkov
2022-09-22 15:53           ` Rafael J. Wysocki
2022-09-22 16:36             ` Dave Hansen
2022-09-22 16:44 ` Dave Hansen
2022-09-22 16:54   ` K Prateek Nayak
2022-09-22 17:01     ` Dave Hansen [this message]
2022-09-22 17:48       ` Limonciello, Mario
2022-09-22 18:17         ` Dave Hansen
2022-09-22 18:28           ` Limonciello, Mario
2022-09-23 11:47             ` Ananth Narayan
2022-09-22 19:42       ` Andreas Mohr
2022-09-22 20:10         ` Andreas Mohr
2022-09-22 21:21           ` Dave Hansen
2022-09-22 21:38             ` Limonciello, Mario
2022-09-23  7:42             ` Peter Zijlstra
2022-09-23  7:57             ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=88c17568-8694-940a-0f1f-9d345e8dcbdb@intel.com \
    --to=dave.hansen@intel.com \
    --cc=ananth.narayan@amd.com \
    --cc=andi@lisas.de \
    --cc=bp@alien8.de \
    --cc=calvin.ong@amd.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=gautham.shenoy@amd.com \
    --cc=gpiccoli@igalia.com \
    --cc=kprateek.nayak@amd.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=peterz@infradead.org \
    --cc=puwen@hygon.cn \
    --cc=rafael@kernel.org \
    --cc=regressions@lists.linux.dev \
    --cc=rui.zhang@intel.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.