Skip to contentSkip to conversation

take3: Updated CPU Hotplug patches for IA64 [just the last patch 7/7]cpu_present_map.patch

PATCH Ashok Raj 1 participant 2 messages Apr 29, 2004 – May 4, 2004

Subsystems (3)
lore
Share & tools
lore

Ashok Raj

author
#0 lore raw

Hi Andrew

please replace the last patch cpu_present_map with this attached patch. In the earlier version, i didnt validate with sgi config that had caused some compile problems with sn2_defconfig that Paul Jackson reported. Iam working with him to clean up the patch to fit his new cpumask related changes.

we will need to find a new home for the following section that is in asm-ia64/cpumask.h

#ifdef CONFIG_HOTPLUG_CPU
#define ARCH_HAS_CPU_PRESENT_MAP
#endif

Paul is cleaning up this cpumask and explained that it will disapper in his new patch. I will work with him closely to find a new place, or an equivalent when his patches get released.

thanks to David Mosberger and Paul to help cleanup my patches.

Cheers,
Ashok

Name: cpu_present_map.patch
Author: Ashok Raj (Intel Corporation)
D: This patch adds cpu_present_map, cpu_present() and for_each_cpu_present()
D: to distinguish between possible cpu's in a system and cpu's physically
D: present in a system. Before cpu hotplug was introduced cpu_possible()
D: represented cpu's physically present in the system. With hotplug capable
D: Kernel, there is a requirement to distinguish a cpu as possible verses a
D: CPU physically present in the system. This is required so thta when
D: smp_init() attempts to start all cpu's it should now only attempt
D: to start cpu's present in the system. When a hotplug cpu is
D: physically inserted cpu_present_map will have bits updated
D: dynamically.

---

 arch/ia64/kernel/smp.c                           |    0 
 linux-2.6.5-lhcs-root/arch/ia64/kernel/smpboot.c |   21 +++++++++++++++++++--
 linux-2.6.5-lhcs-root/fs/proc/proc_misc.c        |    4 ++--
 linux-2.6.5-lhcs-root/include/asm-ia64/cpumask.h |    3 +++
 linux-2.6.5-lhcs-root/include/asm-ia64/smp.h     |    5 +++++
 linux-2.6.5-lhcs-root/include/linux/cpumask.h    |   17 +++++++++++++++++
 linux-2.6.5-lhcs-root/init/main.c                |    4 ++--
 linux-2.6.5-lhcs-root/kernel/cpu.c               |    2 +-
 8 files changed, 49 insertions(+), 7 deletions(-)
include/asm-ia64/smp.h renamed from include/asm-ia64/smp.h~cpu_present +5 -0
diff -puN include/asm-ia64/smp.h~cpu_present include/asm-ia64/smp.h
@@ -48,7 +48,12 @@ extern volatile int ia64_cpu_to_sapicid[
 
 extern unsigned long ap_wakeup_vector;
 
+#ifdef CONFIG_HOTPLUG_CPU
+extern cpumask_t cpu_possible_map;
+#define cpu_present_map phys_cpu_present_map
+#else
 #define cpu_possible_map phys_cpu_present_map
+#endif
 
 /*
  * Function to map hard smp processor id to logical id.  Slow, so don't use this in
arch/ia64/kernel/smpboot.c renamed from arch/ia64/kernel/smpboot.c~cpu_present +19 -2
diff -puN arch/ia64/kernel/smpboot.c~cpu_present arch/ia64/kernel/smpboot.c
@@ -87,9 +87,15 @@ DEFINE_PER_CPU(int, cpu_state);
 /* Bitmask of currently online CPUs */
 cpumask_t cpu_online_map;
 EXPORT_SYMBOL(cpu_online_map);
+
 cpumask_t phys_cpu_present_map;
 EXPORT_SYMBOL(phys_cpu_present_map);
 
+#ifdef CONFIG_HOTPLUG_CPU
+cpumask_t cpu_possible_map;
+EXPORT_SYMBOL(cpu_possible_map);
+#endif
+
 /* which logical CPU number maps to which CPU (physical APIC ID) */
 volatile int ia64_cpu_to_sapicid[NR_CPUS];
 EXPORT_SYMBOL(ia64_cpu_to_sapicid);
@@ -108,6 +114,7 @@ static int __init
 nointroute (char *str)
 {
 	no_int_routing = 1;
+	printk ("no_int_routing on\n");
 	return 1;
 }
 
@@ -472,13 +479,23 @@ smp_build_cpu_map (void)
 	int sapicid, cpu, i;
 	int boot_cpu_id = hard_smp_processor_id();
 
-	for (cpu = 0; cpu < NR_CPUS; cpu++)
+	/*
+	 * Since ACPI does not give us whats MAX cpu's
+	 * possible in the entire platform, we will just have to use
+	 * NR_CPUS set for possible map. cpu_present_map a.k.a
+	 * phys_cpu_present_map can grow based on a new cpu
+	 * becomming available to the system.
+	 */
+	cpus_clear(cpu_possible_map);
+	for (cpu=0; cpu < NR_CPUS; cpu++) {
 		ia64_cpu_to_sapicid[cpu] = -1;
+		cpu_set(cpu, cpu_possible_map);
+	}
 
 	ia64_cpu_to_sapicid[0] = boot_cpu_id;
+
 	cpus_clear(phys_cpu_present_map);
 	cpu_set(0, phys_cpu_present_map);
-
 	for (cpu = 1, i = 0; i < smp_boot_data.cpu_count; i++) {
 		sapicid = smp_boot_data.cpu_phys_id[i];
 		if (sapicid = boot_cpu_id)
include/linux/cpumask.h renamed from include/linux/cpumask.h~cpu_present +17 -0
diff -puN include/linux/cpumask.h~cpu_present include/linux/cpumask.h
@@ -16,6 +16,16 @@ extern cpumask_t cpu_possible_map;
 #define cpu_online(cpu)			cpu_isset(cpu, cpu_online_map)
 #define cpu_possible(cpu)		cpu_isset(cpu, cpu_possible_map)
 
+#ifdef ARCH_HAS_CPU_PRESENT_MAP
+extern cpumask_t cpu_present_map;
+#define cpu_present(cpu)		cpu_isset(cpu, cpu_present_map)
+#define num_present_cpus()		cpus_weight(cpu_present_map)
+#else
+#define cpu_present_map			cpu_possible_map
+#define cpu_present(x)			cpu_possible(x)
+#define num_present_cpus()		num_possible_cpus()
+#endif
+
 #define for_each_cpu_mask(cpu, mask)					\
 	for (cpu = first_cpu_const(mk_cpumask_const(mask));		\
 		cpu < NR_CPUS;						\
@@ -23,16 +33,23 @@ extern cpumask_t cpu_possible_map;
 
 #define for_each_cpu(cpu) for_each_cpu_mask(cpu, cpu_possible_map)
 #define for_each_online_cpu(cpu) for_each_cpu_mask(cpu, cpu_online_map)
+#define for_each_present_cpu(cpu) for_each_cpu_mask(cpu, cpu_present_map)
 #else
 #define	cpu_online_map			cpumask_of_cpu(0)
 #define	cpu_possible_map		cpumask_of_cpu(0)
+#define cpu_present_map			cpumask_of_cpu(0)
+
 #define num_online_cpus()		1
 #define num_possible_cpus()		1
+#define num_present_cpus()		1
+
 #define cpu_online(cpu)			({ BUG_ON((cpu) != 0); 1; })
 #define cpu_possible(cpu)		({ BUG_ON((cpu) != 0); 1; })
+#define cpu_present(cpu)		({ BUG_ON((cpu) != 0); 1; })
 
 #define for_each_cpu(cpu) for (cpu = 0; cpu < 1; cpu++)
 #define for_each_online_cpu(cpu) for (cpu = 0; cpu < 1; cpu++)
+#define for_each_present_cpu(cpu) for (cpu = 0; cpu < 1; cpu++)
 #endif
 
 #define cpumask_scnprintf(buf, buflen, map)				\
init/main.c renamed from init/main.c~cpu_present +2 -2
diff -puN init/main.c~cpu_present init/main.c
@@ -357,10 +357,10 @@ static void __init smp_init(void)
 	unsigned j = 1;
 
 	/* FIXME: This should be done in userspace --RR */
-	for (i = 0; i < NR_CPUS; i++) {
+	for_each_present_cpu(i) {
 		if (num_online_cpus() >= max_cpus)
 			break;
-		if (cpu_possible(i) && !cpu_online(i)) {
+		if (!cpu_online(i)) {
 			cpu_up(i);
 			j++;
 		}
kernel/cpu.c renamed from kernel/cpu.c~cpu_present +1 -1
diff -puN kernel/cpu.c~cpu_present kernel/cpu.c
@@ -169,7 +169,7 @@ int __devinit cpu_up(unsigned int cpu)
 	if ((ret = down_interruptible(&cpucontrol)) != 0)
 		return ret;
 
-	if (cpu_online(cpu)) {
+	if (cpu_online(cpu) || !cpu_present(cpu)) {
 		ret = -EINVAL;
 		goto out;
 	}

diff -puN arch/ia64/kernel/smp.c~cpu_present arch/ia64/kernel/smp.c

fs/proc/proc_misc.c renamed from fs/proc/proc_misc.c~cpu_present +2 -2
diff -puN fs/proc/proc_misc.c~cpu_present fs/proc/proc_misc.c
@@ -368,7 +368,7 @@ int show_stat(struct seq_file *p, void *
 	if (wall_to_monotonic.tv_nsec)
 		--jif;
 
-	for_each_cpu(i) {
+	for_each_online_cpu(i) {
 		int j;
 
 		user += kstat_cpu(i).cpustat.user;
@@ -390,7 +390,7 @@ int show_stat(struct seq_file *p, void *
 		(unsigned long long)jiffies_64_to_clock_t(iowait),
 		(unsigned long long)jiffies_64_to_clock_t(irq),
 		(unsigned long long)jiffies_64_to_clock_t(softirq));
-	for_each_cpu(i) {
+	for_each_online_cpu(i) {
 
 		/* Copy values here to work around gcc-2.95.3, gcc-2.96 */
 		user = kstat_cpu(i).cpustat.user;
include/asm-ia64/cpumask.h renamed from include/asm-ia64/cpumask.h~cpu_present +3 -0
diff -puN include/asm-ia64/cpumask.h~cpu_present include/asm-ia64/cpumask.h
@@ -1,6 +1,9 @@
 #ifndef _ASM_IA64_CPUMASK_H
 #define _ASM_IA64_CPUMASK_H
 
+#ifdef CONFIG_HOTPLUG_CPU
+#define ARCH_HAS_CPU_PRESENT_MAP
+#endif
 #include <asm-generic/cpumask.h>
 
 #endif /* _ASM_IA64_CPUMASK_H */

_

author
#1 lore raw

take3: Updated CPU Hotplug patches for IA64 (pj blessed) Patch [2/7]

Sorry.. i missed copying on this one...

Name: ia64_init_removal.patch
Author: Ashok Raj (Intel Corporation)
Status: Experimental

D: Contains changes from __init to __devinit to support cpu hotplug
D: Changes only arch/ia64 portions of the kernel tree.

---

 linux-2.6.5-lhcs-root/arch/ia64/kernel/setup.c   |    2 +-
 linux-2.6.5-lhcs-root/arch/ia64/kernel/smpboot.c |   12 ++++++------
 linux-2.6.5-lhcs-root/arch/ia64/kernel/time.c    |    2 +-
 linux-2.6.5-lhcs-root/arch/ia64/mm/init.c        |    4 ++--
 linux-2.6.5-lhcs-root/arch/ia64/mm/tlb.c         |    2 +-
 linux-2.6.5-lhcs-root/include/asm-ia64/smp.h     |    3 ++-
 6 files changed, 13 insertions(+), 12 deletions(-)
arch/ia64/kernel/setup.c renamed from arch/ia64/kernel/setup.c~init_removal_ia64 +1 -1
diff -puN arch/ia64/kernel/setup.c~init_removal_ia64 arch/ia64/kernel/setup.c
@@ -575,7 +575,7 @@ get_max_cacheline_size (void)
 void
 cpu_init (void)
 {
-	extern void __init ia64_mmu_init (void *);
+	extern void __devinit ia64_mmu_init (void *);
 	unsigned long num_phys_stacked;
 	pal_vm_info_2_u_t vmi;
 	unsigned int max_ctx;
arch/ia64/kernel/smpboot.c renamed from arch/ia64/kernel/smpboot.c~init_removal_ia64 +6 -6
diff -puN arch/ia64/kernel/smpboot.c~init_removal_ia64 arch/ia64/kernel/smpboot.c
@@ -69,7 +69,7 @@ static volatile unsigned long go[SLAVE +
 
 #define DEBUG_ITC_SYNC	0
 
-extern void __init calibrate_delay (void);
+extern void __devinit calibrate_delay (void);
 extern void start_ap (void);
 extern unsigned long ia64_iobase;
 
@@ -262,12 +262,12 @@ ia64_sync_itc (unsigned int master)
 /*
  * Ideally sets up per-cpu profiling hooks.  Doesn't do much now...
  */
-static inline void __init
+static inline void __devinit
 smp_setup_percpu_timer (void)
 {
 }
 
-static void __init
+static void __devinit
 smp_callin (void)
 {
 	int cpuid, phys_id;
@@ -333,7 +333,7 @@ smp_callin (void)
 /*
  * Activate a secondary processor.  head.S calls this.
  */
-int __init
+int __devinit
 start_secondary (void *unused)
 {
 	extern int cpu_idle (void);
@@ -346,7 +346,7 @@ start_secondary (void *unused)
 	return cpu_idle();
 }
 
-static struct task_struct * __init
+static struct task_struct * __devinit
 fork_by_hand (void)
 {
 	/*
@@ -356,7 +356,7 @@ fork_by_hand (void)
 	return copy_process(CLONE_VM|CLONE_IDLETASK, 0, 0, 0, NULL, NULL);
 }
 
-static int __init
+static int __devinit
 do_boot_cpu (int sapicid, int cpu)
 {
 	struct task_struct *idle;
arch/ia64/kernel/time.c renamed from arch/ia64/kernel/time.c~init_removal_ia64 +1 -1
diff -puN arch/ia64/kernel/time.c~init_removal_ia64 arch/ia64/kernel/time.c
@@ -326,7 +326,7 @@ ia64_cpu_local_tick (void)
 	ia64_set_itm(local_cpu_data->itm_next);
 }
 
-void __init
+void __devinit
 ia64_init_itm (void)
 {
 	unsigned long platform_base_freq, itc_freq;
arch/ia64/mm/init.c renamed from arch/ia64/mm/init.c~init_removal_ia64 +2 -2
diff -puN arch/ia64/mm/init.c~init_removal_ia64 arch/ia64/mm/init.c
@@ -274,11 +274,11 @@ setup_gate (void)
 	ia64_patch_gate();
 }
 
-void __init
+void __devinit
 ia64_mmu_init (void *my_cpu_data)
 {
 	unsigned long psr, pta, impl_va_bits;
-	extern void __init tlb_init (void);
+	extern void __devinit tlb_init (void);
 	int cpu;
 
 #ifdef CONFIG_DISABLE_VHPT
arch/ia64/mm/tlb.c renamed from arch/ia64/mm/tlb.c~init_removal_ia64 +1 -1
diff -puN arch/ia64/mm/tlb.c~init_removal_ia64 arch/ia64/mm/tlb.c
@@ -166,7 +166,7 @@ flush_tlb_range (struct vm_area_struct *
 }
 EXPORT_SYMBOL(flush_tlb_range);
 
-void __init
+void __devinit
 ia64_tlb_init (void)
 {
 	ia64_ptce_info_t ptce_info;
include/asm-ia64/smp.h renamed from include/asm-ia64/smp.h~init_removal_ia64 +2 -1
diff -puN include/asm-ia64/smp.h~init_removal_ia64 include/asm-ia64/smp.h
@@ -36,7 +36,7 @@ extern struct smp_boot_data {
 	int cpu_phys_id[NR_CPUS];
 } smp_boot_data __initdata;
 
-extern char no_int_routing __initdata;
+extern char no_int_routing __devinitdata;
 
 extern cpumask_t phys_cpu_present_map;
 extern cpumask_t cpu_online_map;
@@ -111,6 +111,7 @@ hard_smp_processor_id (void)
 /* Upping and downing of CPUs */
 extern int __cpu_disable (void);
 extern void __cpu_die (unsigned int cpu);
+extern void cpu_die (void) __attribute__ ((noreturn));
 extern int __cpu_up (unsigned int cpu);
 extern void __init smp_build_cpu_map(void);
 

_