Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752210AbbFOQvq (ORCPT ); Mon, 15 Jun 2015 12:51:46 -0400 Received: from mga02.intel.com ([134.134.136.20]:34143 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755722AbbFOQvj (ORCPT ); Mon, 15 Jun 2015 12:51:39 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,620,1427785200"; d="scan'208";a="588202630" Date: Mon, 15 Jun 2015 09:48:40 -0700 (PDT) From: Vikas Shivappa X-X-Sender: vikas@vshiva-Udesk To: Peter Zijlstra cc: Vikas Shivappa , linux-kernel@vger.kernel.org, vikas.shivappa@intel.com, x86@kernel.org, hpa@zytor.com, tglx@linutronix.de, mingo@kernel.org, matt.fleming@intel.com, will.auld@intel.com, linux-rdt@eclists.intel.com Subject: Re: [PATCH 01/10] cpumask: Introduce cpumask_any_online_but In-Reply-To: <20150615123614.GA3644@twins.programming.kicks-ass.net> Message-ID: References: <1434133037-25189-1-git-send-email-vikas.shivappa@linux.intel.com> <1434133037-25189-2-git-send-email-vikas.shivappa@linux.intel.com> <20150615123614.GA3644@twins.programming.kicks-ass.net> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1954 Lines: 64 On Mon, 15 Jun 2015, Peter Zijlstra wrote: > 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 >> --- >> 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. ok , Will fix. > >> + >> + 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. I saw the cpumask_any_but but wanted to avoid the for loop in the cpumask_any_but , but now i see why from your previous comment. Without the cpumask_t I will have to use the cpumask_any_but .. the two were related. Thanks, Vikas > -- 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/