public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH][2.6-mm] defer free_initmem() if we have no /init
@ 2004-03-22  6:41 Zwane Mwaikambo
  2004-03-22  7:04 ` Mika Penttilä
  2004-03-22  7:49 ` Olaf Hering
  0 siblings, 2 replies; 5+ messages in thread
From: Zwane Mwaikambo @ 2004-03-22  6:41 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Andrew Morton, olh

In the absence of /init and other nice boot goodies, we fall through to
prepare_namespace() so we shall require initmem to complete boot.

Freeing 1nunedlketo lamdlo y:r3elkpfgeeg
equest at virtual address c06c22a0
 printing eip:
c06c22a0
*pde = 00757027
Oops: 0000 [#1]
PREEMPT SMP DEBUG_PAGEALLOC
CPU:    1
EIP:    0060:[<c06c22a0>]    Not tainted VLI
EFLAGS: 00010213   (2.6.5-rc2-mm1)
EIP is at prepare_namespace+0x0/0xd0
eax: 00000002   ebx: 00000000   ecx: c060b2c0   edx: c060b300
esi: 00000001   edi: 00000000   ebp: dff8ffec   esp: dff8ffd4
ds: 007b   es: 007b   ss: 0068
Process swapper (pid: 1, threadinfo=dff8f000 task=dff1fa50)
Stack: c0103235 00000000 00000000 0000007b c0103170 00000000 00000000 c01051f5
       00000000 00000000 00000000
Call Trace:
 [<c0103235>] init+0xc5/0x190
 [<c0103170>] init+0x0/0x190
 [<c01051f5>] kernel_thread_helper+0x5/0x10

Code:  Bad EIP value.
 <0>Kernel panic: Attempted to kill init!

Index: linux-2.6.5-rc2-mm1/init/main.c
===================================================================
RCS file: /home/cvsroot/linux-2.6.5-rc2-mm1/init/main.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 main.c
--- linux-2.6.5-rc2-mm1/init/main.c	21 Mar 2004 17:02:18 -0000	1.1.1.1
+++ linux-2.6.5-rc2-mm1/init/main.c	21 Mar 2004 20:54:19 -0000
@@ -586,8 +586,8 @@ static int free_initmem_on_exec_helper(v
 	char c;

 	sys_close(fd[1]);
-	sys_read(fd[0], &c, 1);
-	free_initmem();
+	if (sys_read(fd[0], &c, 1) > 0)
+		free_initmem();
 	return 0;
 }

@@ -596,7 +596,7 @@ static void free_initmem_on_exec(void)
 	int fd[2];

 	do_pipe(fd);
-       kernel_thread(free_initmem_on_exec_helper, &fd, SIGCHLD);
+	kernel_thread(free_initmem_on_exec_helper, &fd, SIGCHLD);

 	sys_dup2(fd[1], 255);   /* to get it out of the way */
 	sys_close(fd[0]);
@@ -643,6 +643,7 @@ static int init(void * unused)
 	run_init_process("/init");

 	prepare_namespace();
+	free_initmem();

 	if (sys_open("/dev/console", O_RDWR, 0) < 0)
 		printk("Warning: unable to open an initial console.\n");

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][2.6-mm] defer free_initmem() if we have no /init
  2004-03-22  6:41 [PATCH][2.6-mm] defer free_initmem() if we have no /init Zwane Mwaikambo
@ 2004-03-22  7:04 ` Mika Penttilä
  2004-03-22  7:49 ` Olaf Hering
  1 sibling, 0 replies; 5+ messages in thread
From: Mika Penttilä @ 2004-03-22  7:04 UTC (permalink / raw)
  To: Zwane Mwaikambo; +Cc: Linux Kernel, Andrew Morton, olh



Zwane Mwaikambo wrote:

>In the absence of /init and other nice boot goodies, we fall through to
>prepare_namespace() so we shall require initmem to complete boot.
>
>
>Index: linux-2.6.5-rc2-mm1/init/main.c
>===================================================================
>RCS file: /home/cvsroot/linux-2.6.5-rc2-mm1/init/main.c,v
>retrieving revision 1.1.1.1
>diff -u -p -B -r1.1.1.1 main.c
>--- linux-2.6.5-rc2-mm1/init/main.c	21 Mar 2004 17:02:18 -0000	1.1.1.1
>+++ linux-2.6.5-rc2-mm1/init/main.c	21 Mar 2004 20:54:19 -0000
>@@ -586,8 +586,8 @@ static int free_initmem_on_exec_helper(v
> 	char c;
>
> 	sys_close(fd[1]);
>-	sys_read(fd[0], &c, 1);
>-	free_initmem();
>+	if (sys_read(fd[0], &c, 1) > 0)
>+		free_initmem();
> 	return 0;
> }
>  
>

But the above change makes the early init case to not free initmem, 
which was the whole purpose of the close_on_exec + read + broken pipe 
hassle, I think.



--Mika



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][2.6-mm] defer free_initmem() if we have no /init
  2004-03-22  6:41 [PATCH][2.6-mm] defer free_initmem() if we have no /init Zwane Mwaikambo
  2004-03-22  7:04 ` Mika Penttilä
@ 2004-03-22  7:49 ` Olaf Hering
  2004-03-22  8:12   ` Zwane Mwaikambo
  1 sibling, 1 reply; 5+ messages in thread
From: Olaf Hering @ 2004-03-22  7:49 UTC (permalink / raw)
  To: Zwane Mwaikambo; +Cc: Linux Kernel, Andrew Morton

 On Mon, Mar 22, Zwane Mwaikambo wrote:

> In the absence of /init and other nice boot goodies, we fall through to
> prepare_namespace() so we shall require initmem to complete boot.

Andrew, please restore the previous version of the patch. The 3 liner is
much more obvious. 

-- 
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][2.6-mm] defer free_initmem() if we have no /init
  2004-03-22  7:49 ` Olaf Hering
@ 2004-03-22  8:12   ` Zwane Mwaikambo
  2004-03-22  8:15     ` Olaf Hering
  0 siblings, 1 reply; 5+ messages in thread
From: Zwane Mwaikambo @ 2004-03-22  8:12 UTC (permalink / raw)
  To: Olaf Hering; +Cc: Linux Kernel, Andrew Morton

On Mon, 22 Mar 2004, Olaf Hering wrote:

>  On Mon, Mar 22, Zwane Mwaikambo wrote:
>
> > In the absence of /init and other nice boot goodies, we fall through to
> > prepare_namespace() so we shall require initmem to complete boot.
>
> Andrew, please restore the previous version of the patch. The 3 liner is
> much more obvious.

Olaf, what does the previous patch look like?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][2.6-mm] defer free_initmem() if we have no /init
  2004-03-22  8:12   ` Zwane Mwaikambo
@ 2004-03-22  8:15     ` Olaf Hering
  0 siblings, 0 replies; 5+ messages in thread
From: Olaf Hering @ 2004-03-22  8:15 UTC (permalink / raw)
  To: Zwane Mwaikambo; +Cc: Linux Kernel, Andrew Morton

 On Mon, Mar 22, Zwane Mwaikambo wrote:

> On Mon, 22 Mar 2004, Olaf Hering wrote:
> 
> >  On Mon, Mar 22, Zwane Mwaikambo wrote:
> >
> > > In the absence of /init and other nice boot goodies, we fall through to
> > > prepare_namespace() so we shall require initmem to complete boot.
> >
> > Andrew, please restore the previous version of the patch. The 3 liner is
> > much more obvious.
> 
> Olaf, what does the previous patch look like?


.../people/akpm/patches/2.6/2.6.5-rc1/2.6.5-rc1-mm1/broken-out/initramfs-search-for-init.patch

From: Olaf Hering <olh@suse.de>

initramfs can not be used in current 2.6 kernels, the files will never be
executed because prepare_namespace doesn't care about them.  The only way to
workaround that limitation is a root=0:0 cmdline option to force rootfs as
root filesystem.  This will break further booting because rootfs is not the
final root filesystem.

This patch checks for the presence of /init which comes from the cpio archive
(and thats the only way to store files into the rootfs).  This binary/script
has to do all the work of prepare_namespace().



---

 25-akpm/Documentation/early-userspace/README |   26 ++++++++++++++++++++++++++
 25-akpm/init/main.c                          |    7 +++++++
 2 files changed, 33 insertions(+)

diff -puN init/main.c~initramfs-search-for-init init/main.c
--- 25/init/main.c~initramfs-search-for-init	Tue Mar  9 17:00:46 2004
+++ 25-akpm/init/main.c	Tue Mar  9 17:00:46 2004
@@ -604,6 +604,13 @@ static int init(void * unused)
 	sched_init_smp();
 	do_basic_setup();
 
+       /*
+        * check if there is an early userspace init, if yes
+        * let it do all the work
+        */
+       if (sys_access("/init", 0) == 0)
+               execute_command = "/init";
+       else
 	prepare_namespace();
 
 	/*
diff -puN Documentation/early-userspace/README~initramfs-search-for-init Documentation/early-userspace/README
--- 25/Documentation/early-userspace/README~initramfs-search-for-init	Tue Mar  9 17:00:46 2004
+++ 25-akpm/Documentation/early-userspace/README	Tue Mar  9 17:00:46 2004
@@ -71,5 +71,31 @@ custom initramfs images that meet your n
 For questions and help, you can sign up for the early userspace
 mailing list at http://www.zytor.com/mailman/listinfo/klibc
 
+How does it work?
+=================
+
+The kernel has currently 3 ways to mount the root filesystem:
+
+a) all required device and filesystem drivers compiled into the kernel, no
+   initrd.  init/main.c:init() will call prepare_namespace() to mount the
+   final root filesystem, based on the root= option and optional init= to run
+   some other init binary than listed at the end of init/main.c:init().
+
+b) some device and filesystem drivers built as modules and stored in an
+   initrd.  The initrd must contain a binary '/linuxrc' which is supposed to
+   load these driver modules.  It is also possible to mount the final root
+   filesystem via linuxrc and use the pivot_root syscall.  The initrd is
+   mounted and executed via prepare_namespace().
+
+c) using initramfs.  The call to prepare_namespace() must be skipped.
+   This means that a binary must do all the work.  Said binary can be stored
+   into initramfs either via modifying usr/gen_init_cpio.c or via the new
+   initrd format, an cpio archive.  It must be called "/init".  This binary
+   is responsible to do all the things prepare_namespace() would do.
+
+   To remain backwards compatibility, the /init binary will only run if it
+   comes via an initramfs cpio archive.  If this is not the case,
+   init/main.c:init() will run prepare_namespace() to mount the final root
+   and exec one of the predefined init binaries.
 
 Bryan O'Sullivan <bos@serpentine.com>

_

-- 
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-03-22  8:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-22  6:41 [PATCH][2.6-mm] defer free_initmem() if we have no /init Zwane Mwaikambo
2004-03-22  7:04 ` Mika Penttilä
2004-03-22  7:49 ` Olaf Hering
2004-03-22  8:12   ` Zwane Mwaikambo
2004-03-22  8:15     ` Olaf Hering

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox