Re: [patch] 2.3.17-pre1 mem_init [Re: [PATCH] 2.3.15 fancy memory

David Parsons (orc@pell.portland.or.us)
Sat, 4 Sep 1999 13:12:34 -0700 (PDT)


Andrea Arcangeli wrote:
>
> On 30 Aug 1999, david parsons wrote:
>
> >fixed now. This patch should simply work, with no fuss, muss, or
> >bother.
>
> You PAGE_ALIGN the starting address without decreasing the size of the
> area so you may end adding one page of non-memory to the freelist.

Good spotting!

There are some cosmetic things about your patch that I didn't like
(tweaking the output from the memory_region debug printk), so I
modified it slightly:

--- linux-2.3.16p1/arch/i386/mm/init.c.orig Sat Sep 4 13:01:10 1999
+++ linux-2.3.16p1/arch/i386/mm/init.c Sat Sep 4 13:09:39 1999
@@ -375,7 +375,7 @@
int datapages = 0;
int initpages = 0;
unsigned long tmp;
- unsigned long addr;
+ unsigned long addr, size;
int i, avail;

end_mem &= PAGE_MASK;
@@ -418,11 +418,14 @@
printk("memory region: %luk @ %08lx\n",
((long)(e820.map[i].size)) / 1024,
(long)(e820.map[i].addr) );
- for (addr=PAGE_ALIGN(((long)(e820.map[i].addr)))+PAGE_OFFSET,
- tmp = 0;
- tmp < (unsigned long)(e820.map[i].size);
- tmp += PAGE_SIZE,
- addr += PAGE_SIZE) {
+
+ /* honour page alignment */
+ addr = e820.map[i].addr;
+ size = e820.map[i].size - (PAGE_ALIGN(addr) - addr);
+ size >>= PAGE_SHIFT;
+ addr = PAGE_ALIGN(addr) + PAGE_OFFSET;
+
+ for (; size > 0; size--, addr += PAGE_SIZE) {

/* this little bit of grossness is for dealing
* with memory borrowing for system bookkeeping

--
                      ____
	david parsons \bi/ What, you mean people don't write bioses just
                       \/             to accomodate Linux?  The Nerve!!!

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/