From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754191AbYJTRP0 (ORCPT ); Mon, 20 Oct 2008 13:15:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753395AbYJTRE2 (ORCPT ); Mon, 20 Oct 2008 13:04:28 -0400 Received: from relay2.sgi.com ([192.48.171.30]:59554 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753927AbYJTRD0 (ORCPT ); Mon, 20 Oct 2008 13:03:26 -0400 Message-Id: <20081020170322.646161000@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:41 -0700 From: Mike Travis To: Ingo Molnar , Rusty Russell Cc: Andi Kleen , Andrew Morton , davej@codemonkey.org.uk, David Miller , Eric Dumazet , Jack Steiner , Jeremy Fitzhardinge , Jes Sorensen , "H. Peter Anvin" , peterz@infradead.org, Thomas Gleixner , Yinghai Lu , IA64 , PowerPC , S390 , SPARC , linux-kernel@vger.kernel.org Subject: [PATCH 22/35] cpumask: cpumask_first/cpumask_next Content-Disposition: inline; filename=cpumask:cpumask_first-cpumask_next.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pointer-taking variants of first_cpu/next_cpu. From: Rusty Russell Signed-off-by: Rusty Russell Signed-off-by: Mike Travis --- include/linux/cpumask.h | 18 +++++++++--------- lib/cpumask.c | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) --- test-compile.orig/include/linux/cpumask.h +++ test-compile/include/linux/cpumask.h @@ -46,8 +46,8 @@ * void cpumask_shift_right(dst, src, n) Shift right * void cpumask_shift_left(dst, src, n) Shift left * - * int first_cpu(mask) Number lowest set bit or nr_cpumask_bits - * int next_cpu(cpu, mask) Next cpu past 'cpu', or nr_cpumask_bits + * int cpumask_first(mask) Number lowest set bit or nr_cpumask_bits + * int cpumask_next(cpu, mask) Next cpu past 'cpu', or nr_cpumask_bits * * void cpumask_copy(dmask, smask) dmask = smask * @@ -200,6 +200,8 @@ extern cpumask_t _unused_cpumask_arg_; #define for_each_cpu_mask(cpu, mask) for_each_cpu(cpu, &(mask)) #define for_each_cpu_mask_and(cpu, mask, and) \ for_each_cpu_and(cpu, &(mask), &(and)) +#define first_cpu(src) cpumask_first(&(src)) +#define next_cpu(n, src) cpumask_next((n), &(src)) /* End deprecated region. */ static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp) @@ -448,8 +450,8 @@ extern cpumask_t cpu_mask_all; #if NR_CPUS == 1 -#define first_cpu(src) ({ (void)(src); 0; }) -#define next_cpu(n, src) ({ (void)(src); 1; }) +#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 any_online_cpu(mask) 0 @@ -460,18 +462,16 @@ extern cpumask_t cpu_mask_all; #else /* NR_CPUS > 1 */ -int __first_cpu(const cpumask_t *srcp); -int __next_cpu(int n, const cpumask_t *srcp); +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 __any_online_cpu(const cpumask_t *mask); -#define first_cpu(src) __first_cpu(&(src)) -#define next_cpu(n, src) __next_cpu((n), &(src)) #define any_online_cpu(mask) __any_online_cpu(&(mask)) #define for_each_cpu(cpu, mask) \ for ((cpu) = -1; \ - (cpu) = __next_cpu((cpu), (mask)), \ + (cpu) = cpumask_next((cpu), (mask)), \ (cpu) < nr_cpumask_bits;) #define for_each_cpu_and(cpu, mask, and) \ for ((cpu) = -1; \ --- test-compile.orig/lib/cpumask.c +++ test-compile/lib/cpumask.c @@ -3,21 +3,21 @@ #include #include -int __first_cpu(const cpumask_t *srcp) +int cpumask_first(const cpumask_t *srcp) { return find_first_bit(cpumask_bits(srcp), nr_cpumask_bits); } -EXPORT_SYMBOL(__first_cpu); +EXPORT_SYMBOL(cpumask_first); -int __next_cpu(int n, const cpumask_t *srcp) +int cpumask_next(int n, const cpumask_t *srcp) { return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1); } -EXPORT_SYMBOL(__next_cpu); +EXPORT_SYMBOL(cpumask_next); int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp) { - while ((n = next_cpu(n, *srcp)) < nr_cpumask_bits) + while ((n = cpumask_next(n, srcp)) < nr_cpu_ids) if (cpumask_test_cpu(n, andp)) break; return n; --