* [PATCH 1/1] init:add boot option "initramfs_packnum"
@ 2014-11-11 1:42 Zhen Lei
2014-11-21 3:46 ` Fwd: " leizhen
0 siblings, 1 reply; 4+ messages in thread
From: Zhen Lei @ 2014-11-11 1:42 UTC (permalink / raw)
To: Andrew Morton, Yinghai Lu, Mark Rustad, linux-kernel
Cc: Zefan Li, Xinwei Hu, Zhen Lei
During the development phase, we usually enlarge initrd-end to reserve more
memory than the initfs zip exactly occupied. Then we can easily add or delete
files in zip package, without generate fdt again and again. But unfortunately,
if too many zeros followed initfs zip, it will take a long time to break the
loop.
while (!message && len) {
... ...
if (!*buf) {
buf++;
... ...
continue;
}
So, use the boot option "initramfs_packnum" to specify how many zip packages
in each initrd area. When the specified number of packages decompressed in one
area, immediately terminate the loop. Have no impact on current use by default.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
init/initramfs.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/init/initramfs.c b/init/initramfs.c
index ad1bd77..356764f 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -446,12 +446,24 @@ static unsigned long my_inptr; /* index of next byte to be processed in inbuf */
#include <linux/decompress/generic.h>
+/* zero and negative means packages number is unlimited */
+static int initramfs_packnum __initdata;
+
+static __init int setup_initramfs_packnum(char *str)
+{
+ get_option(&str, &initramfs_packnum);
+
+ return 0;
+}
+early_param("initramfs_packnum", setup_initramfs_packnum);
+
static char * __init unpack_to_rootfs(char *buf, unsigned long len)
{
long written;
decompress_fn decompress;
const char *compress_name;
static __initdata char msg_buf[64];
+ int packnum = initramfs_packnum;
header_buf = kmalloc(110, GFP_KERNEL);
symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL);
@@ -500,6 +512,9 @@ static char * __init unpack_to_rootfs(char *buf, unsigned long len)
this_header = saved_offset + my_inptr;
buf += my_inptr;
len -= my_inptr;
+
+ if (!(--packnum))
+ break;
}
dir_utime();
kfree(name_buf);
--
1.8.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Fwd: [PATCH 1/1] init:add boot option "initramfs_packnum"
2014-11-11 1:42 [PATCH 1/1] init:add boot option "initramfs_packnum" Zhen Lei
@ 2014-11-21 3:46 ` leizhen
2014-11-21 4:02 ` Josh Triplett
0 siblings, 1 reply; 4+ messages in thread
From: leizhen @ 2014-11-21 3:46 UTC (permalink / raw)
To: Andrew Morton, Geert Uytterhoeven, Josh Triplett, Peter Zijlstra,
Paul Gortmaker, Paul E. McKenney, Linus Torvalds, linux-kernel
Cc: Zefan Li, Xinwei Hu, Zhen Lei
Hi erverbody! What about your opinion?
I run "scripts/get_maintainer.pl -f init/", but it displays no maintainer.
So this time, I added all people the result listed and added famous Linus Torvalds.
This patch is useful and no harmful.
-------- Original Message --------
Subject: [PATCH 1/1] init:add boot option "initramfs_packnum"
Date: Tue, 11 Nov 2014 09:42:14 +0800
From: Zhen Lei <thunder.leizhen@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>, Yinghai Lu <yinghai@kernel.org>, Mark Rustad <mark.d.rustad@intel.com>, linux-kernel <linux-kernel@vger.kernel.org>
CC: Zefan Li <lizefan@huawei.com>, Xinwei Hu <huxinwei@huawei.com>, Zhen Lei <thunder.leizhen@huawei.com>
During the development phase, we usually enlarge initrd-end to reserve more
memory than the initfs zip exactly occupied. Then we can easily add or delete
files in zip package, without generate fdt again and again. But unfortunately,
if too many zeros followed initfs zip, it will take a long time to break the
loop.
while (!message && len) {
... ...
if (!*buf) {
buf++;
... ...
continue;
}
So, use the boot option "initramfs_packnum" to specify how many zip packages
in each initrd area. When the specified number of packages decompressed in one
area, immediately terminate the loop. Have no impact on current use by default.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
init/initramfs.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/init/initramfs.c b/init/initramfs.c
index ad1bd77..356764f 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -446,12 +446,24 @@ static unsigned long my_inptr; /* index of next byte to be processed in inbuf */
#include <linux/decompress/generic.h>
+/* zero and negative means packages number is unlimited */
+static int initramfs_packnum __initdata;
+
+static __init int setup_initramfs_packnum(char *str)
+{
+ get_option(&str, &initramfs_packnum);
+
+ return 0;
+}
+early_param("initramfs_packnum", setup_initramfs_packnum);
+
static char * __init unpack_to_rootfs(char *buf, unsigned long len)
{
long written;
decompress_fn decompress;
const char *compress_name;
static __initdata char msg_buf[64];
+ int packnum = initramfs_packnum;
header_buf = kmalloc(110, GFP_KERNEL);
symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL);
@@ -500,6 +512,9 @@ static char * __init unpack_to_rootfs(char *buf, unsigned long len)
this_header = saved_offset + my_inptr;
buf += my_inptr;
len -= my_inptr;
+
+ if (!(--packnum))
+ break;
}
dir_utime();
kfree(name_buf);
--
1.8.0
.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: Fwd: [PATCH 1/1] init:add boot option "initramfs_packnum"
2014-11-21 3:46 ` Fwd: " leizhen
@ 2014-11-21 4:02 ` Josh Triplett
2014-11-21 6:27 ` leizhen
0 siblings, 1 reply; 4+ messages in thread
From: Josh Triplett @ 2014-11-21 4:02 UTC (permalink / raw)
To: leizhen
Cc: Andrew Morton, Geert Uytterhoeven, Peter Zijlstra, Paul Gortmaker,
Paul E. McKenney, Linus Torvalds, linux-kernel, Zefan Li,
Xinwei Hu
On Fri, Nov 21, 2014 at 11:46:42AM +0800, leizhen wrote:
> During the development phase, we usually enlarge initrd-end to reserve more
> memory than the initfs zip exactly occupied. Then we can easily add or delete
> files in zip package, without generate fdt again and again. But unfortunately,
> if too many zeros followed initfs zip, it will take a long time to break the
> loop.
>
> while (!message && len) {
> ... ...
> if (!*buf) {
> buf++;
> ... ...
> continue;
> }
>
> So, use the boot option "initramfs_packnum" to specify how many zip packages
> in each initrd area. When the specified number of packages decompressed in one
> area, immediately terminate the loop. Have no impact on current use by default.
This seems like the wrong approach to me. Rather than changing Linux to
ignore excess data in the initramfs, could you change your bootloader to
pass the true length of the initramfs to Linux? Even if you reserve
extra space, if you know how much data you've actually included, you
could have your bootloader pass that information to Linux.
- Josh Triplett
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fwd: [PATCH 1/1] init:add boot option "initramfs_packnum"
2014-11-21 4:02 ` Josh Triplett
@ 2014-11-21 6:27 ` leizhen
0 siblings, 0 replies; 4+ messages in thread
From: leizhen @ 2014-11-21 6:27 UTC (permalink / raw)
To: Josh Triplett
Cc: Andrew Morton, Geert Uytterhoeven, Peter Zijlstra, Paul Gortmaker,
Paul E. McKenney, Linus Torvalds, linux-kernel, Zefan Li,
Xinwei Hu, Andrew Morton, Geert Uytterhoeven, Josh Triplett,
Peter Zijlstra, Paul Gortmaker, Paul E. McKenney, Linus Torvalds
On 2014/11/21 12:02, Josh Triplett wrote:
> On Fri, Nov 21, 2014 at 11:46:42AM +0800, leizhen wrote:
>> During the development phase, we usually enlarge initrd-end to reserve more
>> memory than the initfs zip exactly occupied. Then we can easily add or delete
>> files in zip package, without generate fdt again and again. But unfortunately,
>> if too many zeros followed initfs zip, it will take a long time to break the
>> loop.
>>
>> while (!message && len) {
>> ... ...
>> if (!*buf) {
>> buf++;
>> ... ...
>> continue;
>> }
>>
>> So, use the boot option "initramfs_packnum" to specify how many zip packages
>> in each initrd area. When the specified number of packages decompressed in one
>> area, immediately terminate the loop. Have no impact on current use by default.
>
> This seems like the wrong approach to me. Rather than changing Linux to
> ignore excess data in the initramfs, could you change your bootloader to
> pass the true length of the initramfs to Linux? Even if you reserve
> extra space, if you know how much data you've actually included, you
> could have your bootloader pass that information to Linux.
Yes, at release time, I will do it. But during development phase, men are lazy. Please
consider the following scenario:
We have test file1 and file2, they are all too big. We base upon file1 generated fs1.cpio.gz,
and base upon file2 generated fs2.cpio.gz. We don't put file1 and file2 into one fs package,
because the uploading is very slow on simulator or emulator. Now, we should keep fdt1 and fdt2
relate to two fs packages. If there are many test files, we should keep more fdts, it's not convenient.
But with this patch, we only need keep one fdt, and get the result the same to pass the true length.
>
> - Josh Triplett
>
> .
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-21 6:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-11 1:42 [PATCH 1/1] init:add boot option "initramfs_packnum" Zhen Lei
2014-11-21 3:46 ` Fwd: " leizhen
2014-11-21 4:02 ` Josh Triplett
2014-11-21 6:27 ` leizhen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox