diff -u -X /home/tbird/dontdiff -pruN linux-2.4.20/arch/arm/config.in celinux-040503/arch/arm/config.in
--- linux-2.4.20/arch/arm/config.in	2002-11-28 15:53:09.000000000 -0800
+++ celinux-040503/arch/arm/config.in	2004-05-03 04:23:48.000000000 -0700
@@ -629,9 +1015,31 @@ source drivers/misc/Config.in
 
 source drivers/usb/Config.in
 
-source net/bluetooth/Config.in
+source drivers/usb/device/Config.in
+
+if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
+      source drivers/mmc/Config.in
+fi
+
+mainmenu_option next_comment
+
+comment 'Kernel tracing'
+tristate 'Kernel events tracing support' CONFIG_TRACE
+dep_bool '  Trace init process' CONFIG_TRACE_BOOT $CONFIG_TRACE
+endmenu
 
 mainmenu_option next_comment
+
+comment 'Montavista System Tuning Tools'
+bool 'Kernel Function Instrumentation' CONFIG_KFI
+dep_bool '  Static Instrumentation Configs' CONFIG_KFI_STATIC_RUN $CONFIG_KFI
+bool  'Interrupt Latency Instrumentation' CONFIG_ILATENCY
+dep_bool 'Preemption Latency Instrumentation' CONFIG_PREEMPT_TIMES $CONFIG_PREEMPT
+bool  'Memory Accounting Bitmap Instrumentation' CONFIG_MEMORY_ACCOUNTING
+endmenu
+
+mainmenu_option next_comment
+
 comment 'Kernel hacking'
 
 # RMK wants arm kernels compiled with frame pointers so hardwire this to y.  If
diff -u -X /home/tbird/dontdiff -pruN linux-2.4.20/arch/mips/config-shared.in celinux-040503/arch/mips/config-shared.in
--- linux-2.4.20/arch/mips/config-shared.in	2002-11-28 15:53:09.000000000 -0800
+++ celinux-040503/arch/mips/config-shared.in	2004-05-03 04:23:48.000000000 -0700
@@ -777,23 +1257,37 @@ if [ "$CONFIG_SOUND" != "n" ]; then
 fi
 endmenu
 
-if [ "$CONFIG_SGI_IP22" = "y" ]; then
-   source drivers/sgi/Config.in
-fi
-
 source drivers/usb/Config.in
 
 source net/bluetooth/Config.in
 
 mainmenu_option next_comment
+comment 'Kernel tracing'
+tristate 'Kernel events tracing support' CONFIG_TRACE
+dep_bool '  Trace init process' CONFIG_TRACE_BOOT $CONFIG_TRACE
+endmenu
+
+
+mainmenu_option next_comment
+
+comment 'Montavista System Tuning Tools'
+bool 'Kernel Function Instrumentation' CONFIG_KFI
+dep_bool '  Static Instrumentation Configs' CONFIG_KFI_STATIC_RUN $CONFIG_KFI
+bool  'Interrupt Latency Instrumentation' CONFIG_ILATENCY
+dep_bool 'Preemption Latency Instrumentation' CONFIG_PREEMPT_TIMES $CONFIG_PREEMPT
+bool  'Memory Accounting Bitmap Instrumentation' CONFIG_MEMORY_ACCOUNTING
+endmenu
+
+mainmenu_option next_comment
 comment 'Kernel hacking'
 
 bool 'Are you using a crosscompiler' CONFIG_CROSSCOMPILE
-if [ "$CONFIG_SERIAL" = "y" -o "$CONFIG_AU1000_UART" = "y" ]; then
-   bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG
-   dep_bool 'Console output to GDB' CONFIG_GDB_CONSOLE $CONFIG_REMOTE_DEBUG
+bool 'Enable run-time debugging' CONFIG_RUNTIME_DEBUG
+bool 'Remote GDB kernel debugging' CONFIG_KGDB
+dep_bool '  Console output to GDB' CONFIG_GDB_CONSOLE $CONFIG_KGDB
+if [ "$CONFIG_SIBYTE_SB1xxx_SOC" = "y" ]; then
+   bool 'Compile for Corelis Debugger' CONFIG_SB1XXX_CORELIS
 fi
-bool 'Enable run-time debugging' CONFIG_DEBUG
 bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
 if [ "$CONFIG_SMP" != "y" ]; then
    bool 'Run uncached' CONFIG_MIPS_UNCACHED
diff -u -X /home/tbird/dontdiff -pruN linux-2.4.20/fs/proc/array.c celinux-040503/fs/proc/array.c
--- linux-2.4.20/fs/proc/array.c	2002-08-02 17:39:45.000000000 -0700
+++ celinux-040503/fs/proc/array.c	2004-05-03 04:23:43.000000000 -0700
@@ -530,13 +531,23 @@ int proc_pid_statm(struct task_struct *t
  * f_pos = (number of the vma in the task->mm->mmap list) * PAGE_SIZE
  *         + (index into the line)
  */
+#ifdef CONFIG_MEMORY_ACCOUNTING
+extern int count_physical_pages(struct mm_struct * mm, struct vm_area_struct * vma);
+/* for systems with sizeof(void*) == 4: */
+#define MAPS_LINE_FORMAT4	  "%08lx-%08lx %s %08lx %s %lu %-6d"
+#define MAPS_LINE_MAX4	58 /* sum of 8  1  8  1 4 1 8 1 5 1 10 1 6 */
+/* for systems with sizeof(void*) == 8: */
+#define MAPS_LINE_FORMAT8	  "%016lx-%016lx %s %016lx %s %lu %-6d"
+#define MAPS_LINE_MAX8	82 /* sum of 16  1  16  1 4 1 16 1 5 1 10 1 */
+#else
 /* for systems with sizeof(void*) == 4: */
 #define MAPS_LINE_FORMAT4	  "%08lx-%08lx %s %08lx %s %lu"
 #define MAPS_LINE_MAX4	49 /* sum of 8  1  8  1 4 1 8 1 5 1 10 1 */
-
 /* for systems with sizeof(void*) == 8: */
 #define MAPS_LINE_FORMAT8	  "%016lx-%016lx %s %016lx %s %lu"
 #define MAPS_LINE_MAX8	73 /* sum of 16  1  16  1 4 1 16 1 5 1 10 1 */
+#endif /* CONFIG_MEMORY_ACCOUNTING */
+
 
 #define MAPS_LINE_FORMAT	(sizeof(void*) == 4 ? MAPS_LINE_FORMAT4 : MAPS_LINE_FORMAT8)
 #define MAPS_LINE_MAX	(sizeof(void*) == 4 ?  MAPS_LINE_MAX4 :  MAPS_LINE_MAX8)
@@ -574,10 +586,18 @@ static int proc_pid_maps_get_line (char 
 	} else
 		line = buf;
 
+#ifdef CONFIG_MEMORY_ACCOUNTING
+	physical_pages = count_physical_pages(map->vm_mm, map);
+	len = sprintf(line,
+		      MAPS_LINE_FORMAT,
+		      map->vm_start, map->vm_end, str, map->vm_pgoff << PAGE_SHIFT,
+		      kdevname(dev), ino, physical_pages);
+#else
 	len = sprintf(line,
 		      MAPS_LINE_FORMAT,
 		      map->vm_start, map->vm_end, str, map->vm_pgoff << PAGE_SHIFT,
 		      kdevname(dev), ino);
+#endif /* CONFIG_MEMORY_ACCOUNTING */
 
 	if(map->vm_file) {
 		int i;
diff -u -X /home/tbird/dontdiff -pruN linux-2.4.20/fs/proc/proc_misc.c celinux-040503/fs/proc/proc_misc.c
--- linux-2.4.20/fs/proc/proc_misc.c	2002-11-28 15:53:15.000000000 -0800
+++ celinux-040503/fs/proc/proc_misc.c	2004-05-03 04:23:43.000000000 -0700
@@ -36,7 +36,12 @@
 #include <linux/init.h>
 #include <linux/smp_lock.h>
 #include <linux/seq_file.h>
+#include <linux/vmalloc.h>
 
+#ifdef CONFIG_MEMORY_ACCOUNTING
+#include <asm/page.h>
+#include <asm/memory.h>
+#endif
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
 #include <asm/io.h>
@@ -149,12 +189,123 @@ static int uptime_read_proc(char *page, 
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
+#ifdef CONFIG_MEMORY_ACCOUNTING
+/*
+ * We walk all the page structs and translate them to pfns
+ * and then to ptes.  We get the free pages by the page count, count == 0.
+ *
+ * We have an array of unsigned ints of which each bit in an int 
+ * represents one page in memory.
+ *
+ * The pfn is the index into the array, pfn 0 == index 0 (index = pfn / 32).  
+ * We figure out which bit of the unsigned int to set by the following:
+ * bit = pfn % 32, we then set that bit to zero to denote it's free via:
+ * array[index] &= ~(1<<bit);   then we pump the data to /proc 
+ */
+
+#define pfn_to_pte(pfn)	(__pte(pfn << PAGE_SHIFT))
+#define BITS_PER_INT 32
+static int highwater = 0;
+static int lowwater = 0;
+static int mem_acc_debug = 0;
+static int g_read_completed = 0;
+
+static int memmap_read_proc(char *page, char **start, off_t off,
+    int count, int *eof, void *data)
+{
+	unsigned int *bitmap = NULL;
+	pte_t pte;
+	struct page *p, *end;
+	int mark;
+	int len = 0;
+	int free = 0;
+	int total = 0;
+	int index, bit, start_pfn, end_pfn, array_size = 0;
+	int array_bounds, pfn = 0;
+
+	p = NODE_MEM_MAP(node);
+	end = p + NODE_DATA(node)->node_size;
+	end_pfn = (int)page_to_pfn(end);
+	start_pfn = (int)page_to_pfn(p);
+
+	if (bitmap == NULL) {
+		array_size = end_pfn - start_pfn;
+		bitmap = (unsigned int *)kmalloc(array_size / sizeof (int),
+		    GFP_KERNEL);
+		array_bounds = array_size / BITS_PER_INT;
+	}
+
+	/*
+	 * one means used, zero means free, set them all to 1,
+	 * clear them as we find them free.
+	 */
+
+	for (index = 0; index < array_bounds; index++) {
+		bitmap[index] = 0xffffffff;
+	}
+
+	total = free = 0;
+	do {
+		total++;
+		pfn = page_to_pfn(p);
+		if (!PageReserved(p) && page_count(p) == 0 && pfn_valid(pfn)) {
+			index = pfn - start_pfn;
+			bit = index % BITS_PER_INT;
+			index /= BITS_PER_INT;
+			free++;
+			bitmap[index] &= ~(1<<bit);
+		}
+		if (mem_acc_debug) {
+			pte = pfn_to_pte(pfn);
+			index = pfn - start_pfn;
+			bit = index % BITS_PER_INT;
+			index /= BITS_PER_INT;
+			printk("i %d bit %d pfn %d pa 0x%x va 0x%x c %d\n",
+			    index, bit, pfn, pte_val(pte),
+			    __phys_to_virt(pte_val(pte)), page_count(p));
+		}
+		p++;
+	} while (p < end);
+
+	mark = total - free;
+	if (mark < lowwater) {
+		lowwater = mark;
+	}
+	if (mark > highwater) {
+		highwater = mark;
+	}
+	if (off == 0) {
+		g_read_completed = 0;
+		len = sprintf(page,
+		    "High water used pages %d Low water used pages %d\n",
+		       highwater, lowwater);
+	} else if (g_read_completed == array_bounds) {
+		*eof = 1;
+		return 0;
+	}
+
+	for (index = 0; index < array_bounds; index += 8) {
+		len += sprintf(page + len, "%08x%08x%08x%08x%08x%08x%08x%08x\n",
+		    bitmap[index], bitmap[index + 1], bitmap[index + 2],
+		    bitmap[index + 3], bitmap[index + 4], bitmap[index + 5],
+		    bitmap[index + 6], bitmap[index + 7]);
+	}
+	g_read_completed = array_bounds;
+	*start = page;
+	return len;
+}
+#endif
+
+extern atomic_t vm_committed_space;
+
 static int meminfo_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
 {
 	struct sysinfo i;
 	int len;
-	int pg_size ;
+	int pg_size, committed;
+	unsigned long vmtot;
+	struct vmalloc_info vmi;
 
 /*
  * display in kilobytes.
@@ -578,11 +747,24 @@ void __init proc_misc_init(void)
 		{"swaps",	swaps_read_proc},
 		{"iomem",	memory_read_proc},
 		{"execdomains",	execdomains_read_proc},
+#ifdef CONFIG_MEMORY_ACCOUNTING
+		{"memmap",	memmap_read_proc},
+#endif
 		{NULL,}
 	};
 	for (p = simple_ones; p->name; p++)
 		create_proc_read_entry(p->name, 0, NULL, p->read_proc, NULL);
 
+#ifdef CONFIG_MEMORY_ACCOUNTING
+	/*
+	 * get the amount of free pages right here, as this
+	 * should be the lowest amount of allocated pages
+	 * the system ever sees.  After log in there
+	 * should just be more allocated pages.
+	 */
+	lowwater = num_physpages - nr_free_pages();
+#endif
+
 	proc_symlink("mounts", NULL, "self/mounts");
 
 	/* And now for trickier ones */
diff -u -X /home/tbird/dontdiff -pruN linux-2.4.20/mm/vmscan.c celinux-040503/mm/vmscan.c
--- linux-2.4.20/mm/vmscan.c	2002-11-28 15:53:15.000000000 -0800
+++ celinux-040503/mm/vmscan.c	2004-05-03 04:23:47.000000000 -0700
@@ -767,9 +786,95 @@ int kswapd(void *unused)
 static int __init kswapd_init(void)
 {
 	printk("Starting kswapd\n");
+#ifndef CONFIG_EMBEDDED_OOM_KILLER
+	printk("Disabling the Out Of Memory Killer\n");
+#endif
 	swap_setup();
 	kernel_thread(kswapd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGNAL);
 	return 0;
 }
 
+
+#ifdef CONFIG_MEMORY_ACCOUNTING
+
+/* mm->page_table_lock is held. mmap_sem is not held */
+static int 
+count_pmd_pages(struct mm_struct * mm, struct vm_area_struct * vma, 
+	pmd_t *dir, unsigned long address, unsigned long end)
+{
+	pte_t * pte;
+	unsigned long pmd_end;
+	int counted_pages = 0;
+
+	if (pmd_none(*dir))
+		return counted_pages;
+	
+	pte = pte_offset(dir, address);
+	
+	pmd_end = (address + PMD_SIZE) & PMD_MASK;
+	if (end > pmd_end)
+		end = pmd_end;
+
+	do {
+		if (pte_present(*pte)) {
+			struct page *page = pte_page(*pte);
+
+			if (VALID_PAGE(page)) {
+				counted_pages++;
+			}
+		}
+		address += PAGE_SIZE;
+		pte++;
+	} while (address && (address < end));
+	return counted_pages;
+}
+
+/* mm->page_table_lock is held. mmap_sem is not held */
+static int 
+count_pgd_pages(struct mm_struct * mm, struct vm_area_struct * vma, 
+	pgd_t *dir, unsigned long address, unsigned long end)
+{
+	pmd_t * pmd;
+	unsigned long pgd_end;
+	int counted_pages = 0;
+
+	if (pgd_none(*dir))
+		return 0;
+
+	pmd = pmd_offset(dir, address);
+
+	pgd_end = (address + PGDIR_SIZE) & PGDIR_MASK;	
+	if (pgd_end && (end > pgd_end))
+		end = pgd_end;
+	
+	do {
+		counted_pages += count_pmd_pages(mm, vma, pmd, address, end);
+		address = (address + PMD_SIZE) & PMD_MASK;
+		pmd++;
+	} while (address && (address < end));
+	return counted_pages;
+}
+/* mm->page_table_lock is held. mmap_sem is not held */
+int 
+count_physical_pages(struct mm_struct * mm, struct vm_area_struct * vma)
+{
+	pgd_t *pgdir;
+	unsigned long end;
+	unsigned long address;
+	int count = 0;
+
+	spin_lock(&mm->page_table_lock);
+	pgdir = pgd_offset(mm, address);
+
+	end = vma->vm_end;
+	address = vma->vm_start;
+	do {
+		count += count_pgd_pages(mm, vma, pgdir, address, end);
+		address = (address + PGDIR_SIZE) & PGDIR_MASK;
+		pgdir++;
+	} while (address && (address < end));
+	spin_unlock(&mm->page_table_lock);
+	return count;
+}
+#endif /* CONFIG_MEMORY_ACCOUNTING */
 module_init(kswapd_init)
