Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751562AbbFXH7d (ORCPT ); Wed, 24 Jun 2015 03:59:33 -0400 Received: from www.linutronix.de ([62.245.132.108]:43488 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750800AbbFXH7Z (ORCPT ); Wed, 24 Jun 2015 03:59:25 -0400 Date: Wed, 24 Jun 2015 09:59:22 +0200 (CEST) From: Thomas Gleixner To: Vikas Shivappa cc: linux-kernel@vger.kernel.org, x86@kernel.org, hpa@zytor.com, mingo@kernel.org, tj@kernel.org, peterz@infradead.org, matt.fleming@intel.com, will.auld@intel.com, glenn.p.williamson@intel.com, kanaka.d.juvva@intel.com, priya.v.autee@intel.com Subject: Re: [PATCH 01/10] cpumask: Introduce cpumask_any_online_but In-Reply-To: <1435100183-21720-2-git-send-email-vikas.shivappa@linux.intel.com> Message-ID: References: <1435100183-21720-1-git-send-email-vikas.shivappa@linux.intel.com> <1435100183-21720-2-git-send-email-vikas.shivappa@linux.intel.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1591 Lines: 50 On Tue, 23 Jun 2015, 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 > --- > include/linux/cpumask.h | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h > index 27e285b..ea63b65 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) > +{ > + static cpumask_t tmp; How is that supposed to work? You cannot expect, that all potential users of this function are magically serialized. > + > + cpumask_and(&tmp, cpu_online_mask, mask); > + cpumask_clear_cpu(cpu, &tmp); > + return cpumask_any(&tmp); Thanks, tglx -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/