Skip to contentSkip to conversation

New DISCONTIG patch

Linux-ia64 Jack Steiner 1 participant 1 message May 6, 2003

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

Attached is a new discontig patch. I would appreciate feedback on these changes & whether you see problems. Assuming there are no major issues, I'll move the patch to 2.5.

The patch is based on 2.4.20 and builds on the discontig-2.4.20-030304.patch from kimi. Apply the patch to a vanilla 2.4.20+mosberger tree.

The code boots/runs on the following hardware configurations:
- SGI SN2 platform
- DIG SP kernel
- DIG MP kernel using phys memmap
- DIG MP kernel with a hack to force it to use virt memmap
- DIG MP kernel with CONFIG_NUMA & CONFIG_DISCONTIGMEM enabled:
- boots using phy memmap
- boots with hack to force it to use virt memmap

The patch contains a number of improvements to the previous patches. Primarily, it shrinks the size & complexity of the discontig patch by using the VIRTUAL_MEMMAP code that is in 2.4.20.

Note that discontig_paging_init() is gone & that a lot of DISCONTIG code has been removed from other places except the for code that initializes the bootmem allocator.

The files that are the most interesting are:
arch/ia64/mm/discontig.c - paging_init is gone arch/ia64/mm/init.c - DISCONTIG uses VIRT_MEMMAP
- no #ifdef CONFIG_DISCONTIG
include/asm-ia64/pgtable.h - no #ifdef CONFIG_DISCONTIG include/asm-ia64/mmzone.h - add SGI & GENERIC platforms & remove
most of the ugly macros

I have run a few AIM7 benchmarks to compare the performance of the old patch that uses region 7 for page-structs vs this new patch that uses the virtual memmap in region 5. So far, I have not seen any significant differences. AIM7 shows a max of 0.5% degradation in thruput. Cpu time increases 0-2% depending on the number of users.

Next, I am working on making the patch work on GENERIC kernels but have not yet completed the work. I think this patch is close....

Notes:
- discontig_paging_init is completely gone. I use the paging_init() code that is in arch/ia64/mm/init.c There are a few changes in paging_init() but I believe it will work on all platforms (needs to be verified though).

- there were a few features in the original discontig patch that were missing in the latest discontig patch. A few of these have been added again. They are important on the SGI platform & I suspect they are important on other platforms too. I think that some of these features were implemented differently in 2.5 & were just dropped to simplify the backport of discontig to 2.4.20.
- node local cpu_data structures & mmu_gathers. Possible performance improvement but done primarily to reduce the amount of static data. This could be split into a separate patch.

---------------------------------------
discontig_2.4.20-20030502

arch/ia64/config.in +4 -0
diff -Naur linux_base/arch/ia64/config.in linux/arch/ia64/config.in
@@ -66,6 +66,10 @@
 fi
 
 if [ "$CONFIG_IA64_GENERIC" = "y" -o "$CONFIG_IA64_DIG" = "y" -o "$CONFIG_IA64_HP_ZX1" = "y" ]; then
+	bool '  Enable NUMA support' CONFIG_NUMA
+	if [ "$CONFIG_NUMA" = "y" ]; then
+	  define_bool CONFIG_DISCONTIGMEM y
+	fi
 	bool '  Enable IA-64 Machine Check Abort' CONFIG_IA64_MCA
 	define_bool CONFIG_PM y
 fi
arch/ia64/kernel/acpi.c +211 -7

259 lines not on this page · raw message

arch/ia64/kernel/setup.c +98 -31

221 lines not on this page · raw message

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

73 lines not on this page · raw message

arch/ia64/mm/Makefile +2 -0
diff -Naur linux_base/arch/ia64/mm/Makefile linux/arch/ia64/mm/Makefile
@@ -12,5 +12,7 @@
 export-objs := init.o
 
 obj-y	 := init.o fault.o tlb.o extable.o
+obj-$(CONFIG_NUMA) += numa.o
+obj-$(CONFIG_DISCONTIGMEM) += discontig.o
 
 include $(TOPDIR)/Rules.make
arch/ia64/mm/discontig.c +280 -0

280 lines not on this page · raw message

arch/ia64/mm/init.c +127 -114

382 lines not on this page · raw message

arch/ia64/mm/numa.c +46 -0

46 lines not on this page · raw message

drivers/acpi/Config.in +6 -0
diff -Naur linux_base/drivers/acpi/Config.in linux/drivers/acpi/Config.in
@@ -36,6 +36,9 @@
     tristate     '  Fan'		CONFIG_ACPI_FAN
     tristate     '  Processor'		CONFIG_ACPI_PROCESSOR
     dep_tristate '  Thermal Zone' CONFIG_ACPI_THERMAL $CONFIG_ACPI_PROCESSOR
+    if [ "$CONFIG_NUMA" = "y" ]; then
+      bool	 '  NUMA support' 	CONFIG_ACPI_NUMA
+    fi
     bool         '  Debug Statements' 	CONFIG_ACPI_DEBUG
   fi
 
@@ -123,4 +126,7 @@
     endmenu
   fi
 
+  if [ "$CONFIG_NUMA" = "y" ]; then
+    bool	 '  NUMA support'	CONFIG_ACPI_NUMA
+  fi
 fi
drivers/acpi/Makefile +1 -0
diff -Naur linux_base/drivers/acpi/Makefile linux/drivers/acpi/Makefile
@@ -51,5 +51,6 @@
   obj-$(CONFIG_ACPI_THERMAL)	+= thermal.o
   obj-$(CONFIG_ACPI_SYSTEM)	+= system.o
 endif
+obj-$(CONFIG_ACPI_NUMA)         += numa.o
 
 include $(TOPDIR)/Rules.make
drivers/acpi/numa.c +188 -0

188 lines not on this page · raw message

drivers/acpi/tables.c +23 -9
diff -Naur linux_base/drivers/acpi/tables.c linux/drivers/acpi/tables.c
@@ -224,11 +224,13 @@
 
 
 int __init
-acpi_table_parse_madt (
+acpi_table_parse_madt_family (
 	enum acpi_table_id	id,
+	unsigned long		madt_size,
+	int			entry_id,
 	acpi_madt_entry_handler	handler)
 {
-	struct acpi_table_madt	*madt = NULL;
+	void			*madt = NULL;
 	acpi_table_entry_header	*entry = NULL;
 	unsigned long		count = 0;
 	unsigned long		madt_end = 0;
@@ -240,19 +242,21 @@
 	/* Locate the MADT (if exists). There should only be one. */
 
 	for (i = 0; i < sdt.count; i++) {
-		if (sdt.entry[i].id != ACPI_APIC)
+		if (sdt.entry[i].id != id)
 			continue;
-		madt = (struct acpi_table_madt *)
+		madt = (void *)
 			__acpi_map_table(sdt.entry[i].pa, sdt.entry[i].size);
 		if (!madt) {
-			printk(KERN_WARNING PREFIX "Unable to map MADT\n");
+			printk(KERN_WARNING PREFIX "Unable to map %s\n",
+			       acpi_table_signatures[id]);
 			return -ENODEV;
 		}
 		break;
 	}
 
 	if (!madt) {
-		printk(KERN_WARNING PREFIX "MADT not present\n");
+		printk(KERN_WARNING PREFIX "%s not present\n",
+		       acpi_table_signatures[id]);
 		return -ENODEV;
 	}
 
@@ -261,21 +265,31 @@
 	/* Parse all entries looking for a match. */
 
 	entry = (acpi_table_entry_header *)
-		((unsigned long) madt + sizeof(struct acpi_table_madt));
+		((unsigned long) madt + madt_size);
 
 	while (((unsigned long) entry) < madt_end) {
-		if (entry->type = id) {
+		if (entry->type = entry_id) {
 			count++;
 			handler(entry);
 		}
 		entry = (acpi_table_entry_header *)
-			((unsigned long) entry += entry->length);
+			((unsigned long) entry + entry->length);
 	}
 
 	return count;
 }
 
 
+int __init
+acpi_table_parse_madt (
+	enum acpi_madt_entry_id	id,
+	acpi_madt_entry_handler	handler)
+{
+	return acpi_table_parse_madt_family(ACPI_APIC, sizeof(struct acpi_table_madt),
+					    id, handler);
+}
+
+
 int __init
 acpi_table_parse (
 	enum acpi_table_id	id,
include/asm-generic/tlb.h +6 -1
diff -Naur linux_base/include/asm-generic/tlb.h linux/include/asm-generic/tlb.h
@@ -31,15 +31,20 @@
 	pte_t	ptes[FREE_PTE_NR];
 } mmu_gather_t;
 
+#if defined(CONFIG_NUMA) && defined(CONFIG_IA64)
 /* Users of the generic TLB shootdown code must declare this storage space. */
+#define local_mmu_gathers	local_cpu_data->mmu_gathers
+#else
 extern mmu_gather_t	mmu_gathers[NR_CPUS];
+#define local_mmu_gathers	&mmu_gathers[smp_processor_id()]
+#endif
 
 /* tlb_gather_mmu
  *	Return a pointer to an initialized mmu_gather_t.
  */
 static inline mmu_gather_t *tlb_gather_mmu(struct mm_struct *mm)
 {
-	mmu_gather_t *tlb = &mmu_gathers[smp_processor_id()];
+	mmu_gather_t *tlb = local_mmu_gathers;
 
 	tlb->mm = mm;
 	/* Use fast mode if there is only one user of this mm (this process) */
include/asm-ia64/acpi.h +7 -6
diff -Naur linux_base/include/asm-ia64/acpi.h linux/include/asm-ia64/acpi.h
@@ -97,17 +97,18 @@
 	} while (0)
 
 const char *acpi_get_sysname (void);
-int acpi_boot_init (char *cdline);
 int acpi_request_vector (u32 int_type);
 int acpi_get_prt (struct pci_vector_struct **vectors, int *count);
 int acpi_get_interrupt_model (int *type);
 int acpi_irq_to_vector (u32 irq);
 
-#ifdef CONFIG_DISCONTIGMEM
-#define NODE_ARRAY_INDEX(x)	((x) / 8)	/* 8 bits/char */
-#define NODE_ARRAY_OFFSET(x)	((x) % 8)	/* 8 bits/char */
-#define MAX_PXM_DOMAINS		(256)
-#endif /* CONFIG_DISCONTIGMEM */
+#ifdef CONFIG_ACPI_NUMA
+#include <asm/numa.h>
+/* Proximity bitmap length; _PXM is at most 255 (8 bit)*/
+#define MAX_PXM_DOMAINS (256)
+extern int __initdata pxm_to_nid_map[MAX_PXM_DOMAINS];
+extern int __initdata nid_to_pxm_map[NR_NODES];
+#endif
 
 #endif /*__KERNEL__*/
 
include/asm-ia64/mmzone.h +65 -0

65 lines not on this page · raw message

include/asm-ia64/nodedata.h +67 -0

67 lines not on this page · raw message

include/asm-ia64/numa.h +84 -0

84 lines not on this page · raw message

include/asm-ia64/numnodes.h +7 -0
@@ -0,0 +1,7 @@
+#ifndef _ASM_MAX_NUMNODES_H
+#define _ASM_MAX_NUMNODES_H
+
+#include <asm/mmzone.h>
+#define MAX_NUMNODES	NR_NODES
+
+#endif /* _ASM_MAX_NUMNODES_H */
include/asm-ia64/page.h +0 -11
diff -Naur linux_base/include/asm-ia64/page.h linux/include/asm-ia64/page.h
@@ -52,19 +52,8 @@
  */
 #define MAP_NR_DENSE(addr)	(((unsigned long) (addr) - PAGE_OFFSET) >> PAGE_SHIFT)
 
-#ifdef CONFIG_IA64_GENERIC
-# include <asm/machvec.h>
-# define virt_to_page(kaddr)	(mem_map + platform_map_nr(kaddr))
-# define page_to_phys(page)	((page - mem_map) << PAGE_SHIFT)
-#elif defined (CONFIG_IA64_SGI_SN1)
-# ifndef CONFIG_DISCONTIGMEM
-#  define virt_to_page(kaddr)	(mem_map + MAP_NR_DENSE(kaddr))
-#  define page_to_phys(page)	XXX fix me
-# endif
-#else
 # define virt_to_page(kaddr)	(mem_map + MAP_NR_DENSE(kaddr))
 # define page_to_phys(page)	((page - mem_map) << PAGE_SHIFT)
-#endif
 
 struct page;
 extern int ia64_page_valid (struct page *);
include/asm-ia64/pgtable.h +0 -1
diff -Naur linux_base/include/asm-ia64/pgtable.h linux/include/asm-ia64/pgtable.h
@@ -163,7 +163,6 @@
 	return (addr & (local_cpu_data->unimpl_pa_mask)) = 0;
 }
 
-#ifndef CONFIG_DISCONTIGMEM
 /*
  * kern_addr_valid(ADDR) tests if ADDR is pointing to valid kernel
  * memory.  For the return value to be meaningful, ADDR must be >@@ -179,7 +178,6 @@

*/
#define kern_addr_valid(addr) (1)

-#endif

/*
* Now come the defines and routines to manage and access the three-level
@@ -227,10 +225,8 @@
#define pte_none(pte) (!pte_val(pte))
#define pte_present(pte) (pte_val(pte) & (_PAGE_P | _PAGE_PROTNONE))
#define pte_clear(pte) (pte_val(*(pte)) = 0UL)
-#ifndef CONFIG_DISCONTIGMEM
/* pte_page() returns the "struct page *" corresponding to the PTE: */
#define pte_page(pte) (mem_map + (unsigned long) ((pte_val(pte) & _PFN_MASK) >> PAGE_SHIFT))
-#endif

#define pmd_none(pmd) (!pmd_val(pmd))
#define pmd_bad(pmd) (!ia64_phys_addr_valid(pmd_val(pmd)))
@@ -430,7 +426,8 @@
* for zero-mapped memory areas etc..
*/
extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)];
-#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) +extern struct page *zero_page_memmap_ptr;
+#define ZERO_PAGE(vaddr) (zero_page_memmap_ptr)

/* We provide our own get_unmapped_area to cope with VA holes for userland */ #define HAVE_ARCH_UNMAPPED_AREA

include/asm-ia64/processor.h +10 -4
diff -Naur linux_base/include/asm-ia64/processor.h linux/include/asm-ia64/processor.h
@@ -87,6 +87,9 @@
 #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 {
@@ -187,9 +190,12 @@
 	} ipi;
 #endif
 #ifdef CONFIG_NUMA
-	void *node_directory;
-	int numa_node_id;
+	void* mmu_gathers;
+	struct ia64_node_data *node_data;
+	int nodeid;
 	struct cpuinfo_ia64 *cpu_data[NR_CPUS];
+	/* mod this number by numnodes to get the node to use for this pagecache allocation */
+	unsigned int page_cache_nodeval; 
 #endif
 	/* Platform specific word.  MUST BE LAST IN STRUCT */
 	__u64 platform_specific;
@@ -213,9 +219,9 @@
  */
 #ifdef CONFIG_NUMA
 # define cpu_data(cpu)		local_cpu_data->cpu_data[cpu]
-# define numa_node_id()		(local_cpu_data->numa_node_id)
+# define numa_node_id()		(local_cpu_data->nodeid)
 #else
-  extern struct cpuinfo_ia64 _cpu_data[NR_CPUS];
+  extern struct cpuinfo_ia64	_cpu_data[NR_CPUS];
 # define cpu_data(cpu)		(&_cpu_data[cpu])
 #endif
 
include/asm-ia64/smp.h +1 -0
diff -Naur linux_base/include/asm-ia64/smp.h linux/include/asm-ia64/smp.h
@@ -122,6 +122,7 @@
 extern int smp_call_function_single (int cpuid, void (*func) (void *info), void *info,
 				     int retry, int wait);
 
+extern void smp_build_cpu_map(void);
 
 #endif /* CONFIG_SMP */
 #endif /* _ASM_IA64_SMP_H */
include/asm-ia64/topology.h +63 -0

63 lines not on this page · raw message

include/linux/acpi.h +8 -0
diff -Naur linux_base/include/linux/acpi.h linux/include/linux/acpi.h
@@ -344,6 +344,14 @@
 void acpi_table_print (struct acpi_table_header *, unsigned long);
 void acpi_table_print_madt_entry (acpi_table_entry_header *);
 
+#ifdef CONFIG_ACPI_NUMA
+int __init acpi_numa_init(void);
+void __init acpi_numa_slit_init (struct acpi_table_slit *);
+void __init acpi_numa_processor_affinity_init (struct acpi_table_processor_affinity *);
+void __init acpi_numa_memory_affinity_init (struct acpi_table_memory_affinity *);
+void __init acpi_numa_arch_fixup(void);
+#endif
+
 #endif /*CONFIG_ACPI_BOOT*/
 
 
include/linux/mmzone.h +21 -3
diff -Naur linux_base/include/linux/mmzone.h linux/include/linux/mmzone.h
@@ -8,6 +8,12 @@
 #include <linux/spinlock.h>
 #include <linux/list.h>
 #include <linux/wait.h>
+#ifdef CONFIG_DISCONTIGMEM
+#include <asm/numnodes.h>
+#endif
+#ifndef MAX_NUMNODES
+#define MAX_NUMNODES 1
+#endif
 
 /*
  * Free memory management - zoned buddy allocator.
@@ -110,7 +116,7 @@
  * footprint of this construct is very small.
  */
 typedef struct zonelist_struct {
-	zone_t * zones [MAX_NR_ZONES+1]; // NULL delimited
+	zone_t * zones [MAX_NUMNODES*MAX_NR_ZONES+1]; // NULL delimited
 } zonelist_t;
 
 #define GFP_ZONEMASK	0x0f
@@ -144,8 +150,8 @@
 extern int numnodes;
 extern pg_data_t *pgdat_list;
 
-#define memclass(pgzone, classzone)	(((pgzone)->zone_pgdat = (classzone)->zone_pgdat) \
-			&& ((pgzone) <= (classzone)))
+#define memclass(pgzone, classzone)            (((pgzone) - (pgzone)->zone_pgdat->node_zones) <= \
+((classzone) - (classzone)->zone_pgdat->node_zones))
 
 /*
  * The following two are not meant for general usage. They are here as
@@ -212,6 +218,18 @@
 #define for_each_zone(zone) \
 	for(zone = pgdat_list->node_zones; zone; zone = next_zone(zone))
 
+#ifdef CONFIG_NUMA
+#define MAX_NR_MEMBLKS  BITS_PER_LONG /* Max number of Memory Blocks */
+#include <asm/topology.h>
+#else /* !CONFIG_NUMA */
+#define MAX_NR_MEMBLKS  1
+#endif /* CONFIG_NUMA */
+
+/* Returns the number of the current Node. */
+
+#ifndef CONFIG_NUMA
+#define numa_node_id()          (__cpu_to_node(smp_processor_id()))
+#endif
 
 #ifndef CONFIG_DISCONTIGMEM
 
init/main.c +2 -0
diff -Naur linux_base/init/main.c linux/init/main.c
@@ -290,6 +290,7 @@
 
 
 extern void setup_arch(char **);
+extern void __init build_all_zonelists(void);
 extern void cpu_idle(void);
 
 unsigned long wait_init_idle;
@@ -360,6 +361,7 @@
 	lock_kernel();
 	printk(linux_banner);
 	setup_arch(&command_line);
+	build_all_zonelists();
 	printk("Kernel command line: %s\n", saved_command_line);
 	parse_options(command_line);
 	trap_init();
mm/page_alloc.c +56 -29

120 lines not on this page · raw message

Signature · 3 lines
Thanks

Jack Steiner    (651-683-5302)   (vnet 233-5302)      [email protected]