From patchwork Mon Oct 20 17:03:33 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Travis X-Patchwork-Id: 5105 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 6063C49038 for ; Tue, 21 Oct 2008 04:12:56 +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 015F2DDF17 for ; Tue, 21 Oct 2008 04:03:26 +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 98E9230410D; Mon, 20 Oct 2008 10:03:22 -0700 (PDT) Received: by polaris-admin.engr.sgi.com (Postfix, from userid 5508) id A0AEE517CB02; Mon, 20 Oct 2008 10:03:21 -0700 (PDT) Message-Id: <20081020170321.535939000@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:33 -0700 From: Mike Travis To: Ingo Molnar , Rusty Russell Subject: [PATCH 14/35] cpumask: make nr_cpu_ids valid in all configurations. Content-Disposition: inline; filename=cpumask:always-have-nr_cpu_ids.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 nr_cpu_ids is the (badly named) runtime limit on possible CPU numbers; ie. the variable version of NR_CPUS. This makes is valid in all configs, including UP. From: Rusty Russell Signed-off-by: Rusty Russell Signed-off-by: Mike Travis --- include/linux/cpumask.h | 10 ++++++++-- init/main.c | 7 +++++++ 2 files changed, 15 insertions(+), 2 deletions(-) --- test-compile.orig/include/linux/cpumask.h +++ test-compile/include/linux/cpumask.h @@ -195,6 +195,14 @@ extern cpumask_t _unused_cpumask_arg_; #define cpus_addr(src) ((src).bits) /* End deprecated region. */ +#if NR_CPUS <= BITS_PER_LONG +/* Constant is usually more efficient than a variable for small NR_CPUS */ +#define nr_cpu_ids NR_CPUS +#else +/* Starts at NR_CPUS until we know better. */ +extern int nr_cpu_ids; +#endif /* NR_CPUS > BITS_PER_LONG */ + static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp) { set_bit(cpu, dstp->bits); @@ -434,7 +442,6 @@ extern cpumask_t cpu_mask_all; #if NR_CPUS == 1 -#define nr_cpu_ids 1 #define first_cpu(src) ({ (void)(src); 0; }) #define next_cpu(n, src) ({ (void)(src); 1; }) #define cpumask_next_and(n, srcp, andp) ({ (void)(srcp), (void)(andp); 1; }) @@ -447,7 +454,6 @@ extern cpumask_t cpu_mask_all; #else /* NR_CPUS > 1 */ -extern int nr_cpu_ids; int __first_cpu(const cpumask_t *srcp); int __next_cpu(int n, const cpumask_t *srcp); int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp); --- test-compile.orig/init/main.c +++ test-compile/init/main.c @@ -373,6 +373,8 @@ EXPORT_SYMBOL(cpu_mask_all); #endif /* Setup number of possible processor ids */ +/* nr_cpu_ids is a real variable for large NR_CPUS. */ +#ifndef nr_cpu_ids int nr_cpu_ids __read_mostly = NR_CPUS; EXPORT_SYMBOL(nr_cpu_ids); @@ -386,6 +388,11 @@ void __init setup_nr_cpu_ids(void) nr_cpu_ids = highest_cpu + 1; } +#else +void __init setup_nr_cpu_ids(void) +{ +} +#endif /* ... nr_cpu_ids is a constant. */ #ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;