public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* x86: Convert cpu_core_map to be a per cpu variable
@ 2007-07-13  6:58 Christoph Lameter
  2007-07-13  7:08 ` David Miller
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Christoph Lameter @ 2007-07-13  6:58 UTC (permalink / raw)
  To: ak; +Cc: linux-kernel, travis, Jeremy Fitzhardinge

cpu_core_map is currently an array defined using NR_CPUS. This means that
we overallocate since we will rarely really use the maximum 
number of configured cpus. This may become a problem when we need to 
increase the NR_CPUs on x86_64 for our new product line.

If we put the cpu_core_map into the per cpu area then it will be allocated
for each processor as it comes online.

However, this means that the core map cannot be accessed until the per cpu 
area has been allocated. Xen does a weird thing here looping over all 
processors and zeroing the masks that are not yet allocated and that will 
be zeroed when they are allocated. I commented the code out. Maybe there 
is another purpose? Jeremy?

Signed-off-by: Christoph Lameter <clameter@sgi.com>

---
 arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c       |    2 -
 arch/i386/kernel/cpu/cpufreq/powernow-k8.c        |   10 +++---
 arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c |    2 -
 arch/i386/kernel/cpu/proc.c                       |    3 +
 arch/i386/kernel/smpboot.c                        |   34 +++++++++++-----------
 arch/i386/xen/smp.c                               |   13 +++++++-
 arch/x86_64/kernel/mce_amd.c                      |    6 +--
 arch/x86_64/kernel/setup.c                        |    2 -
 arch/x86_64/kernel/smpboot.c                      |   24 +++++++--------
 include/asm-i386/smp.h                            |    2 -
 include/asm-i386/topology.h                       |    2 -
 include/asm-x86_64/topology.h                     |    2 -
 12 files changed, 56 insertions(+), 46 deletions(-)

Index: linux-2.6.22-rc6-mm1/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c	2007-07-12 23:02:11.000000000 -0700
+++ linux-2.6.22-rc6-mm1/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c	2007-07-12 23:14:04.000000000 -0700
@@ -609,7 +609,7 @@ static int acpi_cpufreq_cpu_init(struct 
 	dmi_check_system(sw_any_bug_dmi_table);
 	if (bios_with_sw_any_bug && cpus_weight(policy->cpus) == 1) {
 		policy->shared_type = CPUFREQ_SHARED_TYPE_ALL;
-		policy->cpus = cpu_core_map[cpu];
+		policy->cpus = per_cpu(cpu_core_map, cpu);
 	}
 #endif
 
Index: linux-2.6.22-rc6-mm1/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/arch/i386/kernel/cpu/cpufreq/powernow-k8.c	2007-07-12 23:02:11.000000000 -0700
+++ linux-2.6.22-rc6-mm1/arch/i386/kernel/cpu/cpufreq/powernow-k8.c	2007-07-12 23:14:04.000000000 -0700
@@ -57,7 +57,7 @@ static struct powernow_k8_data *powernow
 static int cpu_family = CPU_OPTERON;
 
 #ifndef CONFIG_SMP
-static cpumask_t cpu_core_map[1];
+DEFINE_PER_CPU(cpumask_t, cpu_core_map)
 #endif
 
 /* Return a frequency in MHz, given an input fid */
@@ -661,7 +661,7 @@ static int fill_powernow_table(struct po
 
 	dprintk("cfid 0x%x, cvid 0x%x\n", data->currfid, data->currvid);
 	data->powernow_table = powernow_table;
-	if (first_cpu(cpu_core_map[data->cpu]) == data->cpu)
+	if (first_cpu(per_cpu(cpu_core_map, data->cpu)) == data->cpu)
 		print_basics(data);
 
 	for (j = 0; j < data->numps; j++)
@@ -815,7 +815,7 @@ static int powernow_k8_cpu_init_acpi(str
 
 	/* fill in data */
 	data->numps = data->acpi_data.state_count;
-	if (first_cpu(cpu_core_map[data->cpu]) == data->cpu)
+	if (first_cpu(per_cpu(cpu_core_map, data->cpu)) == data->cpu)
 		print_basics(data);
 	powernow_k8_acpi_pst_values(data, 0);
 
@@ -1209,7 +1209,7 @@ static int __cpuinit powernowk8_cpu_init
 	if (cpu_family == CPU_HW_PSTATE)
 		pol->cpus = cpumask_of_cpu(pol->cpu);
 	else
-		pol->cpus = cpu_core_map[pol->cpu];
+		pol->cpus = per_cpu(cpu_core_map, pol->cpu);
 	data->available_cores = &(pol->cpus);
 
 	/* Take a crude guess here.
@@ -1276,7 +1276,7 @@ static unsigned int powernowk8_get (unsi
 	cpumask_t oldmask = current->cpus_allowed;
 	unsigned int khz = 0;
 
-	data = powernow_data[first_cpu(cpu_core_map[cpu])];
+	data = powernow_data[first_cpu(per_cpu(cpu_core_map, cpu))];
 
 	if (!data)
 		return -EINVAL;
Index: linux-2.6.22-rc6-mm1/arch/x86_64/kernel/mce_amd.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/arch/x86_64/kernel/mce_amd.c	2007-07-12 23:02:11.000000000 -0700
+++ linux-2.6.22-rc6-mm1/arch/x86_64/kernel/mce_amd.c	2007-07-12 23:14:04.000000000 -0700
@@ -472,7 +472,7 @@ static __cpuinit int threshold_create_ba
 
 #ifdef CONFIG_SMP
 	if (cpu_data[cpu].cpu_core_id && shared_bank[bank]) {	/* symlink */
-		i = first_cpu(cpu_core_map[cpu]);
+		i = first_cpu(per_cpu(cpu_core_map, cpu));
 
 		/* first core not up yet */
 		if (cpu_data[i].cpu_core_id)
@@ -492,7 +492,7 @@ static __cpuinit int threshold_create_ba
 		if (err)
 			goto out;
 
-		b->cpus = cpu_core_map[cpu];
+		b->cpus = per_cpu(cpu_core_map, cpu);
 		per_cpu(threshold_banks, cpu)[bank] = b;
 		goto out;
 	}
@@ -509,7 +509,7 @@ static __cpuinit int threshold_create_ba
 #ifndef CONFIG_SMP
 	b->cpus = CPU_MASK_ALL;
 #else
-	b->cpus = cpu_core_map[cpu];
+	b->cpus = per_cpu(cpu_core_map, cpu);
 #endif
 	err = kobject_register(&b->kobj);
 	if (err)
Index: linux-2.6.22-rc6-mm1/arch/x86_64/kernel/setup.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/arch/x86_64/kernel/setup.c	2007-07-12 23:02:11.000000000 -0700
+++ linux-2.6.22-rc6-mm1/arch/x86_64/kernel/setup.c	2007-07-12 23:14:04.000000000 -0700
@@ -1042,7 +1042,7 @@ static int show_cpuinfo(struct seq_file 
 	if (smp_num_siblings * c->x86_max_cores > 1) {
 		int cpu = c - cpu_data;
 		seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
-		seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[cpu]));
+		seq_printf(m, "siblings\t: %d\n", cpus_weight(per_cpu(cpu_core_map, cpu)));
 		seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
 		seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
 	}
Index: linux-2.6.22-rc6-mm1/arch/x86_64/kernel/smpboot.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/arch/x86_64/kernel/smpboot.c	2007-07-12 23:02:11.000000000 -0700
+++ linux-2.6.22-rc6-mm1/arch/x86_64/kernel/smpboot.c	2007-07-12 23:25:36.000000000 -0700
@@ -95,8 +95,8 @@ cpumask_t cpu_sibling_map[NR_CPUS] __rea
 EXPORT_SYMBOL(cpu_sibling_map);
 
 /* representing HT and core siblings of each logical CPU */
-cpumask_t cpu_core_map[NR_CPUS] __read_mostly;
-EXPORT_SYMBOL(cpu_core_map);
+DEFINE_PER_CPU(cpumask_t, cpu_core_map);
+EXPORT_PER_CPU_SYMBOL(cpu_core_map);
 
 /*
  * Trampoline 80x86 program as an array.
@@ -243,7 +243,7 @@ cpumask_t cpu_coregroup_map(int cpu)
 	 * And for power savings, we return cpu_core_map
 	 */
 	if (sched_mc_power_savings || sched_smt_power_savings)
-		return cpu_core_map[cpu];
+		return per_cpu(cpu_core_map, cpu);
 	else
 		return c->llc_shared_map;
 }
@@ -264,8 +264,8 @@ static inline void set_cpu_sibling_map(i
 			    c[cpu].cpu_core_id == c[i].cpu_core_id) {
 				cpu_set(i, cpu_sibling_map[cpu]);
 				cpu_set(cpu, cpu_sibling_map[i]);
-				cpu_set(i, cpu_core_map[cpu]);
-				cpu_set(cpu, cpu_core_map[i]);
+				cpu_set(i, per_cpu(cpu_core_map, cpu));
+				cpu_set(cpu, per_cpu(cpu_core_map, i));
 				cpu_set(i, c[cpu].llc_shared_map);
 				cpu_set(cpu, c[i].llc_shared_map);
 			}
@@ -277,7 +277,7 @@ static inline void set_cpu_sibling_map(i
 	cpu_set(cpu, c[cpu].llc_shared_map);
 
 	if (current_cpu_data.x86_max_cores == 1) {
-		cpu_core_map[cpu] = cpu_sibling_map[cpu];
+		per_cpu(cpu_core_map, cpu) = cpu_sibling_map[cpu];
 		c[cpu].booted_cores = 1;
 		return;
 	}
@@ -289,8 +289,8 @@ static inline void set_cpu_sibling_map(i
 			cpu_set(cpu, c[i].llc_shared_map);
 		}
 		if (c[cpu].phys_proc_id == c[i].phys_proc_id) {
-			cpu_set(i, cpu_core_map[cpu]);
-			cpu_set(cpu, cpu_core_map[i]);
+			cpu_set(i, per_cpu(cpu_core_map, cpu));
+			cpu_set(cpu, per_cpu(cpu_core_map, i));
 			/*
 			 *  Does this new cpu bringup a new core?
 			 */
@@ -739,7 +739,7 @@ static __init void disable_smp(void)
 	else
 		phys_cpu_present_map = physid_mask_of_physid(0);
 	cpu_set(0, cpu_sibling_map[0]);
-	cpu_set(0, cpu_core_map[0]);
+	cpu_set(0, per_cpu(cpu_core_map, 0));
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
@@ -974,8 +974,8 @@ static void remove_siblinginfo(int cpu)
 	int sibling;
 	struct cpuinfo_x86 *c = cpu_data;
 
-	for_each_cpu_mask(sibling, cpu_core_map[cpu]) {
-		cpu_clear(cpu, cpu_core_map[sibling]);
+	for_each_cpu_mask(sibling, per_cpu(cpu_core_map, cpu)) {
+		cpu_clear(cpu, per_cpu(cpu_core_map, sibling));
 		/*
 		 * last thread sibling in this cpu core going down
 		 */
@@ -986,7 +986,7 @@ static void remove_siblinginfo(int cpu)
 	for_each_cpu_mask(sibling, cpu_sibling_map[cpu])
 		cpu_clear(cpu, cpu_sibling_map[sibling]);
 	cpus_clear(cpu_sibling_map[cpu]);
-	cpus_clear(cpu_core_map[cpu]);
+	cpus_clear(per_cpu(cpu_core_map, cpu));
 	c[cpu].phys_proc_id = 0;
 	c[cpu].cpu_core_id = 0;
 	cpu_clear(cpu, cpu_sibling_setup_map);
Index: linux-2.6.22-rc6-mm1/include/asm-i386/smp.h
===================================================================
--- linux-2.6.22-rc6-mm1.orig/include/asm-i386/smp.h	2007-07-12 23:26:57.000000000 -0700
+++ linux-2.6.22-rc6-mm1/include/asm-i386/smp.h	2007-07-12 23:27:20.000000000 -0700
@@ -31,7 +31,7 @@ extern void smp_alloc_memory(void);
 extern int pic_mode;
 extern int smp_num_siblings;
 extern cpumask_t cpu_sibling_map[];
-extern cpumask_t cpu_core_map[];
+DECLARE_PER_CPU(cpumask_t, cpu_core_map);
 
 extern void (*mtrr_hook) (void);
 extern void zap_low_mappings (void);
Index: linux-2.6.22-rc6-mm1/include/asm-i386/topology.h
===================================================================
--- linux-2.6.22-rc6-mm1.orig/include/asm-i386/topology.h	2007-07-12 23:27:28.000000000 -0700
+++ linux-2.6.22-rc6-mm1/include/asm-i386/topology.h	2007-07-12 23:27:37.000000000 -0700
@@ -30,7 +30,7 @@
 #ifdef CONFIG_X86_HT
 #define topology_physical_package_id(cpu)	(cpu_data[cpu].phys_proc_id)
 #define topology_core_id(cpu)			(cpu_data[cpu].cpu_core_id)
-#define topology_core_siblings(cpu)		(cpu_core_map[cpu])
+#define topology_core_siblings(cpu)		(per_cpu(cpu_core_map, cpu))
 #define topology_thread_siblings(cpu)		(cpu_sibling_map[cpu])
 #endif
 
Index: linux-2.6.22-rc6-mm1/include/asm-x86_64/topology.h
===================================================================
--- linux-2.6.22-rc6-mm1.orig/include/asm-x86_64/topology.h	2007-07-12 23:26:14.000000000 -0700
+++ linux-2.6.22-rc6-mm1/include/asm-x86_64/topology.h	2007-07-12 23:26:28.000000000 -0700
@@ -58,7 +58,7 @@ extern int __node_distance(int, int);
 #ifdef CONFIG_SMP
 #define topology_physical_package_id(cpu)	(cpu_data[cpu].phys_proc_id)
 #define topology_core_id(cpu)			(cpu_data[cpu].cpu_core_id)
-#define topology_core_siblings(cpu)		(cpu_core_map[cpu])
+#define topology_core_siblings(cpu)		(per_cpu(cpu_core_map, cpu))
 #define topology_thread_siblings(cpu)		(cpu_sibling_map[cpu])
 #define mc_capable()			(boot_cpu_data.x86_max_cores > 1)
 #define smt_capable() 			(smp_num_siblings > 1)
Index: linux-2.6.22-rc6-mm1/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c	2007-07-12 23:30:11.000000000 -0700
+++ linux-2.6.22-rc6-mm1/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c	2007-07-12 23:30:50.000000000 -0700
@@ -444,7 +444,7 @@ static int centrino_cpu_init_acpi(struct
 	dmi_check_system(sw_any_bug_dmi_table);
 	if (bios_with_sw_any_bug && cpus_weight(policy->cpus) == 1) {
 		policy->shared_type = CPUFREQ_SHARED_TYPE_ALL;
-		policy->cpus = cpu_core_map[cpu];
+		policy->cpus = per_cpu(cpu_core_map, cpu);
 	}
 #endif
 
Index: linux-2.6.22-rc6-mm1/arch/i386/kernel/cpu/proc.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/arch/i386/kernel/cpu/proc.c	2007-07-12 23:31:30.000000000 -0700
+++ linux-2.6.22-rc6-mm1/arch/i386/kernel/cpu/proc.c	2007-07-12 23:32:01.000000000 -0700
@@ -122,7 +122,8 @@ static int show_cpuinfo(struct seq_file 
 #ifdef CONFIG_X86_HT
 	if (c->x86_max_cores * smp_num_siblings > 1) {
 		seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
-		seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[n]));
+		seq_printf(m, "siblings\t: %d\n",
+				cpus_weight(per_cpu(cpu_core_map, n)));
 		seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
 		seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
 	}
Index: linux-2.6.22-rc6-mm1/arch/i386/kernel/smpboot.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/arch/i386/kernel/smpboot.c	2007-07-12 23:33:30.000000000 -0700
+++ linux-2.6.22-rc6-mm1/arch/i386/kernel/smpboot.c	2007-07-12 23:39:13.000000000 -0700
@@ -74,8 +74,8 @@ cpumask_t cpu_sibling_map[NR_CPUS] __rea
 EXPORT_SYMBOL(cpu_sibling_map);
 
 /* representing HT and core siblings of each logical CPU */
-cpumask_t cpu_core_map[NR_CPUS] __read_mostly;
-EXPORT_SYMBOL(cpu_core_map);
+DEFINE_PER_CPU(cpumask_t, cpu_core_map);
+EXPORT_PER_CPU_SYMBOL(cpu_core_map);
 
 /* bitmap of online cpus */
 cpumask_t cpu_online_map __read_mostly;
@@ -300,7 +300,7 @@ cpumask_t cpu_coregroup_map(int cpu)
 	 * And for power savings, we return cpu_core_map
 	 */
 	if (sched_mc_power_savings || sched_smt_power_savings)
-		return cpu_core_map[cpu];
+		return per_cpu(cpu_core_map, cpu);
 	else
 		return c->llc_shared_map;
 }
@@ -321,8 +321,8 @@ void __cpuinit set_cpu_sibling_map(int c
 			    c[cpu].cpu_core_id == c[i].cpu_core_id) {
 				cpu_set(i, cpu_sibling_map[cpu]);
 				cpu_set(cpu, cpu_sibling_map[i]);
-				cpu_set(i, cpu_core_map[cpu]);
-				cpu_set(cpu, cpu_core_map[i]);
+				cpu_set(i, per_cpu(cpu_core_map, cpu));
+				cpu_set(cpu, per_cpu(cpu_core_map, i));
 				cpu_set(i, c[cpu].llc_shared_map);
 				cpu_set(cpu, c[i].llc_shared_map);
 			}
@@ -334,7 +334,7 @@ void __cpuinit set_cpu_sibling_map(int c
 	cpu_set(cpu, c[cpu].llc_shared_map);
 
 	if (current_cpu_data.x86_max_cores == 1) {
-		cpu_core_map[cpu] = cpu_sibling_map[cpu];
+		per_cpu(cpu_core_map, cpu) = cpu_sibling_map[cpu];
 		c[cpu].booted_cores = 1;
 		return;
 	}
@@ -346,8 +346,8 @@ void __cpuinit set_cpu_sibling_map(int c
 			cpu_set(cpu, c[i].llc_shared_map);
 		}
 		if (c[cpu].phys_proc_id == c[i].phys_proc_id) {
-			cpu_set(i, cpu_core_map[cpu]);
-			cpu_set(cpu, cpu_core_map[i]);
+			cpu_set(i, per_cpu(cpu_core_map, cpu));
+			cpu_set(cpu, per_cpu(cpu_core_map, i));
 			/*
 			 *  Does this new cpu bringup a new core?
 			 */
@@ -984,7 +984,7 @@ static void __init smp_boot_cpus(unsigne
 					   " Using dummy APIC emulation.\n");
 		map_cpu_to_logical_apicid();
 		cpu_set(0, cpu_sibling_map[0]);
-		cpu_set(0, cpu_core_map[0]);
+		cpu_set(0, per_cpu(cpu_core_map, 0));
 		return;
 	}
 
@@ -1009,7 +1009,7 @@ static void __init smp_boot_cpus(unsigne
 		smpboot_clear_io_apic_irqs();
 		phys_cpu_present_map = physid_mask_of_physid(0);
 		cpu_set(0, cpu_sibling_map[0]);
-		cpu_set(0, cpu_core_map[0]);
+		cpu_set(0, per_cpu(cpu_core_map, 0));
 		return;
 	}
 
@@ -1024,7 +1024,7 @@ static void __init smp_boot_cpus(unsigne
 		smpboot_clear_io_apic_irqs();
 		phys_cpu_present_map = physid_mask_of_physid(0);
 		cpu_set(0, cpu_sibling_map[0]);
-		cpu_set(0, cpu_core_map[0]);
+		cpu_set(0, per_cpu(cpu_core_map, 0));
 		return;
 	}
 
@@ -1107,11 +1107,11 @@ static void __init smp_boot_cpus(unsigne
 	 */
 	for (cpu = 0; cpu < NR_CPUS; cpu++) {
 		cpus_clear(cpu_sibling_map[cpu]);
-		cpus_clear(cpu_core_map[cpu]);
+		cpus_clear(per_cpu(cpu_core_map, cpu));
 	}
 
 	cpu_set(0, cpu_sibling_map[0]);
-	cpu_set(0, cpu_core_map[0]);
+	cpu_set(0, per_cpu(cpu_core_map, 0));
 
 	smpboot_setup_io_apic();
 
@@ -1148,9 +1148,9 @@ void remove_siblinginfo(int cpu)
 	int sibling;
 	struct cpuinfo_x86 *c = cpu_data;
 
-	for_each_cpu_mask(sibling, cpu_core_map[cpu]) {
-		cpu_clear(cpu, cpu_core_map[sibling]);
-		/*
+	for_each_cpu_mask(sibling, per_cpu(cpu_core_map, cpu)) {
+		cpu_clear(cpu, per_cpu(cpu_core_map, sibling));
+		/*/
 		 * last thread sibling in this cpu core going down
 		 */
 		if (cpus_weight(cpu_sibling_map[cpu]) == 1)
@@ -1160,7 +1160,7 @@ void remove_siblinginfo(int cpu)
 	for_each_cpu_mask(sibling, cpu_sibling_map[cpu])
 		cpu_clear(cpu, cpu_sibling_map[sibling]);
 	cpus_clear(cpu_sibling_map[cpu]);
-	cpus_clear(cpu_core_map[cpu]);
+	cpus_clear(per_cpu(cpu_core_map, cpu));
 	c[cpu].phys_proc_id = 0;
 	c[cpu].cpu_core_id = 0;
 	cpu_clear(cpu, cpu_sibling_setup_map);
Index: linux-2.6.22-rc6-mm1/arch/i386/xen/smp.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/arch/i386/xen/smp.c	2007-07-12 23:32:37.000000000 -0700
+++ linux-2.6.22-rc6-mm1/arch/i386/xen/smp.c	2007-07-12 23:52:08.000000000 -0700
@@ -150,7 +150,12 @@ void __init xen_smp_prepare_boot_cpu(voi
 
 	for (cpu = 0; cpu < NR_CPUS; cpu++) {
 		cpus_clear(cpu_sibling_map[cpu]);
-		cpus_clear(cpu_core_map[cpu]);
+		/*
+		 * cpu_core_map lives in a per cpu area that is cleared
+		 * when the per cpu array is allocated.
+		 *
+		 * cpus_clear(per_cpu(cpu_core_map, cpu));
+		 */
 	}
 }
 
@@ -160,7 +165,11 @@ void __init xen_smp_prepare_cpus(unsigne
 
 	for (cpu = 0; cpu < NR_CPUS; cpu++) {
 		cpus_clear(cpu_sibling_map[cpu]);
-		cpus_clear(cpu_core_map[cpu]);
+		/*
+		 * cpu_core_ map will be zeroed when the per cpu area is allocated.
+		 *
+		 * cpus_clear(per_cpu(cpu_core_map, cpu));
+		 */
 	}
 
 	smp_store_cpu_info(0);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: x86: Convert cpu_core_map to be a per cpu variable
  2007-07-13  6:58 x86: Convert cpu_core_map to be a per cpu variable Christoph Lameter
@ 2007-07-13  7:08 ` David Miller
  2007-07-13 16:34   ` Christoph Lameter
  2007-07-13 13:49 ` Jeremy Fitzhardinge
  2007-07-17 19:27 ` Siddha, Suresh B
  2 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2007-07-13  7:08 UTC (permalink / raw)
  To: clameter; +Cc: ak, linux-kernel, travis, jeremy

From: Christoph Lameter <clameter@sgi.com>
Date: Thu, 12 Jul 2007 23:58:06 -0700 (PDT)

> cpu_core_map is currently an array defined using NR_CPUS. This means that
> we overallocate since we will rarely really use the maximum 
> number of configured cpus. This may become a problem when we need to 
> increase the NR_CPUs on x86_64 for our new product line.

I'm using NR_CPUS set to 1024 on my sparc64 workstation, it's
not that bad to be honest :-)  What kind of cpu arity are you
talking about?

> If we put the cpu_core_map into the per cpu area then it will be allocated
> for each processor as it comes online.
> 
> However, this means that the core map cannot be accessed until the per cpu 
> area has been allocated. Xen does a weird thing here looping over all 
> processors and zeroing the masks that are not yet allocated and that will 
> be zeroed when they are allocated. I commented the code out. Maybe there 
> is another purpose? Jeremy?
> 
> Signed-off-by: Christoph Lameter <clameter@sgi.com>

Please take care of sparc64 if you're going to do this change.
It uses cpu_core_map too.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: x86: Convert cpu_core_map to be a per cpu variable
  2007-07-13  6:58 x86: Convert cpu_core_map to be a per cpu variable Christoph Lameter
  2007-07-13  7:08 ` David Miller
@ 2007-07-13 13:49 ` Jeremy Fitzhardinge
  2007-07-17 19:27 ` Siddha, Suresh B
  2 siblings, 0 replies; 9+ messages in thread
From: Jeremy Fitzhardinge @ 2007-07-13 13:49 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: ak, linux-kernel, travis

Christoph Lameter wrote:
> cpu_core_map is currently an array defined using NR_CPUS. This means that
> we overallocate since we will rarely really use the maximum 
> number of configured cpus. This may become a problem when we need to 
> increase the NR_CPUs on x86_64 for our new product line.
>
> If we put the cpu_core_map into the per cpu area then it will be allocated
> for each processor as it comes online.
>
> However, this means that the core map cannot be accessed until the per cpu 
> area has been allocated. Xen does a weird thing here looping over all 
> processors and zeroing the masks that are not yet allocated and that will 
> be zeroed when they are allocated. I commented the code out. Maybe there 
> is another purpose? Jeremy?
>   

That code is identical to the code in smp_boot_cpus().  Not sure why it 
needs to be there twice though.  Perhaps it doesn't need to be there at all.

> @@ -1107,11 +1107,11 @@ static void __init smp_boot_cpus(unsigne
>  	 */
>  	for (cpu = 0; cpu < NR_CPUS; cpu++) {
>  		cpus_clear(cpu_sibling_map[cpu]);
> -		cpus_clear(cpu_core_map[cpu]);
> +		cpus_clear(per_cpu(cpu_core_map, cpu));
>  	}
>  
>  	cpu_set(0, cpu_sibling_map[0]);
> -	cpu_set(0, cpu_core_map[0]);
> +	cpu_set(0, per_cpu(cpu_core_map, 0));
>   

> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/arch/i386/xen/smp.c	2007-07-12 23:32:37.000000000 -0700
> +++ linux-2.6.22-rc6-mm1/arch/i386/xen/smp.c	2007-07-12 23:52:08.000000000 -0700
> @@ -150,7 +150,12 @@ void __init xen_smp_prepare_boot_cpu(voi
>  
>  	for (cpu = 0; cpu < NR_CPUS; cpu++) {
>  		cpus_clear(cpu_sibling_map[cpu]);
> -		cpus_clear(cpu_core_map[cpu]);
> +		/*
> +		 * cpu_core_map lives in a per cpu area that is cleared
> +		 * when the per cpu array is allocated.
> +		 *
> +		 * cpus_clear(per_cpu(cpu_core_map, cpu));
> +		 */
>  	}
>  }
>  
> @@ -160,7 +165,11 @@ void __init xen_smp_prepare_cpus(unsigne
>  
>  	for (cpu = 0; cpu < NR_CPUS; cpu++) {
>  		cpus_clear(cpu_sibling_map[cpu]);
> -		cpus_clear(cpu_core_map[cpu]);
> +		/*
> +		 * cpu_core_ map will be zeroed when the per cpu area is allocated.
> +		 *
> +		 * cpus_clear(per_cpu(cpu_core_map, cpu));
> +		 */
>  	}
>  
>  	smp_store_cpu_info(0);
>   

    J

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: x86: Convert cpu_core_map to be a per cpu variable
  2007-07-13  7:08 ` David Miller
@ 2007-07-13 16:34   ` Christoph Lameter
  2007-07-13 22:41     ` David Miller
  0 siblings, 1 reply; 9+ messages in thread
From: Christoph Lameter @ 2007-07-13 16:34 UTC (permalink / raw)
  To: David Miller; +Cc: ak, linux-kernel, travis, jeremy

On Fri, 13 Jul 2007, David Miller wrote:

> From: Christoph Lameter <clameter@sgi.com>
> Date: Thu, 12 Jul 2007 23:58:06 -0700 (PDT)
> 
> > cpu_core_map is currently an array defined using NR_CPUS. This means that
> > we overallocate since we will rarely really use the maximum 
> > number of configured cpus. This may become a problem when we need to 
> > increase the NR_CPUs on x86_64 for our new product line.
> 
> I'm using NR_CPUS set to 1024 on my sparc64 workstation, it's
> not that bad to be honest :-)  What kind of cpu arity are you
> talking about?

Up to 16k.

> > If we put the cpu_core_map into the per cpu area then it will be allocated
> > for each processor as it comes online.
> > 
> > However, this means that the core map cannot be accessed until the per cpu 
> > area has been allocated. Xen does a weird thing here looping over all 
> > processors and zeroing the masks that are not yet allocated and that will 
> > be zeroed when they are allocated. I commented the code out. Maybe there 
> > is another purpose? Jeremy?
> > 
> > Signed-off-by: Christoph Lameter <clameter@sgi.com>
> 
> Please take care of sparc64 if you're going to do this change.
> It uses cpu_core_map too.

But the code modified here is x86_64 and i386 specific? Is there an 
overlap?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: x86: Convert cpu_core_map to be a per cpu variable
  2007-07-13 16:34   ` Christoph Lameter
@ 2007-07-13 22:41     ` David Miller
  2007-07-13 22:50       ` Christoph Lameter
  0 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2007-07-13 22:41 UTC (permalink / raw)
  To: clameter; +Cc: ak, linux-kernel, travis, jeremy

From: Christoph Lameter <clameter@sgi.com>
Date: Fri, 13 Jul 2007 09:34:02 -0700 (PDT)

> But the code modified here is x86_64 and i386 specific? Is there an 
> overlap?

I see, the acessor is abstracted via a function.

That seems pointless, and allows you to do things like this, improving
the implementation on one set of platforms yet leave others using
SMT/multi-core scheduling behind.

It makes a lot more sense to make the implementation consistent
and therefore the improvements are seen on every platform.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: x86: Convert cpu_core_map to be a per cpu variable
  2007-07-13 22:41     ` David Miller
@ 2007-07-13 22:50       ` Christoph Lameter
  2007-07-13 22:51         ` David Miller
  0 siblings, 1 reply; 9+ messages in thread
From: Christoph Lameter @ 2007-07-13 22:50 UTC (permalink / raw)
  To: David Miller; +Cc: ak, linux-kernel, travis, jeremy


On Fri, 13 Jul 2007, David Miller wrote:

> I see, the acessor is abstracted via a function.

Yes. The accessor for the scheduler is defined for each arch in topology.c

> That seems pointless, and allows you to do things like this, improving
> the implementation on one set of platforms yet leave others using
> SMT/multi-core scheduling behind.
> 
> It makes a lot more sense to make the implementation consistent
> and therefore the improvements are seen on every platform.

Slight differences exist on each platform. I already have enough trouble 
here right now to deal with the x86_64 overlap into i386. There are 
numerous other x86 specific maps that will have to be treated the same way 
and they are all handled in arch specific files.

Core cpu and node maps exist in the page allocator and are defined in 
nodemask.h and cpumask.h. I have recently introduced a framework that 
allows the definition of new masks that could be used in the future to 
abstract these out of the arches (See the memoryless node patchees). But 
that work has not been merged yet and is likely going to be a separate 
project.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: x86: Convert cpu_core_map to be a per cpu variable
  2007-07-13 22:50       ` Christoph Lameter
@ 2007-07-13 22:51         ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2007-07-13 22:51 UTC (permalink / raw)
  To: clameter; +Cc: ak, linux-kernel, travis, jeremy

From: Christoph Lameter <clameter@sgi.com>
Date: Fri, 13 Jul 2007 15:50:33 -0700 (PDT)

> Core cpu and node maps exist in the page allocator and are defined in 
> nodemask.h and cpumask.h. I have recently introduced a framework that 
> allows the definition of new masks that could be used in the future to 
> abstract these out of the arches (See the memoryless node patchees). But 
> that work has not been merged yet and is likely going to be a separate 
> project.

Ok.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: x86: Convert cpu_core_map to be a per cpu variable
  2007-07-13  6:58 x86: Convert cpu_core_map to be a per cpu variable Christoph Lameter
  2007-07-13  7:08 ` David Miller
  2007-07-13 13:49 ` Jeremy Fitzhardinge
@ 2007-07-17 19:27 ` Siddha, Suresh B
  2007-07-23 19:34   ` Christoph Lameter
  2 siblings, 1 reply; 9+ messages in thread
From: Siddha, Suresh B @ 2007-07-17 19:27 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: ak, linux-kernel, travis, Jeremy Fitzhardinge

On Thu, Jul 12, 2007 at 11:58:06PM -0700, Christoph Lameter wrote:
> cpu_core_map is currently an array defined using NR_CPUS. This means that
> we overallocate since we will rarely really use the maximum 
> number of configured cpus. This may become a problem when we need to 
> increase the NR_CPUs on x86_64 for our new product line.
> 
> If we put the cpu_core_map into the per cpu area then it will be allocated
> for each processor as it comes online.
> 
> However, this means that the core map cannot be accessed until the per cpu 
> area has been allocated. Xen does a weird thing here looping over all 
> processors and zeroing the masks that are not yet allocated and that will 
> be zeroed when they are allocated. I commented the code out. Maybe there 
> is another purpose? Jeremy?

Is there a reason why cpu_sibling_map[] is left out in these changes?

thanks,
suresh

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: x86: Convert cpu_core_map to be a per cpu variable
  2007-07-17 19:27 ` Siddha, Suresh B
@ 2007-07-23 19:34   ` Christoph Lameter
  0 siblings, 0 replies; 9+ messages in thread
From: Christoph Lameter @ 2007-07-23 19:34 UTC (permalink / raw)
  To: Siddha, Suresh B; +Cc: ak, linux-kernel, travis, Jeremy Fitzhardinge

On Tue, 17 Jul 2007 12:27:18 -0700
"Siddha, Suresh B" <suresh.b.siddha@intel.com> wrote:


> Is there a reason why cpu_sibling_map[] is left out in these changes?

Yes this patch is a trial balloon to make sure that I/we do the right
thing when dealing with the other cpu maps. Patchset will hopefully
soon be forthcoming (after I have dealt with the pile of emails/issues
that came in during my vacation). I'd be glad if someone else could do
it???

Hopefully yours,
	C


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-07-23 19:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-13  6:58 x86: Convert cpu_core_map to be a per cpu variable Christoph Lameter
2007-07-13  7:08 ` David Miller
2007-07-13 16:34   ` Christoph Lameter
2007-07-13 22:41     ` David Miller
2007-07-13 22:50       ` Christoph Lameter
2007-07-13 22:51         ` David Miller
2007-07-13 13:49 ` Jeremy Fitzhardinge
2007-07-17 19:27 ` Siddha, Suresh B
2007-07-23 19:34   ` Christoph Lameter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox