wok annotate linux/stuff/linux-freeinitrd-2.6.37.u @ rev 12057

cleaning up receipts that have unnecessary cp operations
author Samuel Trassare <samuel_trassare@yahoo.com>
date Wed Mar 07 21:27:37 2012 -0800 (2012-03-07)
parents
children
rev   line source
slaxemulator@8085 1 --- linux-2.6.30.4/arch/x86/mm/init.c
slaxemulator@8085 2 +++ linux-2.6.30.4/arch/x86/mm/init.c
slaxemulator@8085 3 @@ -366,7 +366,7 @@
slaxemulator@8085 4 */
slaxemulator@8085 5 set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);
slaxemulator@8085 6
slaxemulator@8085 7 - printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
slaxemulator@8085 8 + if (what) printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
slaxemulator@8085 9
slaxemulator@8085 10 for (; addr < end; addr += PAGE_SIZE) {
slaxemulator@8085 11 ClearPageReserved(virt_to_page(addr));
slaxemulator@8085 12
slaxemulator@8085 13 --- linux-2.6.30.4/init/initramfs.c
slaxemulator@8085 14 +++ linux-2.6.30.4/init/initramfs.c
slaxemulator@8085 15 @@ -374,6 +374,52 @@
slaxemulator@8085 16 [Reset] = do_reset,
slaxemulator@8085 17 };
slaxemulator@8085 18
slaxemulator@8085 19 +#include <linux/initrd.h>
slaxemulator@8085 20 +#define INITRD_PAGE ((PAGE_SIZE > 64*1024) ? PAGE_SIZE : 64*1024)
slaxemulator@8085 21 +#define INITRD_DOT (1024*1024)
slaxemulator@8085 22 +
slaxemulator@8085 23 +static void free_rootfs_mem(unsigned long start, unsigned long end)
slaxemulator@8085 24 +{
slaxemulator@8085 25 + free_init_pages(NULL, start, end);
slaxemulator@8085 26 +}
slaxemulator@8085 27 +
slaxemulator@8085 28 +static void _free_initrd(unsigned long initrd_start, unsigned long initrd_end,
slaxemulator@8085 29 + void (*free_initrd_mem)(unsigned long, unsigned long));
slaxemulator@8085 30 +
slaxemulator@8085 31 +static struct {
slaxemulator@8085 32 + int offset, last, inptr, freed;
slaxemulator@8085 33 + char *max;
slaxemulator@8085 34 +} fill;
slaxemulator@8085 35 +
slaxemulator@8085 36 +static void release_inbuf(unsigned n)
slaxemulator@8085 37 +{
slaxemulator@8085 38 + if (n >= INITRD_PAGE) {
slaxemulator@8085 39 + unsigned rem = n % INITRD_PAGE;
slaxemulator@8085 40 + unsigned end = initrd_start + n - rem;
slaxemulator@8085 41 + _free_initrd(initrd_start, end, free_rootfs_mem);
slaxemulator@8085 42 + fill.freed += n - rem;
slaxemulator@8085 43 + if (fill.freed >= INITRD_DOT) {
slaxemulator@8085 44 + fill.freed -= INITRD_DOT;
slaxemulator@8085 45 + printk(".");
slaxemulator@8085 46 + }
slaxemulator@8085 47 + initrd_start = end;
slaxemulator@8085 48 + fill.offset = rem;
slaxemulator@8085 49 + }
slaxemulator@8085 50 +}
slaxemulator@8085 51 +
slaxemulator@8085 52 +static int fill_buffer(void *buffer, unsigned size)
slaxemulator@8085 53 +{
slaxemulator@8085 54 + int max = fill.max - (char *) initrd_start - fill.offset;
slaxemulator@8085 55 + if (max > size) max = size;
slaxemulator@8085 56 + if (max > INITRD_PAGE) max = INITRD_PAGE;
slaxemulator@8085 57 + memcpy(buffer, (void *)(initrd_start + fill.offset), max);
slaxemulator@8085 58 + release_inbuf(fill.offset);
slaxemulator@8085 59 + fill.offset += max;
slaxemulator@8085 60 + fill.inptr += fill.last;
slaxemulator@8085 61 + fill.last = max;
slaxemulator@8085 62 + return max;
slaxemulator@8085 63 +}
slaxemulator@8085 64 +
slaxemulator@8085 65 static int __init write_buffer(char *buf, unsigned len)
slaxemulator@8085 66 {
slaxemulator@8085 67 count = len;
slaxemulator@8085 68 @@ -418,6 +463,7 @@
slaxemulator@8085 69 decompress_fn decompress;
slaxemulator@8085 70 const char *compress_name;
slaxemulator@8085 71 static __initdata char msg_buf[64];
slaxemulator@8085 72 + int early_free_initrd = (buf == (char *) initrd_start);
slaxemulator@8085 73
slaxemulator@8085 74 header_buf = kmalloc(110, GFP_KERNEL);
slaxemulator@8085 75 symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL);
slaxemulator@8085 76 @@ -431,11 +478,16 @@
slaxemulator@8085 77 message = NULL;
slaxemulator@8085 78 while (!message && len) {
slaxemulator@8085 79 loff_t saved_offset = this_header;
slaxemulator@8085 80 + fill.offset = buf - (char *) initrd_start;
slaxemulator@8085 81 + fill.max = buf + len;
slaxemulator@8085 82 + fill.inptr = fill.last = fill.freed = 0;
slaxemulator@8085 83 if (*buf == '0' && !(this_header & 3)) {
slaxemulator@8085 84 state = Start;
slaxemulator@8085 85 written = write_buffer(buf, len);
slaxemulator@8085 86 buf += written;
slaxemulator@8085 87 len -= written;
slaxemulator@8085 88 + if (early_free_initrd)
slaxemulator@8085 89 + release_inbuf(buf - (char *) initrd_start);
slaxemulator@8085 90 continue;
slaxemulator@8085 91 }
slaxemulator@8085 92 if (!*buf) {
slaxemulator@8085 93 @@ -447,7 +497,12 @@
slaxemulator@8085 94 this_header = 0;
slaxemulator@8085 95 decompress = decompress_method(buf, len, &compress_name);
slaxemulator@8085 96 if (decompress) {
slaxemulator@8085 97 - res = decompress(buf, len, NULL, flush_buffer, NULL,
slaxemulator@8085 98 + if (early_free_initrd) {
slaxemulator@8085 99 + res = decompress(NULL, 0, fill_buffer,
slaxemulator@8085 100 + flush_buffer, NULL, &my_inptr, error);
slaxemulator@8085 101 + my_inptr += fill.inptr;
slaxemulator@8085 102 + }
slaxemulator@8085 103 + else res = decompress(buf, len, NULL, flush_buffer, NULL,
slaxemulator@8085 104 &my_inptr, error);
slaxemulator@8085 105 if (res)
slaxemulator@8085 106 error("decompressor failed");
slaxemulator@8085 107 @@ -488,7 +546,8 @@
slaxemulator@8085 108 #include <linux/initrd.h>
slaxemulator@8085 109 #include <linux/kexec.h>
slaxemulator@8085 110
slaxemulator@8085 111 -static void __init free_initrd(void)
slaxemulator@8085 112 +static void _free_initrd(unsigned long initrd_start, unsigned long initrd_end,
slaxemulator@8085 113 + void (*free_initrd_mem)(unsigned long, unsigned long))
slaxemulator@8085 114 {
slaxemulator@8085 115 #ifdef CONFIG_KEXEC
slaxemulator@8085 116 unsigned long crashk_start = (unsigned long)__va(crashk_res.start);
slaxemulator@8085 117 @@ -516,6 +574,12 @@
slaxemulator@8085 118 #endif
slaxemulator@8085 119 free_initrd_mem(initrd_start, initrd_end);
slaxemulator@8085 120 skip:
slaxemulator@8085 121 + ;
slaxemulator@8085 122 +}
slaxemulator@8085 123 +
slaxemulator@8085 124 +static void __init free_initrd(void)
slaxemulator@8085 125 +{
slaxemulator@8085 126 + _free_initrd(initrd_start, initrd_end, free_initrd_mem);
slaxemulator@8085 127 initrd_start = 0;
slaxemulator@8085 128 initrd_end = 0;
slaxemulator@8085 129 }