take3: Updated CPU Hotplug patches for IA64 (pj blessed) Patch [6/7]
Subsystems (3)
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 that 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.
---
linux-2.6.5-lhcs-root/arch/ia64/kernel/smpboot.c | 24 ++++++++++++----------- linux-2.6.5-lhcs-root/fs/proc/proc_misc.c | 4 +-- linux-2.6.5-lhcs-root/include/linux/cpumask.h | 11 ++++++++++ linux-2.6.5-lhcs-root/init/main.c | 4 +-- linux-2.6.5-lhcs-root/kernel/cpu.c | 10 ++++++++- linux-2.6.5-lhcs-root/kernel/sched.c | 11 ++++++++++ 6 files changed, 48 insertions(+), 16 deletions(-)
arch/ia64/kernel/smpboot.c renamed from arch/ia64/kernel/smpboot.c~cpu_present +13 -11
@@ -75,11 +75,11 @@ extern unsigned long ia64_iobase;task_t *task_for_booting_cpu; -/* Bitmask of currently online CPUs */ +/* Bitmasks of currently online, and possible CPUs */ cpumask_t cpu_online_map;EXPORT_SYMBOL (cpu_online_map); -cpumask_t phys_cpu_present_map; -EXPORT_SYMBOL (phys_cpu_present_map); +cpumask_t cpu_possible_map; +EXPORT_SYMBOL (cpu_possible_map);/* which logical CPU number maps to which CPU (physical APIC ID) */ volatile int ia64_cpu_to_sapicid[NR_CPUS ];
@@ -99,6 +99,7 @@ static int __init nointroute (char *str) { no_int_routing =1 ; +printk ("no_int_routing on\n" );return 1 ; }
@@ -437,18 +438,17 @@ smp_build_cpu_map (void)int sapicid, cpu, i;int boot_cpu_id =hard_smp_processor_id (); -for (cpu =0 ; cpu <NR_CPUS ; cpu++) - ia64_cpu_to_sapicid[cpu] =-1 ; - ia64_cpu_to_sapicid[0 ] = boot_cpu_id; -cpus_clear (phys_cpu_present_map); -cpu_set (0 , phys_cpu_present_map); +cpus_clear (cpu_present_map); +cpu_set (0 , cpu_present_map); +cpu_set (0 , cpu_possible_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)continue ; -cpu_set (cpu, phys_cpu_present_map); +cpu_set (cpu, cpu_present_map); +cpu_set (cpu, cpu_possible_map); ia64_cpu_to_sapicid[cpu] = sapicid; cpu++; }
@@ -529,9 +529,11 @@ smp_prepare_cpus (unsigned int max_cpus)if (!max_cpus) {printk (KERN_INFO "SMP mode deactivated.\n" );cpus_clear (cpu_online_map); -cpus_clear (phys_cpu_present_map); +cpus_clear (cpu_present_map); +cpus_clear (cpu_possible_map);cpu_set (0 , cpu_online_map); -cpu_set (0 , phys_cpu_present_map); +cpu_set (0 , cpu_present_map); +cpu_set (0 , cpu_possible_map);return ; } }
include/linux/cpumask.h renamed from include/linux/cpumask.h~cpu_present +11 -0
@@ -10,11 +10,15 @@extern cpumask_t cpu_online_map;extern cpumask_t cpu_possible_map; +extern cpumask_t cpu_present_map;#define num_online_cpus () cpus_weight(cpu_online_map)#define num_possible_cpus () cpus_weight(cpu_possible_map) +#define num_present_cpus () cpus_weight(cpu_present_map) +#define cpu_online (cpu) cpu_isset(cpu, cpu_online_map)#define cpu_possible (cpu) cpu_isset(cpu, cpu_possible_map) +#define cpu_present (cpu) cpu_isset(cpu, cpu_present_map)#define for_each_cpu_mask (cpu, mask) \ for (cpu = first_cpu_const(mk_cpumask_const(mask)); \
@@ -23,16 +27,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
@@ -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 +9 -1
@@ -20,6 +20,14 @@DECLARE_MUTEX (cpucontrol);static struct notifier_block *cpu_chain; +/* +* Represents all cpu's present in the system +* In systems capable of hotplug, this map could dynamically grow +* as new cpu's are detected in the system via any platform specific +* method, such as ACPI for e.g. +*/ +cpumask_t cpu_present_map; +EXPORT_SYMBOL (cpu_present_map);/* Need to know about CPUs going up/down? */ int register_cpu_notifier (struct notifier_block *nb)
@@ -169,7 +177,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; }
fs/proc/proc_misc.c renamed from fs/proc/proc_misc.c~cpu_present +2 -2
@@ -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;
kernel/sched.c renamed from kernel/sched.c~cpu_present +11 -0
@@ -2934,6 +2934,17 @@ void __init sched_init(void)runqueue_t *rq;int i, j, k; +/* +* If arch is not hotplug ready and did not populate +* cpu_present_map, just make cpu_present_map same as cpu_possible_map +* for other cpu bringup code to function as normal. e.g smp_init() etc. +*/ +if (cpus_empty (cpu_present_map)) { +for_each_cpu (i) { +cpu_set (i, cpu_present_map); + } + } +for (i =0 ; i <NR_CPUS ; i++) {prio_array_t *array;
_