All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Ingo Molnar <mingo@elte.hu>
Cc: Mike Travis <travis@sgi.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [bug #2] Re: [PATCH 00/35] cpumask: Replace cpumask_t with struct cpumask
Date: Fri, 24 Oct 2008 09:29:46 +1100	[thread overview]
Message-ID: <200810240929.46985.rusty@rustcorp.com.au> (raw)
In-Reply-To: <20081023160959.GB8853@elte.hu>

On Friday 24 October 2008 03:09:59 Ingo Molnar wrote:
> * Mike Travis <travis@sgi.com> wrote:
> > Rusty Russell wrote:
> > > On Friday 24 October 2008 01:20:25 Ingo Molnar wrote:
> > >> Thomas has started a -tip cross-build test, and there's massive
> > >> cross-build failures as well due to the cpumask changes:
> > >
> > > Yes.  linux-next reported the same thing.  I've backed out various arch
> > > changes for this reason.
> > >
> > >> it seems to me that this commit is massively borked:
> > >>
> > >>   4a792c2: cpumask: make CONFIG_NR_CPUS always valid
> > >
> > > Yep.  This is the big one I dropped.  There are a few others; Mike is
> > > just porting the changes across to your tree now.
> > >
> > > Cheers,
> > > Rusty.
> >
> > Hi Ingo,
> >
> > It would seem easier to back out previous patches and apply the
> > replacements. Does this work for you?
>
> no, it does not work fine. As i said, i reworked various small bits
> along the way of reviewing and integrating them, under the obvious
> assumption that you submitted the latest and greatest. I spent hours
> testing every single step as well. If you cannot get your workflow right
> then we cannot have this stuff in v2.6.28.

Indeed, though to be honest it's been easier to do the fixes in linux-next.

Here's the interdiff; it's not too bad (you already reverted the
arch-destroying config changes).

Summary:
1) Alpha defines cpu_possible_map to cpu_present_map: this isn't possible
   under centralization, so just manipulate both together.
2) IA64, cris and m32r gratuitously re-declared cpu_possible_map; remove.
3) PowerPC Cell used __cpu_setall in a questionable way.
   Arnd approved this version.
4) That also leads to weakening the BUG_ON() to WARN_ON_ONCE() for
   CONFIG_DEBUG_PER_CPU_MAPS; Arnd wants to be reminded, but only once :)
5) Revert most of S390 smp_call_function_mask->smp_call_function_many: it's
   safer to just do the minimal conversion.
6) Remove __deprecated from smp_call_function_mask: we're not pushing
   replacement patches yet so it's not appropriate, and it breaks sparc64
   which compiles arch/sparc with -Werror.
7) Hack header to set CONFIG_NR_CPUS for UP on archs; safer than touching
   Kconfigs for them.  Also update comment.

Thanks,
Rusty.

diff --git a/arch/alpha/include/asm/smp.h b/arch/alpha/include/asm/smp.h
index 544c69a..547e909 100644
--- a/arch/alpha/include/asm/smp.h
+++ b/arch/alpha/include/asm/smp.h
@@ -45,7 +45,6 @@ extern struct cpuinfo_alpha cpu_data[NR_CPUS];
 #define raw_smp_processor_id()	(current_thread_info()->cpu)
 
 extern int smp_num_cpus;
-#define cpu_possible_map	cpu_present_map
 
 extern void arch_send_call_function_single_ipi(int cpu);
 extern void arch_send_call_function_ipi(cpumask_t mask);
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index 351407e..f238370 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -94,6 +94,7 @@ common_shutdown_1(void *generic_ptr)
 		flags |= 0x00040000UL; /* "remain halted" */
 		*pflags = flags;
 		cpu_clear(cpuid, cpu_present_map);
+		cpu_clear(cpuid, cpu_possible_map);
 		halt();
 	}
 #endif
@@ -120,6 +121,7 @@ common_shutdown_1(void *generic_ptr)
 #ifdef CONFIG_SMP
 	/* Wait for the secondaries to halt. */
 	cpu_clear(boot_cpuid, cpu_present_map);
+	cpu_clear(boot_cpuid, cpu_possible_map);
 	while (cpus_weight(cpu_present_map))
 		barrier();
 #endif
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index ac26335..ce6791a 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -435,6 +435,7 @@ setup_smp(void)
 				((char *)cpubase + i*hwrpb->processor_size);
 			if ((cpu->flags & 0x1cc) == 0x1cc) {
 				smp_num_probed++;
+				cpu_set(i, cpu_possible_map);
 				cpu_set(i, cpu_present_map);
 				cpu->pal_revision = boot_cpu_palrev;
 			}
@@ -468,6 +469,7 @@ smp_prepare_cpus(unsigned int max_cpus)
 
 	/* Nothing to do on a UP box, or when told not to.  */
 	if (smp_num_probed == 1 || max_cpus == 0) {
+		cpu_possible_map = cpumask_of_cpu(boot_cpuid);
 		cpu_present_map = cpumask_of_cpu(boot_cpuid);
 		printk(KERN_INFO "SMP mode deactivated.\n");
 		return;
diff --git a/arch/ia64/include/asm/smp.h b/arch/ia64/include/asm/smp.h
index 12d96e0..21c4023 100644
--- a/arch/ia64/include/asm/smp.h
+++ b/arch/ia64/include/asm/smp.h
@@ -57,7 +57,6 @@ extern struct smp_boot_data {
 
 extern char no_int_routing __devinitdata;
 
-extern cpumask_t cpu_online_map;
 extern cpumask_t cpu_core_map[NR_CPUS];
 DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
 extern int smp_num_siblings;
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index a5bdb89..402c183 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -111,10 +111,11 @@ void spu_flush_all_slbs(struct mm_struct *mm)
  */
 static inline void mm_needs_global_tlbie(struct mm_struct *mm)
 {
-	int nr = (NR_CPUS > 1) ? NR_CPUS : NR_CPUS + 1;
+	cpumask_setall(&mm->cpu_vm_mask);
 
 	/* Global TLBIE broadcast required with SPEs. */
-	__cpus_setall(&mm->cpu_vm_mask, nr);
+	if (nr_cpu_ids == 1)
+		cpumask_set_cpu(1, &mm->cpu_vm_mask);
 }
 
 void spu_associate_mm(struct spu *spu, struct mm_struct *mm)
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 10e7f97..29a3eb1 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -103,7 +103,7 @@ static void do_call_function(void)
 }
 
 static void __smp_call_function_map(void (*func) (void *info), void *info,
-				    int wait, struct cpumask *map)
+				    int wait, cpumask_t map)
 {
 	struct call_data_struct data;
 	int cpu, local = 0;
@@ -163,16 +163,14 @@ out:
  * You must not call this function with disabled interrupts, from a
  * hardware interrupt handler or from a bottom half.
  */
-
-/* protected by call_lock */
-static DEFINE_BITMAP(smp_call_map, CONFIG_NR_CPUS);
-
 int smp_call_function(void (*func) (void *info), void *info, int wait)
 {
+	cpumask_t map;
+
 	spin_lock(&call_lock);
-	cpumask_copy(to_cpumask(smp_call_map), cpu_online_mask);
-	cpumask_clear_cpu(smp_processor_id(), to_cpumask(smp_call_map));
-	__smp_call_function_map(func, info, wait, to_cpumask(smp_call_map));
+	map = cpu_online_map;
+	cpu_clear(smp_processor_id(), map);
+	__smp_call_function_map(func, info, wait, map);
 	spin_unlock(&call_lock);
 	return 0;
 }
@@ -194,8 +192,7 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
 			     int wait)
 {
 	spin_lock(&call_lock);
-	cpumask_copy(to_cpumask(smp_call_map), cpumask_of(cpu));
-	__smp_call_function_map(func, info, wait, cpumask_of(cpu));
+	__smp_call_function_map(func, info, wait, cpumask_of_cpu(cpu));
 	spin_unlock(&call_lock);
 	return 0;
 }
@@ -216,13 +213,13 @@ EXPORT_SYMBOL(smp_call_function_single);
  * You must not call this function with disabled interrupts or from a
  * hardware interrupt handler or from a bottom half handler.
  */
-int smp_call_function_many(const struct cpumask *mask,
+int smp_call_function_many(const struct cpumask *maskp,
 			   void (*func)(void *), void *info, bool wait)
 {
+	cpumask_t mask = *maskp;
 	spin_lock(&call_lock);
-	cpumask_copy(to_cpumask(smp_call_map), cpu_online_mask);
-	cpumask_clear_cpu(smp_processor_id(), to_cpumask(smp_call_map));
-	__smp_call_function_map(func, info, wait, to_cpumask(smp_call_map));
+	cpu_clear(smp_processor_id(), mask);
+	__smp_call_function_map(func, info, wait, mask);
 	spin_unlock(&call_lock);
 	return 0;
 }
diff --git a/include/asm-cris/smp.h b/include/asm-cris/smp.h
index dba33ab..c615a06 100644
--- a/include/asm-cris/smp.h
+++ b/include/asm-cris/smp.h
@@ -4,7 +4,6 @@
 #include <linux/cpumask.h>
 
 extern cpumask_t phys_cpu_present_map;
-extern cpumask_t cpu_possible_map;
 
 #define raw_smp_processor_id() (current_thread_info()->cpu)
 
diff --git a/include/asm-m32r/smp.h b/include/asm-m32r/smp.h
index c5dd669..b96a6d2 100644
--- a/include/asm-m32r/smp.h
+++ b/include/asm-m32r/smp.h
@@ -63,8 +63,6 @@ extern volatile int cpu_2_physid[NR_CPUS];
 #define raw_smp_processor_id()	(current_thread_info()->cpu)
 
 extern cpumask_t cpu_callout_map;
-extern cpumask_t cpu_possible_map;
-extern cpumask_t cpu_present_map;
 
 static __inline__ int hard_smp_processor_id(void)
 {
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index d1f22ee..295d9e8 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -254,8 +254,7 @@ extern cpumask_t _unused_cpumask_arg_;
 static inline unsigned int cpumask_check(unsigned int cpu)
 {
 #ifdef CONFIG_DEBUG_PER_CPU_MAPS
-	/* This breaks at runtime. */
-	BUG_ON(cpu >= nr_cpumask_bits);
+	WARN_ON_ONCE(cpu >= nr_cpumask_bits);
 #endif /* CONFIG_DEBUG_PER_CPU_MAPS */
 	return cpu;
 }
diff --git a/include/linux/smp.h b/include/linux/smp.h
index c7bc2fa..748ebc9 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -71,7 +71,7 @@ int smp_call_function_single(int cpuid, void (*func) (void *info), void *info,
 void __smp_call_function_single(int cpuid, struct call_single_data *data);
 
 /* Use smp_call_function_many, which takes a pointer to the mask. */
-static inline int __deprecated
+static inline int
 smp_call_function_mask(cpumask_t mask, void(*func)(void *info), void *info,
 		       int wait)
 {
diff --git a/include/linux/threads.h b/include/linux/threads.h
index 38d1a5d..08a0286 100644
--- a/include/linux/threads.h
+++ b/include/linux/threads.h
@@ -8,17 +8,18 @@
  */
 
 /*
- * Maximum supported processors that can run under SMP.  This value is
- * set via configure setting.  The maximum is equal to the size of the
- * bitmasks used on that platform, i.e. 32 or 64.  Setting this smaller
- * saves quite a bit of memory.
+ * Maximum supported processors that can run under SMP.  Setting this smaller
+ * saves quite a bit of memory.  Use nr_cpu_ids instead of this except for
+ * static bitmaps.
  */
-#ifdef CONFIG_SMP
-#define NR_CPUS		CONFIG_NR_CPUS
-#else
-#define NR_CPUS		1
+#ifndef CONFIG_NR_CPUS
+/* FIXME: This should be fixed in the arch's Kconfig */
+#define CONFIG_NR_CPUS	1
 #endif
 
+/* Places which use this should consider cpumask_var_t. */
+#define NR_CPUS		CONFIG_NR_CPUS
+
 #define MIN_THREADS_LEFT_FOR_ROOT 4
 
 /*

  reply	other threads:[~2008-10-23 22:30 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-23  2:08 [PATCH 00/35] cpumask: Replace cpumask_t with struct cpumask Mike Travis
2008-10-23  2:08 ` [PATCH 01/35] cpumask: add for_each_cpu_mask_and function Mike Travis
2008-10-23  2:08 ` [PATCH 02/35] x86 smp: modify send_IPI_mask interface to accept cpumask_t pointers Mike Travis
2008-10-23  2:08 ` [PATCH 03/35] sched: Reduce stack size requirements in kernel/sched.c Mike Travis
2008-10-23  2:08 ` [PATCH 04/35] cpumask: centralize cpu_online_map and cpu_possible_map Mike Travis
2008-10-23  2:14   ` [PATCH 04/35] cpumask: centralize cpu_online_map and cpu_possible_map - resubmit Mike Travis
2008-10-23  2:08 ` [PATCH 05/35] cpumask: remove min from first_cpu/next_cpu From: Rusty Russell <rusty@rustcorp.com.au> Mike Travis
2008-10-23  2:08 ` [PATCH 06/35] cpumask: introduce struct cpumask. " Mike Travis
2008-10-23  2:08 ` [PATCH 07/35] cpumask: change cpumask/list_scnprintf, cpumask/list_parse to take pointers. " Mike Travis
2008-10-23  2:08 ` [PATCH 08/35] cpumask: cpumask_size() From: Mike Travis <travis@sgi.com> Mike Travis
2008-10-23  2:08 ` [PATCH 09/35] cpumask: add cpumask_copy() Mike Travis
2008-10-23  2:08 ` [PATCH 10/35] cpumask: introduce cpumask_var_t for local cpumask vars From: Rusty Russell <rusty@rustcorp.com.au> Mike Travis
2008-10-23  2:08 ` [PATCH 11/35] x86: enable MAXSMP Mike Travis
2008-10-23  2:08 ` [PATCH 12/35] cpumask: make CONFIG_NR_CPUS always valid. From: Rusty Russell <rusty@rustcorp.com.au> Mike Travis
2008-10-23  2:08 ` [PATCH 13/35] cpumask: make nr_cpu_ids valid in all configurations. " Mike Travis
2008-10-23  2:08 ` [PATCH 14/35] cpumask: add nr_cpumask_bits Mike Travis
2008-10-23  2:08 ` [PATCH 15/35] cpumask: prepare for iterators to only go to nr_cpu_ids/nr_cpumask_bits. From: Rusty Russell <rusty@rustcorp.com.au> Mike Travis
2008-10-23  2:08 ` [PATCH 16/35] percpu: fix percpu accessors to potentially !cpu_possible() cpus " Mike Travis
2008-10-23  2:08 ` [PATCH 17/35] cpumask: make nr_cpu_ids the actual limit on bitmap size Mike Travis
2008-10-23  2:08 ` [PATCH 18/35] cpumask: use cpumask_bits() everywhere Mike Travis
2008-10-23  2:16   ` [PATCH 18/35] cpumask: use cpumask_bits() everywhere.-resubmit Mike Travis
2008-10-23  2:08 ` [PATCH 19/35] cpumask: cpumask_of(): cpumask_of_cpu() which returns a pointer. From: Rusty Russell <rusty@rustcorp.com.au> Mike Travis
2008-10-23  2:08 ` [PATCH 20/35] cpumask: for_each_cpu(): for_each_cpu_mask which takes a pointer " Mike Travis
2008-10-23  2:08 ` [PATCH 21/35] cpumask: cpumask_first/cpumask_next " Mike Travis
2008-10-23  2:08 ` [PATCH 22/35] cpumask: deprecate any_online_cpu() in favour of cpumask_any/cpumask_any_and " Mike Travis
2008-10-23 10:25   ` Ingo Molnar
2008-10-23 10:43     ` Ingo Molnar
2008-10-23 12:57     ` Mike Travis
2008-10-23  2:08 ` [PATCH 23/35] cpumask: cpumask_any_but() " Mike Travis
2008-10-23 11:00   ` Ingo Molnar
2008-10-23  2:08 ` [PATCH 24/35] cpumask: Deprecate CPUMASK_ALLOC etc in favor of cpumask_var_t. " Mike Travis
2008-10-23  2:08 ` [PATCH 25/35] cpumask: get rid of boutique sched.c allocations, use " Mike Travis
2008-10-23  2:08 ` [PATCH 26/35] cpumask: to_cpumask() " Mike Travis
2008-10-23  2:08 ` [PATCH 27/35] cpumask: accessors to manipulate possible/present/online/active maps " Mike Travis
2008-10-23 11:05   ` Ingo Molnar
2008-10-23 13:52     ` Mike Travis
2008-10-23  2:08 ` [PATCH 28/35] cpumask: CONFIG_BITS_ALL, CONFIG_BITS_NONE and CONFIG_BITS_CPU0 " Mike Travis
2008-10-23  2:08 ` [PATCH 29/35] cpumask: switch over to cpu_online/possible/active/present_mask " Mike Travis
2008-10-30 17:36   ` Tony Luck
2008-10-23  2:08 ` [PATCH 30/35] cpumask: cpu_all_mask and cpu_none_mask. " Mike Travis
2008-10-23  2:08 ` [PATCH 31/35] cpumask: reorder header to minimize separate #ifdefs " Mike Travis
2008-10-23  2:08 ` [PATCH 32/35] cpumask: debug options for cpumasks " Mike Travis
2008-10-23  2:08 ` [PATCH 33/35] cpumask: smp_call_function_many() " Mike Travis
2008-10-23  2:09 ` [PATCH 34/35] cpumask: Use accessors code. " Mike Travis
2008-10-23  5:34   ` Rusty Russell
2008-10-23  2:09 ` [PATCH 35/35] x86: clean up speedctep-centrino and reduce cpumask_t usage " Mike Travis
2008-10-23  5:36   ` Rusty Russell
2008-10-23 12:04     ` Ingo Molnar
2008-10-23 15:06       ` Rusty Russell
2008-10-23 15:10       ` Dave Jones
2008-10-27 16:23         ` Ingo Molnar
2008-10-23 12:03 ` [PATCH 00/35] cpumask: Replace cpumask_t with struct cpumask Ingo Molnar
2008-10-23 12:54   ` Mike Travis
2008-10-23 13:01     ` Ingo Molnar
2008-10-23 13:38       ` Mike Travis
2008-10-23 12:55   ` [bug] " Ingo Molnar
2008-10-23 12:57     ` Ingo Molnar
2008-10-23 13:00     ` Mike Travis
2008-10-23 14:20     ` [bug #2] " Ingo Molnar
2008-10-23 14:21       ` Ingo Molnar
2008-10-23 15:01       ` Rusty Russell
2008-10-23 15:20         ` Mike Travis
2008-10-23 16:09           ` Ingo Molnar
2008-10-23 22:29             ` Rusty Russell [this message]
2008-10-23 16:06         ` Ingo Molnar
2008-10-23 16:18           ` Mike Travis
2008-10-23 16:35             ` Ingo Molnar
2008-10-23 16:50               ` Mike Travis
2008-10-23 16:52                 ` Ingo Molnar
2008-10-23 17:06                   ` Mike Travis
2008-10-23 20:20           ` [PATCH 1/1]: cpumask: fix compiler errors/warnings Mike Travis
2008-10-23 14:22     ` [bug] Re: [PATCH 00/35] cpumask: Replace cpumask_t with struct cpumask Mike Travis
2008-10-23 14:24       ` Ingo Molnar
2008-10-23 14:28       ` Ingo Molnar
2008-10-23 14:32         ` Ingo Molnar
2008-10-23 23:01     ` Rusty Russell
2008-10-23 22:53   ` Rusty Russell
2008-10-27 16:20     ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200810240929.46985.rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=travis@sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.