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: <4FA35EC8.5090804@linux.vnet.ibm.com>
Date:	Fri, 04 May 2012 10:14:56 +0530
From:	"Srivatsa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>
To:	Gilad Ben-Yossef <gilad@...yossef.com>
CC:	linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
	Tejun Heo <tj@...nel.org>, John Stultz <johnstul@...ibm.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Mel Gorman <mel@....ul.ie>, Mike Frysinger <vapier@...too.org>,
	David Rientjes <rientjes@...gle.com>,
	Hugh Dickins <hughd@...gle.com>,
	Minchan Kim <minchan.kim@...il.com>,
	Konstantin Khlebnikov <khlebnikov@...nvz.org>,
	Christoph Lameter <cl@...ux.com>,
	Chris Metcalf <cmetcalf@...era.com>,
	Hakan Akkan <hakanakkan@...il.com>,
	Max Krasnyansky <maxk@...lcomm.com>,
	Frederic Weisbecker <fweisbec@...il.com>, linux-mm@...ck.org
Subject: Re: [PATCH v1 2/6] workqueue: introduce schedule_on_each_cpu_mask

On 05/03/2012 08:25 PM, Gilad Ben-Yossef wrote:

> Introduce schedule_on_each_cpu_mask function to schedule a work
> item on each online CPU which is included in the mask provided.
> 
> Then re-implement schedule_on_each_cpu on top of the new function.
> 
> This function should be prefered to schedule_on_each_cpu in
> any case where some of the CPUs, especially on a big multi-core
> system, might not have actual work to perform in order to save
> needless wakeups and schedules.
> 
> Signed-off-by: Gilad Ben-Yossef <gilad@...yossef.com>


>  /**
> - * schedule_on_each_cpu - execute a function synchronously on each online CPU
> + * schedule_on_each_cpu_mask - execute a function synchronously on each
> + * online CPU which is specified in the supplied cpumask
>   * @func: the function to call
> + * @mask: the cpu mask
>   *
> - * schedule_on_each_cpu() executes @func on each online CPU using the
> - * system workqueue and blocks until all CPUs have completed.
> - * schedule_on_each_cpu() is very slow.
> + * schedule_on_each_cpu_mask() executes @func on each online CPU which
> + * is part of the @mask using the * system workqueue and blocks until

                                    ^^^
stray character?

> + * all CPUs have completed
> + * schedule_on_each_cpu_mask() is very slow.
>   *
>   * RETURNS:
>   * 0 on success, -errno on failure.
>   */
> -int schedule_on_each_cpu(work_func_t func)
> +int schedule_on_each_cpu_mask(work_func_t func, const struct cpumask *mask)
>  {
>  	int cpu;
>  	struct work_struct __percpu *works;
> 
>  	works = alloc_percpu(struct work_struct);
> -	if (!works)
> +	if (unlikely(!works))
>  		return -ENOMEM;
> 
>  	get_online_cpus();
> 
> -	for_each_online_cpu(cpu) {
> +	for_each_cpu_and(cpu, mask, cpu_online_mask) {
>  		struct work_struct *work = per_cpu_ptr(works, cpu);
> 
>  		INIT_WORK(work, func);
>  		schedule_work_on(cpu, work);
>  	}
> 
> -	for_each_online_cpu(cpu)
> +	for_each_cpu_and(cpu, mask, cpu_online_mask)
>  		flush_work(per_cpu_ptr(works, cpu));
> 


Given that cpu hotplug is not a frequent operation, I think mask will be
a subset of cpu_online_mask most of the time (also, one example is from
schedule_on_each_cpu_cond() introduced in 3/6, which is already under
get/put_online_cpus(). So can we optimize something (the 'and' operations
perhaps) based on that?

May be something by using:
	if (likely(cpumask_subset(mask, cpu_online_mask))

>  	put_online_cpus();

>  	free_percpu(works);
> +
>  	return 0;
>  }
> 


Regards,
Srivatsa S. Bhat

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