From patchwork Mon Oct 20 17:03:43 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Travis X-Patchwork-Id: 5115 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id CF58D48170 for ; Tue, 21 Oct 2008 04:20:51 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from relay.sgi.com (relay2.sgi.com [192.48.171.30]) by ozlabs.org (Postfix) with ESMTP id 904E1DDF6A for ; Tue, 21 Oct 2008 04:03:29 +1100 (EST) Received: from polaris-admin.engr.sgi.com (polaris-admin.engr.sgi.com [192.102.97.111]) by relay2.corp.sgi.com (Postfix) with ESMTP id 5AD6E30411B; Mon, 20 Oct 2008 10:03:23 -0700 (PDT) Received: by polaris-admin.engr.sgi.com (Postfix, from userid 5508) id 0AF08517CAF9; Mon, 20 Oct 2008 10:03:23 -0700 (PDT) Message-Id: <20081020170322.922269000@polaris-admin.engr.sgi.com> References: <20081020170319.539427000@polaris-admin.engr.sgi.com> User-Agent: quilt/0.46-1 Date: Mon, 20 Oct 2008 10:03:43 -0700 From: Mike Travis To: Ingo Molnar , Rusty Russell Subject: [PATCH 24/35] cpumask: cpumask_any_but() Content-Disposition: inline; filename=cpumask:cpumask_any_but.patch Cc: davej@codemonkey.org.uk, Jeremy Fitzhardinge , Jes Sorensen , IA64 , S390 , peterz@infradead.org, Jack Steiner , linux-kernel@vger.kernel.org, Eric Dumazet , PowerPC , Andi Kleen , Thomas Gleixner , Yinghai Lu , "H. Peter Anvin" , SPARC , Andrew Morton , David Miller X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org There's a common case where we want any online cpu except a particular one. This creates a helper to do that, otherwise we need a temp var and cpumask_andnot(). From: Rusty Russell Signed-off-by: Rusty Russell Signed-off-by: Mike Travis --- include/linux/cpumask.h | 3 +++ lib/cpumask.c | 10 ++++++++++ 2 files changed, 13 insertions(+) --- test-compile.orig/include/linux/cpumask.h +++ test-compile/include/linux/cpumask.h @@ -111,6 +111,7 @@ * * int cpumask_any(mask) Any cpu in mask * int cpumask_any_and(mask1,mask2) Any cpu in both masks + * int cpumask_any_but(mask,cpu) Any cpu in mask except cpu * * for_each_possible_cpu(cpu) for-loop cpu over cpu_possible_map * for_each_online_cpu(cpu) for-loop cpu over cpu_online_map @@ -458,6 +459,7 @@ extern cpumask_t cpu_mask_all; #define cpumask_first(src) ({ (void)(src); 0; }) #define cpumask_next(n, src) ({ (void)(src); 1; }) #define cpumask_next_and(n, srcp, andp) ({ (void)(srcp), (void)(andp); 1; }) +#define cpumask_any_but(mask, cpu) ({ (void)(mask); (void)(cpu); 0; }) #define for_each_cpu(cpu, mask) \ for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask) @@ -469,6 +471,7 @@ extern cpumask_t cpu_mask_all; int cpumask_first(const cpumask_t *srcp); int cpumask_next(int n, const cpumask_t *srcp); int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp); +int cpumask_any_but(const struct cpumask *mask, unsigned int cpu); #define for_each_cpu(cpu, mask) \ for ((cpu) = -1; \ --- test-compile.orig/lib/cpumask.c +++ test-compile/lib/cpumask.c @@ -24,6 +24,16 @@ int cpumask_next_and(int n, const cpumas } EXPORT_SYMBOL(cpumask_next_and); +int cpumask_any_but(const struct cpumask *mask, unsigned int cpu) +{ + unsigned int i; + + for_each_cpu(i, mask) + if (i != cpu) + break; + return i; +} + /* These are not inline because of header tangles. */ #ifdef CONFIG_CPUMASK_OFFSTACK bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)