From: "H. Peter Anvin" <hpa@zytor.com>
To: Venkatesh Pallipadi <venki@google.com>
Cc: mingo@redhat.com, linux-kernel@vger.kernel.org,
asit.k.mallick@intel.com, arjan@linux.kernel.org,
a.p.zijlstra@chello.hl, lenb@kernel.org, tglx@linutronix.de,
hpa@linux.intel.com, linux-tip-commits@vger.kernel.org,
Andi Kleen <ak@linux.intel.com>
Subject: Re: [tip:x86/idle] x86, hotplug: Move WBINVD back outside the play_dead loop
Date: Mon, 20 Sep 2010 13:11:19 -0700 [thread overview]
Message-ID: <4C97BFE7.6050202@zytor.com> (raw)
In-Reply-To: <4C97A5EF.4070100@zytor.com>
[-- Attachment #1: Type: text/plain, Size: 1074 bytes --]
On 09/20/2010 11:20 AM, H. Peter Anvin wrote:
> On 09/17/2010 05:48 PM, Venkatesh Pallipadi wrote:
>>>
>>> + wbinvd();
>>> +
>>> while (1) {
>>> - mb();
>>> - wbinvd();
>>> __monitor(¤t_thread_info()->flags, 0, 0);
>>> mb();
>>
>>
>> Just one observation. There are some CPUs with errata that need
>> clflush before monitor. So, if that CPU wakesup spuriously it may have
>> problem reentering idle. Not sure whether that will be a problem as
>> that errata also depended on read happening on the flag. May be its
>> better to do monitor (0, 0, 0).
>>
>
> It seems the easy way to deal with that would be to just add clflush
> before monitor... it is *probably* redundant, but it should be safe to
> do. It means depending on X86_FEATURE_CLFLUSH as well as
> X86_FEATURE_MWAIT, but I don't think there is any x86 processor which
> has MWAIT and not CLFLUSH, and I highly doubt there ever will be.
>
> Does anyone see any downside?
>
Patch for review... anyone see any problem with it?
-hpa
[-- Attachment #2: 0001-x86-hotplug-In-the-MWAIT-case-of-play_dead-CLFLUSH-t.patch --]
[-- Type: text/x-patch, Size: 2265 bytes --]
>From 83c70ace9aad19ba7c41986f3c34a0808fbaf78f Mon Sep 17 00:00:00 2001
From: H. Peter Anvin <hpa@linux.intel.com>
Date: Mon, 20 Sep 2010 13:04:45 -0700
Subject: [PATCH] x86, hotplug: In the MWAIT case of play_dead, CLFLUSH the cache line
When we're using MWAIT for play_dead, explicitly CLFLUSH the cache
line before executing MONITOR. This is a potential workaround for the
Xeon 7400 erratum AAI65 after having a spurious wakeup and returning
around the loop. "Potential" here because it is not certain that that
erratum could actually trigger; however, the CLFLUSH should be
harmless.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: Asit Mallick <asit.k.mallick@intel.com>
Cc: Arjan van de Ven <arjan@linux.kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Venkatesh Pallipadi <venki@google.com>
---
arch/x86/kernel/smpboot.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 55c80ffb..fdccfe9 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1394,9 +1394,12 @@ static inline void mwait_play_dead(void)
unsigned int highest_cstate = 0;
unsigned int highest_subcstate = 0;
int i;
+ void *mwait_ptr;
if (!cpu_has(¤t_cpu_data, X86_FEATURE_MWAIT))
return;
+ if (!cpu_has(¤t_cpu_data, X86_FEATURE_CLFLSH))
+ return;
if (current_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
return;
@@ -1422,10 +1425,25 @@ static inline void mwait_play_dead(void)
(highest_subcstate - 1);
}
+ /*
+ * This should be a memory location in a cache line which is
+ * unlikely to be touched by other processors. The actual
+ * content is immaterial as it is not actually modified in any way.
+ */
+ mwait_ptr = ¤t_thread_info()->flags;
+
wbinvd();
while (1) {
- __monitor(¤t_thread_info()->flags, 0, 0);
+ /*
+ * The CLFLUSH is a workaround for erratum AAI65 for
+ * the Xeon 7400 series. It's not clear it is actually
+ * needed, but it should be harmless in either case.
+ * The WBINVD is insufficient due to the spurious-wakeup
+ * case where we return around the loop.
+ */
+ clflush(mwait_ptr);
+ __monitor(mwait_ptr, 0, 0);
mb();
__mwait(eax, 0);
}
--
1.7.2
next prev parent reply other threads:[~2010-09-20 20:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-22 23:19 [patch 0/2] x86: Make offline cpus to go to deepest idle state using mwait venkatesh.pallipadi
2009-05-22 23:19 ` [patch 1/2] x86: Add pm_play_dead funcptr to power-efficiently offline CPUs venkatesh.pallipadi
2009-05-23 10:44 ` Peter Zijlstra
2009-05-23 15:07 ` Pallipadi, Venkatesh
2009-06-22 17:25 ` Pallipadi, Venkatesh
2009-05-22 23:19 ` [patch 2/2] x86: put offline CPUs into deepest mwait cstate_subcstate venkatesh.pallipadi
2009-05-25 0:56 ` Shaohua Li
2009-05-26 21:17 ` Pallipadi, Venkatesh
2010-09-17 23:46 ` [tip:x86/idle] x86, hotplug: Use mwait to offline a processor, fix the legacy case tip-bot for H. Peter Anvin
2010-09-18 0:13 ` [tip:x86/idle] x86, hotplug: Move WBINVD back outside the play_dead loop tip-bot for H. Peter Anvin
2010-09-18 0:48 ` Venkatesh Pallipadi
2010-09-20 18:20 ` H. Peter Anvin
2010-09-20 20:11 ` H. Peter Anvin [this message]
2010-09-20 22:34 ` Venkatesh Pallipadi
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=4C97BFE7.6050202@zytor.com \
--to=hpa@zytor.com \
--cc=a.p.zijlstra@chello.hl \
--cc=ak@linux.intel.com \
--cc=arjan@linux.kernel.org \
--cc=asit.k.mallick@intel.com \
--cc=hpa@linux.intel.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=venki@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox