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]
Message-ID: <1272893191.5605.121.camel@twins>
Date:	Mon, 03 May 2010 15:26:31 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Tejun Heo <tj@...nel.org>
Cc:	mingo@...e.hu, linux-kernel@...r.kernel.org, x86@...nel.org,
	oleg@...hat.com, rusty@...tcorp.com.au, sivanich@....com,
	heiko.carstens@...ibm.com, dipankar@...ibm.com,
	josh@...edesktop.org, paulmck@...ux.vnet.ibm.com,
	akpm@...ux-foundation.org, arjan@...ux.intel.com,
	torvalds@...ux-foundation.org
Subject: Re: [PATCH 1/4] cpu_stop: implement stop_cpu[s]()

On Thu, 2010-04-22 at 18:09 +0200, Tejun Heo wrote:

> +struct cpu_stop_done {
> +	atomic_t		nr_todo;	/* nr left to execute */
> +	bool			executed;	/* actually executed? */
> +	int			ret;		/* collected return value */
> +	struct completion	completion;	/* fired if nr_todo reaches 0 */
> +};
> +

> +/* signal completion unless @done is NULL */
> +static void cpu_stop_signal_done(struct cpu_stop_done *done, bool executed)
> +{
> +	if (done) {
> +		if (executed)
> +			done->executed = true;
> +		if (atomic_dec_and_test(&done->nr_todo))
> +			complete(&done->completion);
> +	}
> +}
> +
> +/* queue @work to @stopper.  if offline, @work is completed immediately */
> +static void cpu_stop_queue_work(struct cpu_stopper *stopper,
> +				struct cpu_stop_work *work)
> +{
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&stopper->lock, flags);
> +
> +	if (stopper->enabled) {
> +		list_add_tail(&work->list, &stopper->works);
> +		wake_up_process(stopper->thread);
> +	} else
> +		cpu_stop_signal_done(work->done, false);
> +
> +	spin_unlock_irqrestore(&stopper->lock, flags);
> +}
> +

> +int stop_one_cpu(unsigned int cpu, cpu_stop_fn_t fn, void *arg)
> +{
> +	struct cpu_stop_done done;
> +	struct cpu_stop_work work = { .fn = fn, .arg = arg, .done = &done };
> +
> +	cpu_stop_init_done(&done, 1);
> +	cpu_stop_queue_work(&per_cpu(cpu_stopper, cpu), &work);
> +	wait_for_completion(&done.completion);
> +	return done.executed ? done.ret : -ENOENT;
> +}

If you do:

 done = { .ret = -ENOENT, };

And remove that if()

> +		ret = work->fn(work->arg);
> +		if (ret)
> +			done->ret = ret;
> +

You can do away with all the ->executed bits.
--
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