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