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] [day] [month] [year] [list]
Message-ID: <20110930233932.GB2658@mtj.dyndns.org>
Date:	Fri, 30 Sep 2011 16:39:32 -0700
From:	Tejun Heo <tj@...nel.org>
To:	Jeremy Fitzhardinge <jeremy@...p.org>
Cc:	Rusty Russell <rusty@...tcorp.com.au>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Ingo Molnar <mingo@...e.hu>,
	Steven Rostedt <rostedt@...dmis.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH RFC] stop_machine: make stop_machine safe and efficient
 to call early

Hello,

On Fri, Sep 30, 2011 at 04:32:40PM -0700, Jeremy Fitzhardinge wrote:
> > As others have pointed out, you'll need to call both local and hardirq
> > disables.  Also, I think the description and the code are a bit
> > misleading.  How aobut setting cpu_stop_initialized in cpu_stop_init()
> > and testing it from __stop_machine() instead?  I think it would be
> > better to keep the behavior as uniform as possible once things are up
> > and running.
> 
> Yes, I was wondering about that.  Do you think the patch (with irq fixes
> in place) would affect the behaviour of an SMP kernel running UP?

I can't think of anything which could go wrong from the top of my head
but there's no reason to risk subtle issues when the alternative isn't
difficult.

> diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
> index f5855fe3..70b3be4 100644
> --- a/kernel/stop_machine.c
> +++ b/kernel/stop_machine.c
> @@ -41,6 +41,7 @@ struct cpu_stopper {
>  };
>  
>  static DEFINE_PER_CPU(struct cpu_stopper, cpu_stopper);
> +static bool stop_machine_initialized = false;
>  
>  static void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo)
>  {
> @@ -386,6 +387,8 @@ static int __init cpu_stop_init(void)
>  	cpu_stop_cpu_callback(&cpu_stop_cpu_notifier, CPU_ONLINE, bcpu);
>  	register_cpu_notifier(&cpu_stop_cpu_notifier);
>  
> +	stop_machine_initialized = true;
> +
>  	return 0;
>  }
>  early_initcall(cpu_stop_init);
> @@ -485,7 +488,7 @@ int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus)
>  					    .num_threads = num_online_cpus(),
>  					    .active_cpus = cpus };
>  
> -	if (smdata.num_threads == 1) {
> +	if (!stop_machine_initialized) {

Yeah, this looks good to me.  You might want to add
WARN_ON_ONCE(smdata.num_threads != 1) inside if {} tho.

Thank you.

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