lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 18 Jan 2014 10:46:06 +0100
From:	Mike Galbraith <bitbucket@...ine.de>
To:	Stephen Rothwell <sfr@...b.auug.org.au>
Cc:	"H. Peter Anvin" <hpa@...or.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...e.hu>, Len Brown <lenb@...nel.org>,
	linux-next@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: linux-next: build failure after merge of the tip tree

On Fri, 2014-01-17 at 14:45 +1100, Stephen Rothwell wrote: 
> Hi all,
> 
> On Thu, 16 Jan 2014 14:51:08 -0800 "H. Peter Anvin" <hpa@...or.com> wrote:
> >
> > On 01/16/2014 02:34 PM, Stephen Rothwell wrote:
> > > 
> > > On Thu, 16 Jan 2014 23:25:36 +0100 Peter Zijlstra
> > > <peterz@...radead.org> wrote:
> > >> 
> > >> On Fri, Jan 17, 2014 at 07:46:28AM +1100, Stephen Rothwell
> > >> wrote:
> > >>> 
> > >>> On Thu, 16 Jan 2014 13:19:55 +0100 Peter Zijlstra
> > >>> <peterz@...radead.org> wrote:
> > >>>> 
> > >>>> I think the below ought to work
> > >>> 
> > >>> To be clear, all you did was replace the body of mwait_idle()
> > >>> with
> > >>> 
> > >>> mwait_idle_with_hints(0, 0);
> > >> 
> > >> Pretty much, and add the asm/mwait.h include, otherwise you'll
> > >> end up with a compile fail.
> > >> 
> > >>> (and the comment above it)?  I need to apply in incremental
> > >>> patch in the merge commit.
> > >> 
> > >> I don't think I touched the comment at all.
> > > 
> > 
> > In retrospect this bit probably should have gone through the idle
> > tree.  That was my bad, I need to coordinate with Len better.
> 
> So this is what I added as a merge fix patch.  Someone just needs to make
> sure Linus gets this when the latter of the tow trees gets merged.

I hope it doesn't look quite like that, next-20140117 is -ENOBOOT on
Q6600 box.  See below for an alternative.

> From: Stephen Rothwell <sfr@...b.auug.org.au>
> Date: Fri, 17 Jan 2014 14:42:06 +1100
> Subject: [PATCH] x86 idle: mwait_idle merge update
> 
> Signed-off-by: Stephen Rothwell <sfr@...b.auug.org.au>
> ---
>  arch/x86/kernel/process.c | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
> index db471a87fdd8..4da840f01561 100644
> --- a/arch/x86/kernel/process.c
> +++ b/arch/x86/kernel/process.c
> @@ -28,6 +28,7 @@
>  #include <asm/fpu-internal.h>
>  #include <asm/debugreg.h>
>  #include <asm/nmi.h>
> +#include <asm/mwait.h>
>  
>  /*
>   * per-CPU TSS segments. Threads are completely 'soft' on Linux,
> @@ -427,18 +428,7 @@ static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)
>  
>  static void mwait_idle(void)
>  {
> -	if (!need_resched()) {
> -		if (this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR))
> -			clflush((void *)&current_thread_info()->flags);
> -
> -		__monitor((void *)&current_thread_info()->flags, 0, 0);
> -		smp_mb();
> -		if (!need_resched())
> -			__sti_mwait(0, 0);
> -		else
> -			local_irq_enable();
> -	} else
> -		local_irq_enable();
> +	mwait_idle_with_hints(0, 0);
>  }
>  
>  void select_idle_routine(const struct cpuinfo_x86 *c)
> -- 
> 1.8.5.2

idle: kill unnecessary mwait_idle() resched IPIs

Set/clear polling instead.

Q6600, pipe-test scheduling cross core:
3.8.13                   487.2 KHz    1.000
3.13.0-master            415.5 KHz     .852
3.13.0-master+           415.2 KHz     .852     + restore mwait_idle
3.13.0-master++          488.5 KHz    1.002     + restore mwait_idle + IPI fix
3.13.0-next-20140117     -ENOBOOT
3.13.0-next-20140117+    531.4 KHz    1.090     + IPI fix

Signed-off-by: Mike Galbraith <bitbucket@...ine.de>
---
 arch/x86/include/asm/processor.h |    8 ++++++++
 arch/x86/kernel/process.c        |   10 +++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -723,6 +723,14 @@ static inline void sync_core(void)
 #endif
 }
 
+static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
+{
+	trace_hardirqs_on();
+	/* "mwait %eax, %ecx;" */
+	asm volatile("sti; .byte 0x0f, 0x01, 0xc9;"
+		     :: "a" (eax), "c" (ecx));
+}
+
 extern void select_idle_routine(const struct cpuinfo_x86 *c);
 extern void init_amd_e400_c1e_mask(void);
 
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -28,6 +28,7 @@
 #include <asm/fpu-internal.h>
 #include <asm/debugreg.h>
 #include <asm/nmi.h>
+#include <asm/mwait.h>
 
 /*
  * per-CPU TSS segments. Threads are completely 'soft' on Linux,
@@ -427,18 +428,21 @@ static int prefer_mwait_c1_over_halt(con
 
 static void mwait_idle(void)
 {
-	if (!need_resched()) {
-		if (this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR))
+	if (!current_set_polling_and_test()) {
+		if (static_cpu_has(X86_FEATURE_CLFLUSH_MONITOR)) {
+			mb();
 			clflush((void *)&current_thread_info()->flags);
+			mb();
+		}
 
 		__monitor((void *)&current_thread_info()->flags, 0, 0);
-		smp_mb();
 		if (!need_resched())
 			__sti_mwait(0, 0);
 		else
 			local_irq_enable();
 	} else
 		local_irq_enable();
+	current_clr_polling();
 }
 
 void select_idle_routine(const struct cpuinfo_x86 *c)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ