linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to understand flow of kernel code
@ 2004-12-02  4:46 krishna
  2004-12-02  6:21 ` Bernd Eckenfels
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: krishna @ 2004-12-02  4:46 UTC (permalink / raw)
  To: Linux Kernel

Hi,

Can Anyone tell me the tips/tricks/techniques/practices followed in 
understanding flow of Linux kernel code?

Regards,
Krishna Chaitanya

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

* Re: How to understand flow of kernel code
  2004-12-02  4:46 How to understand flow of kernel code krishna
@ 2004-12-02  6:21 ` Bernd Eckenfels
  2004-12-02 16:11 ` Jeff V. Merkey
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: Bernd Eckenfels @ 2004-12-02  6:21 UTC (permalink / raw)
  To: linux-kernel

In article <41AE9E3E.9020307@globaledgesoft.com> you wrote:
> Can Anyone tell me the tips/tricks/techniques/practices followed in 
> understanding flow of Linux kernel code?

You read the code and use an ide which allows to find declarations/usage
(ctags suppot in editor for eample). You could also browse with LXR. But
some basic architectural understanding from various kernel books and
articles is helpfull.

http://lxr.linux.no/source/init/main.c

Greetings
Bernd

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

* Re: How to understand flow of kernel code
  2004-12-02  4:46 How to understand flow of kernel code krishna
  2004-12-02  6:21 ` Bernd Eckenfels
@ 2004-12-02 16:11 ` Jeff V. Merkey
  2004-12-04 12:55   ` [OT] " Andries Brouwer
  2004-12-04 16:39   ` Manu Abraham
  2004-12-04 14:51 ` Jon Masters
  2004-12-27 20:22 ` David Eger
  3 siblings, 2 replies; 14+ messages in thread
From: Jeff V. Merkey @ 2004-12-02 16:11 UTC (permalink / raw)
  To: krishna; +Cc: Linux Kernel


Hare Krishna, Hare Krishna, Krishna, Krishna, Hare, Hare,
Hare Rama, Hare Rama, Rama, Rama, Hare, Hare.

Start at entry.S and head.S in /arch/i386/kernel and trace the 
initialization. It's a good place
to start for understanding how the kernel boots and follow the code 
through init. Check out
the userspace interaction as well. It will at least start you with the 
basics.

You may want to offer a leaf, fruit, flower, and water to Lord Chaitanya 
and Lord Krishna
and chant the mantras in between to ask for guidance and understanding 
(I'm serious).

Interesting trivia. Krishna in hindi means "all attractive". The Greeks 
took the word and
over time it was corrupted into the word "Christ" which was later used 
for Jesus of Nazereth.
I lot of people probably don't know his last name actually came from the 
Vedic culture.

Hare Krishna,

Jeff

krishna wrote:

> Hi,
>
> Can Anyone tell me the tips/tricks/techniques/practices followed in 
> understanding flow of Linux kernel code?
>
> Regards,
> Krishna Chaitanya
> -
> To unsubscribe from this list: send the line "unsubscribe 
> linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>


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

* [OT] Re: How to understand flow of kernel code
  2004-12-02 16:11 ` Jeff V. Merkey
@ 2004-12-04 12:55   ` Andries Brouwer
  2004-12-04 16:39   ` Manu Abraham
  1 sibling, 0 replies; 14+ messages in thread
From: Andries Brouwer @ 2004-12-04 12:55 UTC (permalink / raw)
  To: Jeff V. Merkey; +Cc: krishna, Linux Kernel

On Thu, Dec 02, 2004 at 09:11:47AM -0700, Jeff V. Merkey wrote:

> Interesting trivia. Krishna in hindi means "all attractive". The Greeks 
> took the word and
> over time it was corrupted into the word "Christ" which was later used 
> for Jesus of Nazereth.
> I lot of people probably don't know his last name actually came from the 
> Vedic culture.

Hmm - don't think you are a reliable source of etymological information.

Krishna means "black".
Christos means "anointed".

The IE roots are different. The krs-no- is seen e.g. in Slavic cerny
(black). The ghrei- is perhaps seen in English grime.

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

* Re: How to understand flow of kernel code
  2004-12-02  4:46 How to understand flow of kernel code krishna
  2004-12-02  6:21 ` Bernd Eckenfels
  2004-12-02 16:11 ` Jeff V. Merkey
@ 2004-12-04 14:51 ` Jon Masters
  2004-12-27 20:22 ` David Eger
  3 siblings, 0 replies; 14+ messages in thread
From: Jon Masters @ 2004-12-04 14:51 UTC (permalink / raw)
  To: krishna; +Cc: Linux Kernel

On Thu, 02 Dec 2004 10:16:54 +0530, krishna
<krishna.c@globaledgesoft.com> wrote:

> Can Anyone tell me the tips/tricks/techniques/practices followed in
> understanding flow of Linux kernel code?

A really good idea would be to visit:

* http://user-mode-linux.sourceforge.net/

Build a UML kernel with support for kernel debugging and follow their
instructions for debugging the kernel using gdb or even perhaps ddd.
Then you can watch the flow of initialisation for yourself within the
UML. Note that this obviously doesn't have low level hardware specifc
handling for your architecture, but it's a good place to start messing
around.

Also, the usual plugs:

    * http://www.kernelnewbies.org/
    * http://www.tech9.net/rml/kernel_book/
    * http://www.xml.com/ldd/chapter/book/
    * http://safari.oreilly.com/ - Read Understanding the Linux kernel online

Jon.

P.S. You're probably not in the UK, but the next issue of Linux User &
Developer will have a feature on UML debugging. My rather biased
opinion is that it'll be interesting to you :-)

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

* Re: How to understand flow of kernel code
  2004-12-02 16:11 ` Jeff V. Merkey
  2004-12-04 12:55   ` [OT] " Andries Brouwer
@ 2004-12-04 16:39   ` Manu Abraham
  1 sibling, 0 replies; 14+ messages in thread
From: Manu Abraham @ 2004-12-04 16:39 UTC (permalink / raw)
  To: Jeff V. Merkey; +Cc: krishna, Linux Kernel, Andries Brouwer

On Thu December 2 2004 8:11 pm, Jeff V. Merkey wrote:
> Hare Krishna, Hare Krishna, Krishna, Krishna, Hare, Hare,
> Hare Rama, Hare Rama, Rama, Rama, Hare, Hare.
>
> Start at entry.S and head.S in /arch/i386/kernel and trace the
> initialization. It's a good place
> to start for understanding how the kernel boots and follow the code
> through init. Check out
> the userspace interaction as well. It will at least start you with the
> basics.
>
> You may want to offer a leaf, fruit, flower, and water to Lord Chaitanya
> and Lord Krishna
> and chant the mantras in between to ask for guidance and understanding
> (I'm serious).
>
> Interesting trivia. Krishna in hindi means "all attractive". The Greeks
> took the word and
> over time it was corrupted into the word "Christ" which was later used
> for Jesus of Nazereth.
> I lot of people probably don't know his last name actually came from the
> Vedic culture.

FYI, The vedic culture refers to vedic era.

The Vedic scriptures were written much before the books Mahabharatha and 
Ramayana.
	
The last of the vedas, ie, i don't know whether it is the Rig veda or the 
Yajur veda, talks about Kristu or Kristo somebody like that, referring to 
Jesus of Nazareth.

Maybe you should consult some Sanskrit scholars, before making wrong 
statements.

Manu 
>
> Hare Krishna,
>
> Jeff
>
> krishna wrote:
> > Hi,
> >
> > Can Anyone tell me the tips/tricks/techniques/practices followed in
> > understanding flow of Linux kernel code?
> >
> > Regards,
> > Krishna Chaitanya
> > -
> > To unsubscribe from this list: send the line "unsubscribe
> > linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: How to understand flow of kernel code
  2004-12-02  4:46 How to understand flow of kernel code krishna
                   ` (2 preceding siblings ...)
  2004-12-04 14:51 ` Jon Masters
@ 2004-12-27 20:22 ` David Eger
  3 siblings, 0 replies; 14+ messages in thread
From: David Eger @ 2004-12-27 20:22 UTC (permalink / raw)
  To: krishna; +Cc: Linux Kernel

One of the more bizarre details of kernel initialization is in
do_initcalls().  It's one of the last things in the initialization
sequence that you see code for, and it does some odd function-pointer
table assembly hackery.  You don't actually see a list of the functions
that do_initcalls() calls because *it's generated at compile time*.
Each module/filesystem/arch/etc can register an initialization function
with the build system through a declaration like the following in
"binfmt_elf.c":

core_initcall(init_elf_binfmt);

This macro is defined in init.h, along with several others:

#define core_initcall(fn)               __define_initcall("1",fn)
#define postcore_initcall(fn)           __define_initcall("2",fn)
#define arch_initcall(fn)               __define_initcall("3",fn)
#define subsys_initcall(fn)             __define_initcall("4",fn)
#define fs_initcall(fn)                 __define_initcall("5",fn)
#define device_initcall(fn)             __define_initcall("6",fn)
#define late_initcall(fn)               __define_initcall("7",fn)

When the build system is done building all the files, it gathers together
all of the special initcall declarations and links them into one table:
the one that do_initcalls() iterates over.

-dte

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

* Re: How to understand flow of kernel code
  2004-12-06 14:22 krishna
@ 2004-12-06 18:49 ` Jon Masters
  0 siblings, 0 replies; 14+ messages in thread
From: Jon Masters @ 2004-12-06 18:49 UTC (permalink / raw)
  To: krishna; +Cc: Linux Kernel

krishna wrote:

> Thank you. I am able to use UML.

This needs to be advocated more profusely as a experimentation mechanism 
suitable for people just wanting to have an overview initially.

Sure, it's not great for figuring out the lower level stuff, but it 
shines if you want to pick apart the overall VM or sched stuff.

Cheers,

Jon.

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

* How to understand flow of kernel code
@ 2004-12-06 14:22 krishna
  2004-12-06 18:49 ` Jon Masters
  0 siblings, 1 reply; 14+ messages in thread
From: krishna @ 2004-12-06 14:22 UTC (permalink / raw)
  To: jonathan; +Cc: Linux Kernel

Hi jon,

Thank you. I am able to use UML.

Regards,
Krishna Chaitanya


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

* Re: How to understand flow of kernel code
  2004-12-03 15:09 krishna
@ 2004-12-03 15:27 ` Josh Boyer
  0 siblings, 0 replies; 14+ messages in thread
From: Josh Boyer @ 2004-12-03 15:27 UTC (permalink / raw)
  To: krishna; +Cc: Linux Kernel

On Fri, 2004-12-03 at 09:09, krishna wrote:
> Hi Elladan,
> 
>     Thank you very much.
>     Can u tell me how can I start from an interrupt.

Look for the do_IRQ function.  Figure out how it's called, then figure
out what it does, and then figure out how the system is restored.  And
it's a bit more than just C code, so you'll need some understanding of
assembly for whichever architecture you're interested in.

Good luck.

josh


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

* How to understand flow of kernel code
@ 2004-12-03 15:09 krishna
  2004-12-03 15:27 ` Josh Boyer
  0 siblings, 1 reply; 14+ messages in thread
From: krishna @ 2004-12-03 15:09 UTC (permalink / raw)
  To: Linux Kernel

Hi Elladan,

    Thank you very much.
    Can u tell me how can I start from an interrupt.

Regards,
Krishna Chaitanya

Elladan wrote:

It's written in C, so it should be quite simple.

Most everything starts from a syscall, or an interrupt.  

-J

On Thu, Dec 02, 2004 at 10:16:54AM +0530, krishna wrote:
  

Hi,

Can Anyone tell me the tips/tricks/techniques/practices followed in 
understanding flow of Linux kernel code?

Regards,
Krishna Chaitanya


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

* Re: How to understand flow of kernel code
  2004-12-02 19:13 ` Randy.Dunlap
@ 2004-12-02 19:48   ` Cal Peake
  0 siblings, 0 replies; 14+ messages in thread
From: Cal Peake @ 2004-12-02 19:48 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: Nick Warne, Kernel Mailing List

On Thu, 2 Dec 2004, Randy.Dunlap wrote:

> Besides reading the code, Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua>
> has written & posted:
> Subject: [RFC] HOWTO find oops location, v2
> on 2004.Aug.15.  Find it in an lkml email archive.

Another good reference is this slideshow by Simon Trimer:

  http://www.urbanmyth.org/linux/oops/

  http://www.urbanmyth.org/linux/oops/slides.html


-- Cal


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

* Re: How to understand flow of kernel code
  2004-12-02 18:28 Nick Warne
@ 2004-12-02 19:13 ` Randy.Dunlap
  2004-12-02 19:48   ` Cal Peake
  0 siblings, 1 reply; 14+ messages in thread
From: Randy.Dunlap @ 2004-12-02 19:13 UTC (permalink / raw)
  To: Nick Warne; +Cc: linux-kernel

Nick Warne wrote:
>>Interesting trivia. Krishna in hindi means "all attractive". The Greeks 
>>took the word and
>>over time it was corrupted into the word "Christ" which was later used 
>>for Jesus of Nazereth.
>>I lot of people probably don't know his last name actually came from the 
>>Vedic culture.
> 
> 
> So I presume the 'Hare' bit came from that famous race with the tortoise...
> 
> JK'ing aside, good tips - I am trying to learn also to enable me to debug oops 
> I get here and report properly back to the devs.

Besides reading the code, Denis Vlasenko 
<vda@port.imtp.ilyichevsk.odessa.ua> has written & posted:
Subject: [RFC] HOWTO find oops location, v2
on 2004.Aug.15.  Find it in an lkml email archive.

-- 
~Randy

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

* Re: How to understand flow of kernel code
@ 2004-12-02 18:28 Nick Warne
  2004-12-02 19:13 ` Randy.Dunlap
  0 siblings, 1 reply; 14+ messages in thread
From: Nick Warne @ 2004-12-02 18:28 UTC (permalink / raw)
  To: linux-kernel

> Interesting trivia. Krishna in hindi means "all attractive". The Greeks 
> took the word and
> over time it was corrupted into the word "Christ" which was later used 
> for Jesus of Nazereth.
> I lot of people probably don't know his last name actually came from the 
>Vedic culture.

So I presume the 'Hare' bit came from that famous race with the tortoise...

JK'ing aside, good tips - I am trying to learn also to enable me to debug oops 
I get here and report properly back to the devs.

Nick
-- 
"When you're chewing on life's gristle,
Don't grumble, Give a whistle..."

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

end of thread, other threads:[~2004-12-27 20:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-02  4:46 How to understand flow of kernel code krishna
2004-12-02  6:21 ` Bernd Eckenfels
2004-12-02 16:11 ` Jeff V. Merkey
2004-12-04 12:55   ` [OT] " Andries Brouwer
2004-12-04 16:39   ` Manu Abraham
2004-12-04 14:51 ` Jon Masters
2004-12-27 20:22 ` David Eger
2004-12-02 18:28 Nick Warne
2004-12-02 19:13 ` Randy.Dunlap
2004-12-02 19:48   ` Cal Peake
2004-12-03 15:09 krishna
2004-12-03 15:27 ` Josh Boyer
2004-12-06 14:22 krishna
2004-12-06 18:49 ` Jon Masters

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).