Skip to contentSkip to conversation

CONFIG_SMP=n fixes redux

PATCH In review Jesse Barnes 1 participant 2 messages Sep 1, 2004 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CONFIG_SMP=n fixes redux

Today both Christoph and Alex mentioned that they thought this patch would be nice to have in the tree. It allows a generic kernel to build and run when CONFIG_SMP=n. I'd still like feedback about the per-cpu stuff though, in particular, this

+#ifdef CONFIG_SMP

        /* Set the node_data pointer for each per-cpu struct */
        for (cpu = 0; cpu < NR_CPUS; cpu++) {
                node = node_cpuid[cpu].nid;
                per_cpu(cpu_info, cpu).node_data = mem_data[node].node_data;
        }
+#else
+       {
+               struct cpuinfo_ia64 *cpu0_cpu_info;
+               cpu = 0;
+               node = node_cpuid[cpu].nid;
+               cpu0_cpu_info = (struct cpuinfo_ia64 *)(__phys_per_cpu_start +

+ ((char *)&per_cpu__cpu_info - __per_cpu_start));
+ cpu0_cpu_info->node_data = mem_data[node].node_data;
+ }
+#endif /* CONFIG_SMP */

is really ugly. Maybe I should take this opportunity to convert the early memory allocation code to using the bootmem allocator instead of backdooring it via find_pernode_space()? I think that would mean we could share more code between the contig and discontigmem cases, but we'd also have to be careful to avoid cacheline aliasing.

Thanks,
Jesse

===== arch/ia64/kernel/Makefile 1.34 vs edited =====

arch/ia64/kernel/Makefile +1 -0
@@ -15,6 +15,7 @@
 obj-$(CONFIG_IOSAPIC)		+= iosapic.o
 obj-$(CONFIG_MODULES)		+= module.o
 obj-$(CONFIG_SMP)		+= smp.o smpboot.o
+obj-$(CONFIG_NUMA)		+= numa.o
 obj-$(CONFIG_PERFMON)		+= perfmon_default_smpl.o
 obj-$(CONFIG_IA64_CYCLONE)	+= cyclone.o
 

===== arch/ia64/kernel/acpi.c 1.74 vs edited =====

arch/ia64/kernel/acpi.c +3 -1
@@ -624,8 +624,10 @@
 			if (smp_boot_data.cpu_phys_id[cpu] != hard_smp_processor_id())
 				node_cpuid[i++].phys_id = smp_boot_data.cpu_phys_id[cpu];
 	}
-	build_cpu_to_node_map();
 # endif
+#endif
+#ifdef CONFIG_ACPI_NUMA
+	build_cpu_to_node_map();
 #endif
 	/* Make boot-up look pretty */
 	printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus, total_cpus);

===== arch/ia64/kernel/setup.c 1.79 vs edited =====

arch/ia64/kernel/setup.c +0 -2
@@ -317,11 +317,9 @@
 	machvec_init(acpi_get_sysname());
 #endif
 
-#ifdef CONFIG_SMP
 	/* If we register an early console, allow CPU 0 to printk */
 	if (!early_console_setup())
 		cpu_set(smp_processor_id(), cpu_online_map);
-#endif
 
 #ifdef CONFIG_ACPI_BOOT
 	/* Initialize the ACPI boot-time table parser */

===== arch/ia64/kernel/smpboot.c 1.60 vs edited =====

arch/ia64/kernel/smpboot.c +0 -41

47 lines not on this page · raw message

===== arch/ia64/mm/discontig.c 1.18 vs edited =====

arch/ia64/mm/discontig.c +48 -23

122 lines not on this page · raw message

===== include/asm-ia64/smp.h 1.18 vs edited =====

include/asm-ia64/smp.h +1 -0
@@ -126,6 +126,7 @@
 #else
 
 #define cpu_logical_id(cpuid)		0
+#define cpu_physical_id(i)	((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff)
 
 #endif /* CONFIG_SMP */
 #endif /* _ASM_IA64_SMP_H */

===== include/asm-ia64/sn/sn_cpuid.h 1.10 vs edited =====

include/asm-ia64/sn/sn_cpuid.h +0 -4
@@ -83,10 +83,6 @@
  *
  */
 
-#ifndef CONFIG_SMP
-#define cpu_physical_id(cpuid)			((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff)
-#endif
-
 /*
  * macros for some of these exist in sn/addrs.h & sn/arch.h, etc. However, 
  * trying #include these files here causes circular dependencies.
#1 lore raw
Quoted 22 lines · Jesse Barnes

Today both Christoph and Alex mentioned that they thought this patch would be nice to have in the tree. It allows a generic kernel to build and run when CONFIG_SMP=n. I'd still like feedback about the per-cpu stuff though, in particular, this

+#ifdef CONFIG_SMP

        /* Set the node_data pointer for each per-cpu struct */
        for (cpu = 0; cpu < NR_CPUS; cpu++) {
                node = node_cpuid[cpu].nid;
                per_cpu(cpu_info, cpu).node_data =

mem_data[node].node_data; }

(quoted diff) +6 -0
+#else
+       {
+               struct cpuinfo_ia64 *cpu0_cpu_info;
+               cpu = 0;
+               node = node_cpuid[cpu].nid;
+               cpu0_cpu_info = (struct cpuinfo_ia64

*)(__phys_per_cpu_start + + ((char
*)&per_cpu__cpu_info - __per_cpu_start)); +
cpu0_cpu_info->node_data = mem_data[node].node_data; + }
+#endif /* CONFIG_SMP */

Quoted 5 lines

is really ugly. Maybe I should take this opportunity to convert the early memory allocation code to using the bootmem allocator instead of backdooring it via find_pernode_space()? I think that would mean we could share more code between the contig and discontigmem cases, but we'd also have to be careful to avoid cacheline aliasing.

The patch I posted here was incomplete (missing numa.c file). This new one fixes the CONFIG_NUMA=n case too, but has led me to conclude that the whole thing is a big mess. Our CONFIG_* variables aren't named very well and there's a lot of confusion between actual NUMA support routines (e.g. smart page allocation, distance tables, etc.) and simple memory layout information necessary for discontig support on ia64 boxes.

Jesse

# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2004/09/01 11:11:28-07:00 [email protected]
# config fixes
#

# arch/ia64/kernel/numa.c
#   2004/09/01 11:11:18-07:00 [email protected] +57 -0
# 
# include/linux/acpi.h
#   2004/09/01 11:11:18-07:00 [email protected] +4 -0
#   config fixes
# 
# include/asm-ia64/sn/sn_cpuid.h
#   2004/09/01 11:11:18-07:00 [email protected] +0 -4
#   config fixes
# 
# include/asm-ia64/smp.h
#   2004/09/01 11:11:18-07:00 [email protected] +1 -0
#   config fixes
# 
# include/asm-ia64/processor.h
#   2004/09/01 11:11:18-07:00 [email protected] +1 -3
#   config fixes
# 
# include/asm-ia64/numa.h
#   2004/09/01 11:11:18-07:00 [email protected] +1 -8
#   config fixes
# 
# include/asm-ia64/acpi.h
#   2004/09/01 11:11:18-07:00 [email protected] +1 -0
#   config fixes
# 
# drivers/acpi/numa.c
#   2004/09/01 11:11:18-07:00 [email protected] +0 -2
#   config fixes
# 
# drivers/acpi/Kconfig
#   2004/09/01 11:11:18-07:00 [email protected] +0 -1
#   config fixes
# 
# arch/ia64/sn/kernel/setup.c
#   2004/09/01 11:11:18-07:00 [email protected] +1 -0
#   config fixes
# 
# arch/ia64/mm/numa.c
#   2004/09/01 11:11:18-07:00 [email protected] +0 -7
#   config fixes
# 
# arch/ia64/mm/discontig.c
#   2004/09/01 11:11:18-07:00 [email protected] +62 -31
#   config fixes
# 
# arch/ia64/kernel/smpboot.c
#   2004/09/01 11:11:18-07:00 [email protected] +0 -41
#   config fixes
# 
# arch/ia64/kernel/setup.c
#   2004/09/01 11:11:18-07:00 [email protected] +0 -2
#   config fixes
# 
# arch/ia64/kernel/numa.c
#   2004/09/01 11:11:18-07:00 [email protected] +0 -0
#   BitKeeper file /home/jbarnes/working/linux-2.5-numa/arch/ia64/kernel/numa.c
# 
# arch/ia64/kernel/acpi.c
#   2004/09/01 11:11:18-07:00 [email protected] +21 -3
#   config fixes
# 
# arch/ia64/kernel/Makefile
#   2004/09/01 11:11:18-07:00 [email protected] +1 -0
#   config fixes
# 
# arch/ia64/Kconfig
#   2004/09/01 11:11:18-07:00 [email protected] +0 -2
#   config fixes
# 
diff -Nru a/arch/ia64/Kconfig b/arch/ia64/Kconfig
--- a/arch/ia64/Kconfig	2004-09-01 11:12:45 -07:00
+++ b/arch/ia64/Kconfig	2004-09-01 11:12:45 -07:00
@@ -44,8 +44,6 @@

config IA64_GENERIC
bool "generic"
- select NUMA
- select ACPI_NUMA
select VIRTUAL_MEM_MAP
select DISCONTIGMEM
help

arch/ia64/kernel/Makefile +1 -0
diff -Nru a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
@@ -15,6 +15,7 @@
 obj-$(CONFIG_IOSAPIC)		+= iosapic.o
 obj-$(CONFIG_MODULES)		+= module.o
 obj-$(CONFIG_SMP)		+= smp.o smpboot.o
+obj-$(CONFIG_NUMA)		+= numa.o
 obj-$(CONFIG_PERFMON)		+= perfmon_default_smpl.o
 obj-$(CONFIG_IA64_CYCLONE)	+= cyclone.o
 
arch/ia64/kernel/acpi.c +21 -3
diff -Nru a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
@@ -359,6 +359,17 @@
 /* maps to convert between proximity domain and logical node ID */
 int __initdata pxm_to_nid_map[MAX_PXM_DOMAINS];
 int __initdata nid_to_pxm_map[MAX_NUMNODES];
+
+/*
+ * The following structures are usually initialized by ACPI or
+ * similar mechanisms and describe the NUMA characteristics of the machine.
+ */
+int num_node_memblks;
+struct node_memblk_s node_memblk[NR_NODE_MEMBLKS];
+struct node_cpuid_s node_cpuid[NR_CPUS];
+
+#ifdef CONFIG_NUMA
+
 static struct acpi_table_slit __initdata *slit_table;
 
 /*
@@ -380,6 +391,7 @@
 	}
 	slit_table = slit;
 }
+#endif
 
 void __init
 acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa)
@@ -434,7 +446,10 @@
 void __init
 acpi_numa_arch_fixup (void)
 {
-	int i, j, node_from, node_to;
+	int i, j;
+#ifdef CONFIG_NUMA
+	int node_from, node_to;
+#endif
 
 	/* If there's no SRAT, fix the phys_id */
 	if (srat_num_cpus == 0) {
@@ -475,7 +490,7 @@
 
 	printk(KERN_INFO "Number of logical nodes in system = %d\n", numnodes);
 	printk(KERN_INFO "Number of memory chunks in system = %d\n", num_node_memblks);
-
+#ifdef CONFIG_NUMA
 	if (!slit_table) return;
 	memset(numa_slit, -1, sizeof(numa_slit));
 	for (i=0; i<slit_table->localities; i++) {
@@ -490,6 +505,7 @@
 				slit_table->entry[i*slit_table->localities + j];
 		}
 	}
+#endif
 
 #ifdef SLIT_DEBUG
 	printk("ACPI 2.0 SLIT locality table:\n");
@@ -624,8 +640,10 @@
 			if (smp_boot_data.cpu_phys_id[cpu] != hard_smp_processor_id())
 				node_cpuid[i++].phys_id = smp_boot_data.cpu_phys_id[cpu];
 	}
-	build_cpu_to_node_map();
 # endif
+#endif
+#ifdef CONFIG_NUMA
+	build_cpu_to_node_map();
 #endif
 	/* Make boot-up look pretty */
 	printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus, total_cpus);
arch/ia64/kernel/numa.c new file +57 -0

57 lines not on this page · raw message

arch/ia64/kernel/setup.c +0 -2
diff -Nru a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
@@ -317,11 +317,9 @@
 	machvec_init(acpi_get_sysname());
 #endif
 
-#ifdef CONFIG_SMP
 	/* If we register an early console, allow CPU 0 to printk */
 	if (!early_console_setup())
 		cpu_set(smp_processor_id(), cpu_online_map);
-#endif
 
 #ifdef CONFIG_ACPI_BOOT
 	/* Initialize the ACPI boot-time table parser */
arch/ia64/kernel/smpboot.c +0 -41

47 lines not on this page · raw message

arch/ia64/mm/discontig.c +62 -31

194 lines not on this page · raw message

arch/ia64/mm/numa.c +0 -7
diff -Nru a/arch/ia64/mm/numa.c b/arch/ia64/mm/numa.c
@@ -24,13 +24,6 @@
 static struct cpu *sysfs_cpus;
 
 /*
- * The following structures are usually initialized by ACPI or
- * similar mechanisms and describe the NUMA characteristics of the machine.
- */
-int num_node_memblks;
-struct node_memblk_s node_memblk[NR_NODE_MEMBLKS];
-struct node_cpuid_s node_cpuid[NR_CPUS];
-/*
  * This is a matrix with "distances" between nodes, they should be
  * proportional to the memory access latency ratios.
  */
arch/ia64/sn/kernel/setup.c +1 -0
diff -Nru a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
@@ -29,6 +29,7 @@
 #include <linux/sched.h>
 #include <linux/root_dev.h>
 
+#include <asm/acpi.h>
 #include <asm/io.h>
 #include <asm/sal.h>
 #include <asm/machvec.h>
drivers/acpi/Kconfig +0 -1
diff -Nru a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
@@ -142,7 +142,6 @@
 config ACPI_NUMA
 	bool "NUMA support"
 	depends on ACPI_INTERPRETER
-	depends on NUMA
 	depends on IA64
 	default y if IA64_GENERIC || IA64_SGI_SN2
 
drivers/acpi/numa.c +0 -2
diff -Nru a/drivers/acpi/numa.c b/drivers/acpi/numa.c
@@ -95,9 +95,7 @@
 	localities = (u32) slit->localities;
 
 	printk(KERN_INFO PREFIX "SLIT localities %ux%u\n", localities, localities);
-
 	acpi_numa_slit_init(slit);
-
 	return 0;
 }
 
include/asm-ia64/acpi.h +1 -0
diff -Nru a/include/asm-ia64/acpi.h b/include/asm-ia64/acpi.h
@@ -30,6 +30,7 @@
 
 #ifdef __KERNEL__
 
+#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/numa.h>
 #include <asm/system.h>
include/asm-ia64/numa.h +1 -8
diff -Nru a/include/asm-ia64/numa.h b/include/asm-ia64/numa.h
@@ -12,9 +12,6 @@
 #define _ASM_IA64_NUMA_H
 
 #include <linux/config.h>
-
-#ifdef CONFIG_NUMA
-
 #include <linux/cache.h>
 #include <linux/cpumask.h>
 #include <linux/numa.h>
@@ -58,17 +55,13 @@
  * proportional to the memory access latency ratios.
  */
 
+#ifdef CONFIG_NUMA
 extern u8 numa_slit[MAX_NUMNODES * MAX_NUMNODES];
 #define node_distance(from,to) (numa_slit[(from) * numnodes + (to)])
-
 extern int paddr_to_nid(unsigned long paddr);
-
 #define local_nodeid (cpu_to_node_map[smp_processor_id()])
-
 #else /* !CONFIG_NUMA */
-
 #define paddr_to_nid(addr)	0
-
 #endif /* CONFIG_NUMA */
 
 #endif /* _ASM_IA64_NUMA_H */
include/asm-ia64/processor.h +1 -3
diff -Nru a/include/asm-ia64/processor.h b/include/asm-ia64/processor.h
@@ -88,9 +88,7 @@
 #include <asm/rse.h>
 #include <asm/unwind.h>
 #include <asm/atomic.h>
-#ifdef CONFIG_NUMA
 #include <asm/nodedata.h>
-#endif
 
 /* like above but expressed as bitfields for more efficient access: */
 struct ia64_psr {
@@ -168,7 +166,7 @@
 	__u8 archrev;
 	char vendor[16];
 
-#ifdef CONFIG_NUMA
+#ifdef CONFIG_DISCONTIGMEM
 	struct ia64_node_data *node_data;
 #endif
 };
include/asm-ia64/smp.h +1 -0
diff -Nru a/include/asm-ia64/smp.h b/include/asm-ia64/smp.h
@@ -126,6 +126,7 @@
 #else
 
 #define cpu_logical_id(cpuid)		0
+#define cpu_physical_id(i)	((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff)
 
 #endif /* CONFIG_SMP */
 #endif /* _ASM_IA64_SMP_H */
include/asm-ia64/sn/sn_cpuid.h +0 -4
diff -Nru a/include/asm-ia64/sn/sn_cpuid.h b/include/asm-ia64/sn/sn_cpuid.h
@@ -83,10 +83,6 @@
  *
  */
 
-#ifndef CONFIG_SMP
-#define cpu_physical_id(cpuid)			((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff)
-#endif
-
 /*
  * macros for some of these exist in sn/addrs.h & sn/arch.h, etc. However, 
  * trying #include these files here causes circular dependencies.
include/linux/acpi.h +4 -0
diff -Nru a/include/linux/acpi.h b/include/linux/acpi.h
@@ -391,7 +391,11 @@
 void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
 
 /* the following four functions are architecture-dependent */
+#ifdef CONFIG_NUMA
 void acpi_numa_slit_init (struct acpi_table_slit *slit);
+#else
+static inline void acpi_numa_slit_init(struct acpi_table_slit *slit) { }
+#endif
 void acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *pa);
 void acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *ma);
 void acpi_numa_arch_fixup(void);