From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 22005 invoked from network); 27 Jun 2000 22:24:49 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 27 Jun 2000 22:24:49 -0000 Received: from piglet.twiddle.net (piglet.twiddle.net [207.104.6.26]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id SAA03870 for ; Tue, 27 Jun 2000 18:24:48 -0400 Received: (from rth@localhost) by piglet.twiddle.net (8.9.3/8.9.3) id PAA02259; Tue, 27 Jun 2000 15:24:45 -0700 Date: Tue, 27 Jun 2000 15:24:45 -0700 From: Richard Henderson To: Andrea Arcangeli Cc: axp-list@redhat.com, Kernel Mailing List Subject: Re: Linux-2.4.0-test2 Message-ID: <20000627152445.A2252@twiddle.net> References: <20000625092755.A2354@twiddle.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="X1bOJ3K7DJ5YkBrT" X-Mailer: Mutt 1.0pre3us In-Reply-To: --X1bOJ3K7DJ5YkBrT Content-Type: text/plain; charset=us-ascii On Sun, Jun 25, 2000 at 07:35:19PM +0200, Andrea Arcangeli wrote: > Exactly. We originally tried to reuse such memory (the one reported as > real memory) but it caused my machine to hang at boot. Strange thing is > that 2.2.x seems to reuse the memory before the kernel too. I've just tried my recently posted patch on the ds20 and it worked just fine. That makes 5 machines total, all with different memory configurations and representing all the different boot loaders. Give it a try on your machine and see what happens. r~ --X1bOJ3K7DJ5YkBrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=d-2402-memory --- arch/alpha/kernel/setup.c.orig Sat Jun 24 13:06:24 2000 +++ arch/alpha/kernel/setup.c Sun Jun 25 13:04:00 2000 @@ -246,11 +246,12 @@ get_mem_size_limit(char *s) } static void __init -setup_memory(void * kernel_end) +setup_memory(void *kernel_end) { struct memclust_struct * cluster; struct memdesc_struct * memdesc; - unsigned long start_pfn, bootmap_size, bootmap_pages, bootmap_start; + unsigned long start_kernel_pfn, end_kernel_pfn; + unsigned long bootmap_size, bootmap_pages, bootmap_start; unsigned long start, end; int i; @@ -282,12 +283,13 @@ setup_memory(void * kernel_end) max_low_pfn = mem_size_limit; } - /* Find the end of the memory used by the kernel. */ - start_pfn = PFN_UP(virt_to_phys(kernel_end)); + /* Find the bounds of kernel memory. */ + start_kernel_pfn = PFN_DOWN(KERNEL_START_PHYS); + end_kernel_pfn = PFN_UP(virt_to_phys(kernel_end)); bootmap_start = -1; try_again: - if (max_low_pfn <= start_pfn) + if (max_low_pfn <= end_kernel_pfn) panic("not enough memory to boot"); /* We need to know how many physically contiguous pages @@ -301,14 +303,19 @@ setup_memory(void * kernel_end) start = cluster->start_pfn; end = start + cluster->numpages; - if (end <= start_pfn) - continue; if (start >= max_low_pfn) continue; - if (start < start_pfn) - start = start_pfn; if (end > max_low_pfn) end = max_low_pfn; + if (start < start_kernel_pfn) { + if (end > end_kernel_pfn + && end - end_kernel_pfn >= bootmap_pages) { + bootmap_start = end_kernel_pfn; + break; + } else if (end > start_kernel_pfn) + end = start_kernel_pfn; + } else if (start < end_kernel_pfn) + start = end_kernel_pfn; if (end - start >= bootmap_pages) { bootmap_start = start; break; @@ -329,22 +336,28 @@ setup_memory(void * kernel_end) continue; start = cluster->start_pfn; - if (start < start_pfn) - start = start_pfn; - end = cluster->start_pfn + cluster->numpages; + if (start >= max_low_pfn) + continue; if (end > max_low_pfn) end = max_low_pfn; - + if (start < start_kernel_pfn) { + if (end > end_kernel_pfn) { + free_bootmem(PFN_PHYS(start), + (PFN_PHYS(start_kernel_pfn) + - PFN_PHYS(start))); + printk("freeing pages %ld:%ld\n", + start, start_kernel_pfn); + start = end_kernel_pfn; + } else if (end > start_kernel_pfn) + end = start_kernel_pfn; + } else if (start < end_kernel_pfn) + start = end_kernel_pfn; if (start >= end) continue; - start = PFN_PHYS(start); - end = PFN_PHYS(end); - - free_bootmem(start, end - start); - printk("freeing pages %ld:%ld\n", - PFN_UP(start), PFN_DOWN(end)); + free_bootmem(PFN_PHYS(start), PFN_PHYS(end) - PFN_PHYS(start)); + printk("freeing pages %ld:%ld\n", start, end); } /* Reserve the bootmap memory. */ @@ -461,11 +474,12 @@ void __init unregister_srm_console(void) void __init setup_arch(char **cmdline_p) { + extern char _end[]; + struct alpha_machine_vector *vec = NULL; struct percpu_struct *cpu; char *type_name, *var_name, *p; - extern char _end; - void * kernel_end = &_end; /* end of kernel */ + void *kernel_end = _end; /* end of kernel */ /* * Let vmlinux.lds know where to put the kernel start. --X1bOJ3K7DJ5YkBrT--