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, 17 Apr 2010 08:00:32 +1000
From:	Benjamin Herrenschmidt <benh@...nel.crashing.org>
To:	Peter Zijlstra <peterz@...radead.org>
Cc:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>
Subject: Re: Possible bug with mutex adaptative spinning


> 
> I've queued the below patch

Thanks. Should it make -stable as well ?

Cheers,
Ben.

> ---
> Subject: mutex: Don't spin when the owner CPU is offline or other weird cases
> From: Benjamin Herrenschmidt <benh@...nel.crashing.org>
> Date: Fri Apr 16 23:20:00 CEST 2010
> 
> Due to recent load-balancer changes that delay the task migration to
> the next wakeup, the adaptive mutex spinning ends up in a live lock
> when the owner's CPU gets offlined because the cpu_online() check
> lives before the owner running check.
> 
> This patch changes mutex_spin_on_owner() to return 0 (don't spin) in
> any case where we aren't sure about the owner struct validity or CPU
> number, and if the said CPU is offline. There is no point going back &
> re-evaluate spinning in corner cases like that, let's just go to
> sleep.
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@...nel.crashing.org>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@...llo.nl>
> LKML-Reference: <1271212509.13059.135.camel@...glop>
> ---
>  kernel/sched.c |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> Index: linux-2.6/kernel/sched.c
> ===================================================================
> --- linux-2.6.orig/kernel/sched.c
> +++ linux-2.6/kernel/sched.c
> @@ -3647,7 +3647,7 @@ int mutex_spin_on_owner(struct mutex *lo
>  	 * the mutex owner just released it and exited.
>  	 */
>  	if (probe_kernel_address(&owner->cpu, cpu))
> -		goto out;
> +		return 0;
>  #else
>  	cpu = owner->cpu;
>  #endif
> @@ -3657,14 +3657,14 @@ int mutex_spin_on_owner(struct mutex *lo
>  	 * the cpu field may no longer be valid.
>  	 */
>  	if (cpu >= nr_cpumask_bits)
> -		goto out;
> +		return 0;
>  
>  	/*
>  	 * We need to validate that we can do a
>  	 * get_cpu() and that we have the percpu area.
>  	 */
>  	if (!cpu_online(cpu))
> -		goto out;
> +		return 0;
>  
>  	rq = cpu_rq(cpu);
>  
> @@ -3683,7 +3683,7 @@ int mutex_spin_on_owner(struct mutex *lo
>  
>  		cpu_relax();
>  	}
> -out:
> +
>  	return 1;
>  }
>  #endif
> 


--
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