wok diff linux/stuff/linux-freeinitrd-2.6.30.6.u @ rev 4849
xorg-xf86-input-evtouch: ev_calibrate
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Jan 31 22:16:23 2010 +0100 (2010-01-31) |
parents | |
children | 396eeedb83be |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/linux/stuff/linux-freeinitrd-2.6.30.6.u Sun Jan 31 22:16:23 2010 +0100 1.3 @@ -0,0 +1,143 @@ 1.4 +--- linux-2.6.30.4/arch/x86/mm/init.c 1.5 ++++ linux-2.6.30.4/arch/x86/mm/init.c 1.6 +@@ -381,7 +381,7 @@ 1.7 + */ 1.8 + set_memory_rw(begin, (end - begin) >> PAGE_SHIFT); 1.9 + 1.10 +- printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); 1.11 ++ if (what) printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); 1.12 + 1.13 + for (; addr < end; addr += PAGE_SIZE) { 1.14 + ClearPageReserved(virt_to_page(addr)); 1.15 + 1.16 +--- linux-2.6.30.4/init/initramfs.c 1.17 ++++ linux-2.6.30.4/init/initramfs.c 1.18 +@@ -374,6 +374,47 @@ 1.19 + [Reset] = do_reset, 1.20 + }; 1.21 + 1.22 ++#include <linux/initrd.h> 1.23 ++#define INITRD_PAGE ((PAGE_SIZE > 1024*1024) ? PAGE_SIZE : 1024*1024) 1.24 ++ 1.25 ++static void free_rootfs_mem(unsigned long start, unsigned long end) 1.26 ++{ 1.27 ++ free_init_pages(NULL, start, end); 1.28 ++} 1.29 ++ 1.30 ++static void _free_initrd(unsigned long initrd_start, unsigned long initrd_end, 1.31 ++ void (*free_initrd_mem)(unsigned long, unsigned long)); 1.32 ++ 1.33 ++static struct { 1.34 ++ int offset, last, inptr; 1.35 ++ char *max; 1.36 ++} fill; 1.37 ++ 1.38 ++static void release_inbuf(void) 1.39 ++{ 1.40 ++ if (fill.offset >= INITRD_PAGE) { 1.41 ++ unsigned rem = fill.offset % INITRD_PAGE; 1.42 ++ unsigned end = initrd_start + fill.offset - rem; 1.43 ++ _free_initrd(initrd_start, end, free_rootfs_mem); 1.44 ++ printk("."); 1.45 ++ initrd_start = end; 1.46 ++ fill.offset = rem; 1.47 ++ } 1.48 ++} 1.49 ++ 1.50 ++static int fill_buffer(void *buffer, unsigned size) 1.51 ++{ 1.52 ++ int max = fill.max - (char *) initrd_start - fill.offset; 1.53 ++ if (max > size) max = size; 1.54 ++ if (max > INITRD_PAGE) max = INITRD_PAGE; 1.55 ++ memcpy(buffer, (void *)(initrd_start + fill.offset), max); 1.56 ++ fill.offset += max; 1.57 ++ release_inbuf(); 1.58 ++ fill.inptr += fill.last; 1.59 ++ fill.last = max; 1.60 ++ return max; 1.61 ++} 1.62 ++ 1.63 + static int __init write_buffer(char *buf, unsigned len) 1.64 + { 1.65 + count = len; 1.66 +@@ -417,6 +458,7 @@ 1.67 + decompress_fn decompress; 1.68 + const char *compress_name; 1.69 + static __initdata char msg_buf[64]; 1.70 ++ int early_free_initrd = (buf == (char *) initrd_start); 1.71 + 1.72 + header_buf = kmalloc(110, GFP_KERNEL); 1.73 + symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL); 1.74 +@@ -430,8 +472,31 @@ 1.75 + message = NULL; 1.76 + while (!message && len) { 1.77 + loff_t saved_offset = this_header; 1.78 ++ fill.offset = buf - (char *) initrd_start; 1.79 ++ fill.max = buf + len; 1.80 ++ fill.inptr = fill.last = 0; 1.81 + if (*buf == '0' && !(this_header & 3)) { 1.82 + state = Start; 1.83 ++ if (early_free_initrd) { 1.84 ++ while (len) { 1.85 ++ unsigned n = len, tofree; 1.86 ++ if (n > INITRD_PAGE) 1.87 ++ n = INITRD_PAGE; 1.88 ++ flush_buffer(buf, n); 1.89 ++ buf += n; 1.90 ++ len -= n; 1.91 ++ n = buf - (char *) initrd_start; 1.92 ++ tofree = n - (n % INITRD_PAGE); 1.93 ++ if (!tofree) 1.94 ++ continue; 1.95 ++ _free_initrd(initrd_start, 1.96 ++ initrd_start + tofree, 1.97 ++ free_rootfs_mem); 1.98 ++ initrd_start += tofree; 1.99 ++ printk("."); 1.100 ++ } 1.101 ++ continue; 1.102 ++ } 1.103 + written = write_buffer(buf, len); 1.104 + buf += written; 1.105 + len -= written; 1.106 +@@ -445,9 +510,15 @@ 1.107 + } 1.108 + this_header = 0; 1.109 + decompress = decompress_method(buf, len, &compress_name); 1.110 +- if (decompress) 1.111 +- decompress(buf, len, NULL, flush_buffer, NULL, 1.112 ++ if (decompress) { 1.113 ++ if (early_free_initrd) { 1.114 ++ decompress(NULL, 0, fill_buffer, flush_buffer, 1.115 ++ NULL, &my_inptr, error); 1.116 ++ my_inptr += fill.inptr; 1.117 ++ } 1.118 ++ else decompress(buf, len, NULL, flush_buffer, NULL, 1.119 + &my_inptr, error); 1.120 ++ } 1.121 + else if (compress_name) { 1.122 + if (!message) { 1.123 + snprintf(msg_buf, sizeof msg_buf, 1.124 +@@ -484,7 +555,8 @@ 1.125 + #include <linux/initrd.h> 1.126 + #include <linux/kexec.h> 1.127 + 1.128 +-static void __init free_initrd(void) 1.129 ++static void _free_initrd(unsigned long initrd_start, unsigned long initrd_end, 1.130 ++ void (*free_initrd_mem)(unsigned long, unsigned long)) 1.131 + { 1.132 + #ifdef CONFIG_KEXEC 1.133 + unsigned long crashk_start = (unsigned long)__va(crashk_res.start); 1.134 +@@ -512,6 +584,12 @@ 1.135 + #endif 1.136 + free_initrd_mem(initrd_start, initrd_end); 1.137 + skip: 1.138 ++ ; 1.139 ++} 1.140 ++ 1.141 ++static void __init free_initrd(void) 1.142 ++{ 1.143 ++ _free_initrd(initrd_start, initrd_end, free_initrd_mem); 1.144 + initrd_start = 0; 1.145 + initrd_end = 0; 1.146 + }