* [PATCH] x86: Add clflush before monitor for Intel 7400 series - v2
@ 2009-02-07 0:47 Pallipadi, Venkatesh
2009-02-07 14:02 ` Alan Cox
0 siblings, 1 reply; 7+ messages in thread
From: Pallipadi, Venkatesh @ 2009-02-07 0:47 UTC (permalink / raw)
To: H Peter Anvin, Ingo Molnar, thomas; +Cc: linux-kernel
For Intel 7400 series CPUs, the recommendation is to use a clflush on the
monitored address just before monitor and mwait pair [1]. This clflush makes
sure that there are no false wakeups from mwait when the monitored address
was recently written to.
[1] "MONITOR/MWAIT Recommendations for Intel Xeon Processor 7400 series"
section in specification update document of 7400 series
http://download.intel.com/design/xeon/specupdt/32033601.pdf
Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
---
Earlier patch:
http://marc.info/?l=linux-kernel&m=122341330606025&w=2
Current changes:
Minor modification based on Peter's comment
arch/x86/include/asm/cpufeature.h | 1 +
arch/x86/kernel/cpu/intel.c | 3 +++
arch/x86/kernel/process.c | 6 ++++++
3 files changed, 10 insertions(+)
Index: linux-2.6/arch/x86/kernel/cpu/intel.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/intel.c 2009-02-06 15:58:25.000000000 -0800
+++ linux-2.6/arch/x86/kernel/cpu/intel.c 2009-02-06 16:11:41.000000000 -0800
@@ -291,6 +291,9 @@ static void __cpuinit init_intel(struct
ds_init_intel(c);
}
+ if (c->x86 == 6 && c->x86_model == 29 && cpu_has_clflush)
+ set_cpu_cap(c, X86_FEATURE_CLFLUSH_MONITOR);
+
#ifdef CONFIG_X86_64
if (c->x86 == 15)
c->x86_cache_alignment = c->x86_clflush_size * 2;
Index: linux-2.6/arch/x86/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/process.c 2009-02-03 12:58:38.000000000 -0800
+++ linux-2.6/arch/x86/kernel/process.c 2009-02-06 16:11:41.000000000 -0800
@@ -180,6 +180,9 @@ void mwait_idle_with_hints(unsigned long
trace_power_start(&it, POWER_CSTATE, (ax>>4)+1);
if (!need_resched()) {
+ if (cpu_has(¤t_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
+ clflush((void *)¤t_thread_info()->flags);
+
__monitor((void *)¤t_thread_info()->flags, 0, 0);
smp_mb();
if (!need_resched())
@@ -194,6 +197,9 @@ static void mwait_idle(void)
struct power_trace it;
if (!need_resched()) {
trace_power_start(&it, POWER_CSTATE, 1);
+ if (cpu_has(¤t_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
+ clflush((void *)¤t_thread_info()->flags);
+
__monitor((void *)¤t_thread_info()->flags, 0, 0);
smp_mb();
if (!need_resched())
Index: linux-2.6/arch/x86/include/asm/cpufeature.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/cpufeature.h 2009-02-06 16:11:12.000000000 -0800
+++ linux-2.6/arch/x86/include/asm/cpufeature.h 2009-02-06 16:40:44.000000000 -0800
@@ -93,6 +93,7 @@
#define X86_FEATURE_XTOPOLOGY (3*32+22) /* cpu topology enum extensions */
#define X86_FEATURE_TSC_RELIABLE (3*32+23) /* TSC is known to be reliable */
#define X86_FEATURE_NONSTOP_TSC (3*32+24) /* TSC does not stop in C states */
+#define X86_FEATURE_CLFLUSH_MONITOR (3*32+25) /* "" clflush reqd with monitor */
/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
#define X86_FEATURE_XMM3 (4*32+ 0) /* "pni" SSE-3 */
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] x86: Add clflush before monitor for Intel 7400 series - v2
2009-02-07 0:47 [PATCH] x86: Add clflush before monitor for Intel 7400 series - v2 Pallipadi, Venkatesh
@ 2009-02-07 14:02 ` Alan Cox
2009-02-07 16:47 ` Pallipadi, Venkatesh
0 siblings, 1 reply; 7+ messages in thread
From: Alan Cox @ 2009-02-07 14:02 UTC (permalink / raw)
To: Pallipadi, Venkatesh; +Cc: H Peter Anvin, Ingo Molnar, thomas, linux-kernel
On Fri, 6 Feb 2009 16:47:29 -0800
"Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com> wrote:
>
>
> For Intel 7400 series CPUs, the recommendation is to use a clflush on the
> monitored address just before monitor and mwait pair [1]. This clflush makes
> sure that there are no false wakeups from mwait when the monitored address
> was recently written to.
Given our mwait usages will very quickly go back to sleep in such a case
and it would almost certainly be one sleep only is this really worth the
effort ?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86: Add clflush before monitor for Intel 7400 series - v2
2009-02-07 14:02 ` Alan Cox
@ 2009-02-07 16:47 ` Pallipadi, Venkatesh
2009-02-09 5:53 ` Nick Piggin
0 siblings, 1 reply; 7+ messages in thread
From: Pallipadi, Venkatesh @ 2009-02-07 16:47 UTC (permalink / raw)
To: Alan Cox
Cc: Pallipadi, Venkatesh, H Peter Anvin, Ingo Molnar,
thomas@linux-os.sc.intel.com, linux-kernel
On Sat, Feb 07, 2009 at 06:02:45AM -0800, Alan Cox wrote:
> On Fri, 6 Feb 2009 16:47:29 -0800
> "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com> wrote:
>
> >
> >
> > For Intel 7400 series CPUs, the recommendation is to use a clflush on the
> > monitored address just before monitor and mwait pair [1]. This clflush makes
> > sure that there are no false wakeups from mwait when the monitored address
> > was recently written to.
>
> Given our mwait usages will very quickly go back to sleep in such a case
> and it would almost certainly be one sleep only is this really worth the
> effort ?
Yes. If we only consider the CPU idle behavior, we really do not need the
patch as we will go back to idle. But, there are other factors:
- drivers/idle/i7300_idle.c which tries to save memory power based on CPU
idle time. It gets confused with these short idles.
- cpuidle menu governor These platforms may also support more than one C-state.
C1 and CC3. So, we will go through the C-state policy in menu governor, which
again looks at idle time and may end up taking wrong decisions due to these
short idles.
We can make the above code to be more clever, to ignore short idles. But, this
patch seems to be the easier and clean way as the errata is only in a particular
CPU model.
Thanks,
Venki
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86: Add clflush before monitor for Intel 7400 series - v2
2009-02-07 16:47 ` Pallipadi, Venkatesh
@ 2009-02-09 5:53 ` Nick Piggin
2009-02-09 21:37 ` Pallipadi, Venkatesh
0 siblings, 1 reply; 7+ messages in thread
From: Nick Piggin @ 2009-02-09 5:53 UTC (permalink / raw)
To: Pallipadi, Venkatesh
Cc: Alan Cox, H Peter Anvin, Ingo Molnar,
thomas@linux-os.sc.intel.com, linux-kernel
On Sunday 08 February 2009 03:47:07 Pallipadi, Venkatesh wrote:
> On Sat, Feb 07, 2009 at 06:02:45AM -0800, Alan Cox wrote:
> > On Fri, 6 Feb 2009 16:47:29 -0800
> >
> > "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com> wrote:
> > > For Intel 7400 series CPUs, the recommendation is to use a clflush on
> > > the monitored address just before monitor and mwait pair [1]. This
> > > clflush makes sure that there are no false wakeups from mwait when the
> > > monitored address was recently written to.
> >
> > Given our mwait usages will very quickly go back to sleep in such a case
> > and it would almost certainly be one sleep only is this really worth the
> > effort ?
>
> Yes. If we only consider the CPU idle behavior, we really do not need the
> patch as we will go back to idle. But, there are other factors:
> - drivers/idle/i7300_idle.c which tries to save memory power based on CPU
> idle time. It gets confused with these short idles.
> - cpuidle menu governor These platforms may also support more than one
> C-state. C1 and CC3. So, we will go through the C-state policy in menu
> governor, which again looks at idle time and may end up taking wrong
> decisions due to these short idles.
>
> We can make the above code to be more clever, to ignore short idles. But,
> this patch seems to be the easier and clean way as the errata is only in a
> particular CPU model.
Have you benchmarked it? With something like tbench which IIRC should
generate a good number of idle/busy transitions?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86: Add clflush before monitor for Intel 7400 series - v2
2009-02-09 5:53 ` Nick Piggin
@ 2009-02-09 21:37 ` Pallipadi, Venkatesh
0 siblings, 0 replies; 7+ messages in thread
From: Pallipadi, Venkatesh @ 2009-02-09 21:37 UTC (permalink / raw)
To: Nick Piggin; +Cc: Alan Cox, H Peter Anvin, Ingo Molnar, tglx, linux-kernel
On Sun, 2009-02-08 at 21:53 -0800, Nick Piggin wrote:
> On Sunday 08 February 2009 03:47:07 Pallipadi, Venkatesh wrote:
> > On Sat, Feb 07, 2009 at 06:02:45AM -0800, Alan Cox wrote:
> > > On Fri, 6 Feb 2009 16:47:29 -0800
> > >
> > > "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com> wrote:
> > > > For Intel 7400 series CPUs, the recommendation is to use a clflush on
> > > > the monitored address just before monitor and mwait pair [1]. This
> > > > clflush makes sure that there are no false wakeups from mwait when the
> > > > monitored address was recently written to.
> > >
> > > Given our mwait usages will very quickly go back to sleep in such a case
> > > and it would almost certainly be one sleep only is this really worth the
> > > effort ?
> >
> > Yes. If we only consider the CPU idle behavior, we really do not need the
> > patch as we will go back to idle. But, there are other factors:
> > - drivers/idle/i7300_idle.c which tries to save memory power based on CPU
> > idle time. It gets confused with these short idles.
> > - cpuidle menu governor These platforms may also support more than one
> > C-state. C1 and CC3. So, we will go through the C-state policy in menu
> > governor, which again looks at idle time and may end up taking wrong
> > decisions due to these short idles.
> >
> > We can make the above code to be more clever, to ignore short idles. But,
> > this patch seems to be the easier and clean way as the errata is only in a
> > particular CPU model.
>
> Have you benchmarked it? With something like tbench which IIRC should
> generate a good number of idle/busy transitions?
>
We haven't run tbench specifically. But, we noticed this issue running
specpower workload on this platform. Especially the 10-20% point of
specpower, which also has notable idle/busy transitions, this patch
helps.
Thanks,
Venki
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] x86: Add clflush before monitor for Intel 7400 series - v2
@ 2009-02-07 0:52 Pallipadi, Venkatesh
2009-02-09 10:15 ` Ingo Molnar
0 siblings, 1 reply; 7+ messages in thread
From: Pallipadi, Venkatesh @ 2009-02-07 0:52 UTC (permalink / raw)
To: H Peter Anvin, Ingo Molnar, Thomas Gleixner; +Cc: linux-kernel
(Sorry for the duplicate. resending to proper recipients)
For Intel 7400 series CPUs, the recommendation is to use a clflush on the
monitored address just before monitor and mwait pair [1]. This clflush makes
sure that there are no false wakeups from mwait when the monitored address
was recently written to.
[1] "MONITOR/MWAIT Recommendations for Intel Xeon Processor 7400 series"
section in specification update document of 7400 series
http://download.intel.com/design/xeon/specupdt/32033601.pdf
Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
---
Earlier patch:
http://marc.info/?l=linux-kernel&m=122341330606025&w=2
Current changes:
Minor modification based on Peter's comment
arch/x86/include/asm/cpufeature.h | 1 +
arch/x86/kernel/cpu/intel.c | 3 +++
arch/x86/kernel/process.c | 6 ++++++
3 files changed, 10 insertions(+)
Index: linux-2.6/arch/x86/kernel/cpu/intel.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/intel.c 2009-02-06 15:58:25.000000000 -0800
+++ linux-2.6/arch/x86/kernel/cpu/intel.c 2009-02-06 16:11:41.000000000 -0800
@@ -291,6 +291,9 @@ static void __cpuinit init_intel(struct
ds_init_intel(c);
}
+ if (c->x86 == 6 && c->x86_model == 29 && cpu_has_clflush)
+ set_cpu_cap(c, X86_FEATURE_CLFLUSH_MONITOR);
+
#ifdef CONFIG_X86_64
if (c->x86 == 15)
c->x86_cache_alignment = c->x86_clflush_size * 2;
Index: linux-2.6/arch/x86/kernel/process.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/process.c 2009-02-03 12:58:38.000000000 -0800
+++ linux-2.6/arch/x86/kernel/process.c 2009-02-06 16:11:41.000000000 -0800
@@ -180,6 +180,9 @@ void mwait_idle_with_hints(unsigned long
trace_power_start(&it, POWER_CSTATE, (ax>>4)+1);
if (!need_resched()) {
+ if (cpu_has(¤t_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
+ clflush((void *)¤t_thread_info()->flags);
+
__monitor((void *)¤t_thread_info()->flags, 0, 0);
smp_mb();
if (!need_resched())
@@ -194,6 +197,9 @@ static void mwait_idle(void)
struct power_trace it;
if (!need_resched()) {
trace_power_start(&it, POWER_CSTATE, 1);
+ if (cpu_has(¤t_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
+ clflush((void *)¤t_thread_info()->flags);
+
__monitor((void *)¤t_thread_info()->flags, 0, 0);
smp_mb();
if (!need_resched())
Index: linux-2.6/arch/x86/include/asm/cpufeature.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/cpufeature.h 2009-02-06 16:11:12.000000000 -0800
+++ linux-2.6/arch/x86/include/asm/cpufeature.h 2009-02-06 16:40:44.000000000 -0800
@@ -93,6 +93,7 @@
#define X86_FEATURE_XTOPOLOGY (3*32+22) /* cpu topology enum extensions */
#define X86_FEATURE_TSC_RELIABLE (3*32+23) /* TSC is known to be reliable */
#define X86_FEATURE_NONSTOP_TSC (3*32+24) /* TSC does not stop in C states */
+#define X86_FEATURE_CLFLUSH_MONITOR (3*32+25) /* "" clflush reqd with monitor */
/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
#define X86_FEATURE_XMM3 (4*32+ 0) /* "pni" SSE-3 */
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] x86: Add clflush before monitor for Intel 7400 series - v2
2009-02-07 0:52 Pallipadi, Venkatesh
@ 2009-02-09 10:15 ` Ingo Molnar
0 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2009-02-09 10:15 UTC (permalink / raw)
To: Pallipadi, Venkatesh; +Cc: H Peter Anvin, Thomas Gleixner, linux-kernel
* Pallipadi, Venkatesh <venkatesh.pallipadi@intel.com> wrote:
> For Intel 7400 series CPUs, the recommendation is to use a clflush on the
> monitored address just before monitor and mwait pair [1]. This clflush makes sure
> that there are no false wakeups from mwait when the monitored address was recently
> written to.
>
> [1] "MONITOR/MWAIT Recommendations for Intel Xeon Processor 7400 series"
> section in specification update document of 7400 series
> http://download.intel.com/design/xeon/specupdt/32033601.pdf
>
> Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
>
> ---
>
> Earlier patch:
> http://marc.info/?l=linux-kernel&m=122341330606025&w=2
>
> Current changes:
> Minor modification based on Peter's comment
>
> arch/x86/include/asm/cpufeature.h | 1 +
> arch/x86/kernel/cpu/intel.c | 3 +++
> arch/x86/kernel/process.c | 6 ++++++
> 3 files changed, 10 insertions(+)
applied to tip/x86/urgent, thanks Venki!
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-02-09 21:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-07 0:47 [PATCH] x86: Add clflush before monitor for Intel 7400 series - v2 Pallipadi, Venkatesh
2009-02-07 14:02 ` Alan Cox
2009-02-07 16:47 ` Pallipadi, Venkatesh
2009-02-09 5:53 ` Nick Piggin
2009-02-09 21:37 ` Pallipadi, Venkatesh
-- strict thread matches above, loose matches on Subject: below --
2009-02-07 0:52 Pallipadi, Venkatesh
2009-02-09 10:15 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox