QUESTIONS about kernel trace

QUESTIONS about kernel trace

Post by paul » Thu, 28 Dec 2000 18:04:17



Sorry, I am junior in Linux!
Perhaps, they are not smart questions!
Because I do not know where to find its answer!!

<0> what is the shortest way to debug kernel?!
        It is so slow to add printk, rebuild zImage , download zImage and
try to boot ....

<1>  I read some books and documents about the kernel boot
        I get the sequence from them.....
        BOOTSECT.S,HEAD.S,.....-> start_kernel() in main.c -> mount root,
init....
        but I had traced the start_kernel() in main(), I found a function
init() started

after the start_kernel().
        My questions is that
                calling "start_kernel()",and then "init()" (all in main.c)
is definitely sequence?!
                (I use ARM-LINUX, maybe not in X86-linux?)

<2>  "__init" (in front of functions) has any other meaning?!
            such as AUTO-RUN by kernel?!.....
<3>  about the "__initcall()"?!
        I trace how the "cdu31a_init()" in cdu31a.c start (if cdu31a.o is
built-in-driver)!!
        cdu31a_init() <- blk_dev_init() <- device_init() <-
partition_setup()
        but finally end in  "__initcall(partition_setup())" in the tail of
fs/partitions/check.c
        what is  the meaning?! auto-start?!
        or how does it start?!......and so do aha1542_setup() , h8_init()
<4> what kind of driver must be built-in-driver in kernel (not
module-driver)?

---------------
paulong

 
 
 

QUESTIONS about kernel trace

Post by Kasper Dupon » Mon, 01 Jan 2001 01:13:59



> Sorry, I am junior in Linux!
> Perhaps, they are not smart questions!
> Because I do not know where to find its answer!!

> <0> what is the shortest way to debug kernel?!
>         It is so slow to add printk, rebuild zImage , download zImage and
> try to boot ....

> <1>  I read some books and documents about the kernel boot
>         I get the sequence from them.....
>         BOOTSECT.S,HEAD.S,.....-> start_kernel() in main.c -> mount root,
> init....
>         but I had traced the start_kernel() in main(), I found a function
> init() started

> after the start_kernel().
>         My questions is that
>                 calling "start_kernel()",and then "init()" (all in main.c)
> is definitely sequence?!
>                 (I use ARM-LINUX, maybe not in X86-linux?)

> <2>  "__init" (in front of functions) has any other meaning?!
>             such as AUTO-RUN by kernel?!.....
> <3>  about the "__initcall()"?!
>         I trace how the "cdu31a_init()" in cdu31a.c start (if cdu31a.o is
> built-in-driver)!!
>         cdu31a_init() <- blk_dev_init() <- device_init() <-
> partition_setup()
>         but finally end in  "__initcall(partition_setup())" in the tail of
> fs/partitions/check.c
>         what is  the meaning?! auto-start?!
>         or how does it start?!......and so do aha1542_setup() , h8_init()
> <4> what kind of driver must be built-in-driver in kernel (not
> module-driver)?

> ---------------
> paulong

0) If the part of the kernel you want to debug can be
   compiled as a module then that can speed up things.

1) Start_kernel() is called before multitasking is
   posible, when start_kernel() has done its job it
   creates an entry in the tasklist that will call
   init(), this process is assigned pid 1. Then
   start_kernel() gives up the CPU and init() takes
   over. Init() will do more setup and finaly load
   /sbin/init. When start_kernel() gives up the CPU
   the scheduler believes it is process number 0,
   which will be given the CPU again when no other
   process wants it, therefore start_kernel() enters
   the idle loop when it gets control again.

2) Autorun like gcc's constructors would be a nice
   idea, but the kernel does not (yet) have that.
   __init means that this code is only used at boot
   and can be freed later, that saves around 60KB of
   memory.

3) I think __initcall is similair to __init, but I'm
   not sure.

4) Since a module must be loaded from a file
   everything that is needed before the filesystem
   is available must be compiled into the kernel.
   Eg. the filesystem and devicedriver for your
   root partition (or initrd) must be in the
   kernel.

--
Kasper Dupont