[Linux-ia64] [PATCH] free_initrd_mem() need to be correct

From: Takanori Kawano <t-kawano_at_ebina.hitachi.co.jp>
Date: 2001-06-28 13:02:48
When I tried to boot kernel using 'mem=512m' option on Bigsur 
with 1GB memory, it failed and displayed the following message.

           .
           .
    Freeing initrd memory: 746KB freed.
    kernel BUG at page_alloc.c:86!

On our investigation, the cause is that:
(1) When 'mem=xxx' is used, it is possible that the page corresponds to
    the memory used by initrd is not made because initrd is loaded into 
    high address region by bootloader.
(2) free_initrd_mem() frees the memory used by initrd even if its 
    corresponding page was not exist.

The following patch corrects this problem.

--- ./arch/ia64/mm/init.c       Thu Jun 28 10:16:45 2001
+++ ./arch/ia64/mm/init.c.new   Thu Jun 28 09:57:58 2001
@@ -141,10 +141,12 @@
                printk ("Freeing initrd memory: %ldkB freed\n", (end - start) >>
 10);

        for (; start < end; start += PAGE_SIZE) {
-               clear_bit(PG_reserved, &virt_to_page(start)->flags);
-               set_page_count(virt_to_page(start), 1);
-               free_page(start);
-               ++totalram_pages;
+               if (VALID_PAGE(virt_to_page(start))) {
+                       clear_bit(PG_reserved, &virt_to_page(start)->flags);
+                       set_page_count(virt_to_page(start), 1);
+                       free_page(start);
+                       ++totalram_pages;
+               }
        }
 }

---
Takanori Kawano
Hitachi Ltd,
Internet Systems Platform Division
t-kawano@ebina.hitachi.co.jp
Received on Wed Jun 27 20:03:32 2001

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:04 EST