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: <20150615123614.GA3644@twins.programming.kicks-ass.net>
Date:	Mon, 15 Jun 2015 14:36:14 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Vikas Shivappa <vikas.shivappa@...ux.intel.com>
Cc:	linux-kernel@...r.kernel.org, vikas.shivappa@...el.com,
	x86@...nel.org, hpa@...or.com, tglx@...utronix.de,
	mingo@...nel.org, matt.fleming@...el.com, will.auld@...el.com,
	linux-rdt@...ists.intel.com
Subject: Re: [PATCH 01/10] cpumask: Introduce cpumask_any_online_but

On Fri, Jun 12, 2015 at 11:17:08AM -0700, Vikas Shivappa wrote:
> There is currently no cpumask helper function to pick a "random" cpu
> from a mask which is also online.
> 
> cpumask_any_online_but() does that which is similar to cpumask_any_but()
> but also returns a cpu that is online.
> 
> Signed-off-by: Vikas Shivappa <vikas.shivappa@...ux.intel.com>
> ---
>  include/linux/cpumask.h | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
> index 27e285b..f2d7e8a 100644
> --- a/include/linux/cpumask.h
> +++ b/include/linux/cpumask.h
> @@ -548,6 +548,24 @@ static inline void cpumask_copy(struct cpumask *dstp,
>  #define cpumask_of(cpu) (get_cpu_mask(cpu))
>  
>  /**
> + * cpumask_any_online_but - return a "random"  and online cpu in a cpumask,
> + * but not this one
> + * @mask: the input mask to search
> + * @cpu: the cpu to ignore
> + *
> + * Returns >= nr_cpu_ids if no cpus set.
> +*/
> +static inline unsigned int cpumask_any_online_but(const struct cpumask *mask,
> +					   unsigned int cpu)
> +{
> +	cpumask_t tmp;

No, you cannot put a cpumask_t on stack like that. Those things can be
massive.

> +
> +	cpumask_and(&tmp, cpu_online_mask, mask);
> +	cpumask_clear_cpu(cpu, &tmp);
> +	return cpumask_any(&tmp);
> +}

You had a good example in cpumask_any_but() copy that.
--
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