aboutsummaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2008-07-25 04:45:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 13:53:28 -0400
commit2d6ffcca623a9a16df6cdfbe8250b7a5904a5f5e (patch)
tree70d30cb6516608e9a8a1dce60c59f3a5ff21b305 /init
parentba92a43dbaee339cf5915ef766d3d3ffbaaf103c (diff)
inflate: refactor inflate malloc code
Inflate requires some dynamic memory allocation very early in the boot process and this is provided with a set of four functions: malloc/free/gzip_mark/gzip_release. The old inflate code used a mark/release strategy rather than implement free. This new version instead keeps a count on the number of outstanding allocations and when it hits zero, it resets the malloc arena. This allows removing all the mark and release implementations and unifying all the malloc/free implementations. The architecture-dependent code must define two addresses: - free_mem_ptr, the address of the beginning of the area in which allocations should be made - free_mem_end_ptr, the address of the end of the area in which allocations should be made. If set to 0, then no check is made on the number of allocations, it just grows as much as needed The architecture-dependent code can also provide an arch_decomp_wdog() function call. This function will be called several times during the decompression process, and allow to notify the watchdog that the system is still running. If an architecture provides such a call, then it must define ARCH_HAS_DECOMP_WDOG so that the generic inflate code calls arch_decomp_wdog(). Work initially done by Matt Mackall, updated to a recent version of the kernel and improved by me. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Matt Mackall <mpm@selenic.com> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Mikael Starvik <mikael.starvik@axis.com> Cc: Jesper Nilsson <jesper.nilsson@axis.com> Cc: Haavard Skinnemoen <hskinnemoen@atmel.com> Cc: David Howells <dhowells@redhat.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Andi Kleen <andi@firstfloor.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Acked-by: Paul Mundt <lethal@linux-sh.org> Acked-by: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'init')
-rw-r--r--init/do_mounts_rd.c25
-rw-r--r--init/initramfs.c22
2 files changed, 4 insertions, 43 deletions
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index 470a328d1454..fedef93b586f 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -303,32 +303,11 @@ static int crd_infd, crd_outfd;
303 303
304static int __init fill_inbuf(void); 304static int __init fill_inbuf(void);
305static void __init flush_window(void); 305static void __init flush_window(void);
306static void __init *malloc(size_t size);
307static void __init free(void *where);
308static void __init error(char *m); 306static void __init error(char *m);
309static void __init gzip_mark(void **);
310static void __init gzip_release(void **);
311 307
312#include "../lib/inflate.c" 308#define NO_INFLATE_MALLOC
313
314static void __init *malloc(size_t size)
315{
316 return kmalloc(size, GFP_KERNEL);
317}
318
319static void __init free(void *where)
320{
321 kfree(where);
322}
323
324static void __init gzip_mark(void **ptr)
325{
326}
327
328static void __init gzip_release(void **ptr)
329{
330}
331 309
310#include "../lib/inflate.c"
332 311
333/* =========================================================================== 312/* ===========================================================================
334 * Fill the input buffer. This is called only when the buffer is empty 313 * Fill the input buffer. This is called only when the buffer is empty
diff --git a/init/initramfs.c b/init/initramfs.c
index 8eeeccb328c9..644fc01ad5f0 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -14,16 +14,6 @@ static void __init error(char *x)
14 message = x; 14 message = x;
15} 15}
16 16
17static void __init *malloc(size_t size)
18{
19 return kmalloc(size, GFP_KERNEL);
20}
21
22static void __init free(void *where)
23{
24 kfree(where);
25}
26
27/* link hash */ 17/* link hash */
28 18
29#define N_ALIGN(len) ((((len) + 1) & ~3) + 2) 19#define N_ALIGN(len) ((((len) + 1) & ~3) + 2)
@@ -407,18 +397,10 @@ static long bytes_out;
407 397
408static void __init flush_window(void); 398static void __init flush_window(void);
409static void __init error(char *m); 399static void __init error(char *m);
410static void __init gzip_mark(void **);
411static void __init gzip_release(void **);
412 400
413#include "../lib/inflate.c" 401#define NO_INFLATE_MALLOC
414 402
415static void __init gzip_mark(void **ptr) 403#include "../lib/inflate.c"
416{
417}
418
419static void __init gzip_release(void **ptr)
420{
421}
422 404
423/* =========================================================================== 405/* ===========================================================================
424 * Write the output window window[0..outcnt-1] and update crc and bytes_out. 406 * Write the output window window[0..outcnt-1] and update crc and bytes_out.