[parisc-linux-cvs] free_initmem() and free_initrd_mem() patch

Helge Deller deller@gmx.de
Tue, 28 Aug 2001 08:51:57 +0200


EXTRAVERSION -pa8
add/fix free_initmem() and free_initrd_mem()

both work, but since we haven't checked all __initdata, __init,
__devinit and __devinitdata function/structures I #ifdefed them out
for now.

BTW, free_initmem() recovered 367kB RAM during my tests here


Index: Makefile
===================================================================
RCS file: /home/cvs/parisc/linux/Makefile,v
retrieving revision 1.119
diff -u -r1.119 Makefile
--- Makefile	2001/08/28 01:16:14	1.119
+++ Makefile	2001/08/28 06:45:29
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 9
-EXTRAVERSION = -pa7
+EXTRAVERSION = -pa8
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
Index: arch/parisc/mm/init.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/mm/init.c,v
retrieving revision 1.35
diff -u -r1.35 init.c
--- init.c	2001/07/14 21:17:04	1.35
+++ init.c	2001/08/28 06:45:29
@@ -24,6 +24,7 @@
 extern char _text;	/* start of kernel code, defined by linker */
 extern int  data_start;
 extern char _end;	/* end of BSS, defined by linker */
+extern char __init_begin, __init_end;
 
 #ifdef CONFIG_DISCONTIGMEM
 struct node_map_data node_data[MAX_PHYSMEM_RANGES];
@@ -352,7 +353,22 @@
 	sysram_resource.end = ((pmem_ranges[0].start_pfn + pmem_ranges[0].pages) << PAGE_SHIFT) - 1;
 }
 
-void free_initmem(void)  {
+void free_initmem(void)
+{
+#if 0
+	unsigned long addr;
+
+	addr = (unsigned long)(&__init_begin);
+	for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
+		ClearPageReserved(virt_to_page(addr));
+		set_page_count(virt_to_page(addr), 1);
+		free_page(addr);
+		num_physpages++;
+	}
+
+	printk(KERN_INFO "Freeing unused kernel memory: %dk freed\n",
+			(&__init_end - &__init_begin) >> 10);
+#endif
 }
 
 /*
@@ -774,13 +790,14 @@
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
 #if 0
+	if (start < end)
+		printk(KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
 	for (; start < end; start += PAGE_SIZE) {
-		ClearPageReserved(mem_map + MAP_NR(start));
-		set_page_count(mem_map+MAP_NR(start), 1);
+		ClearPageReserved(virt_to_page(start));
+		set_page_count(virt_to_page(start), 1);
 		free_page(start);
-		nu_mphyspages++;
+		num_physpages++;
 	}
-	printk(KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
 #endif
 }
 #endif