12
votes

I am a student interested in working on Memory Management, particularly the page replacement component of the linux kernel.

What are the different guides that can help me to begin understanding the kernel source?

I have tried to read the book Understanding the Linux Virtual Memory Manager by Mel Gorman and Understanding the Linux Kernel by Cesati and Bovet, but they do not explain the flow of control through the code. They only end up explaining various data structures used and the work various functions perform. This makes the code more confusing.

My project deals with tweaking the page replacement algorithm in a mainstream kernel and analyse its performance for a set of workloads. Is there a flavor of the linux kernel that would be easier to understand (if not the linux-2.6.xx kernel)?

  • 1
    May i ask why you've chosen to do kernel programming, when you feel not easy with finding your way around complex code? – LennyProgrammers Feb 11 '11 at 9:56
13
votes

Focus on data structures. Understanding data structures is usually more important than code.

If you are only shown data structures but no code, you still get the big picture of the system.

Vice versa, if shown only code but not data structures, it's very hard to understand the system.

"I will, in fact, claim that the difference between a bad programmer and a good one is whether he considers his code or his data structures more important. Bad programmers worry about the code. Good programmers worry about data structures and their relationships." -- Linus Torvalds

"Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won't usually need your flowcharts; they'll be obvious." -- Fred Brooks.

4
votes

Kernel Newbies is pretty good, I guess

There are a lot of people with an interest in learning about how the kernel works, I think you might learn a thing or two there

3
votes

The debugger option could be useful.

Some more things that can be done after building the kernel with the debugger option is to write some sample test applications calling various system calls which will invoke the kernel and you can traverse through one piece of kernel code at a time and understand it's implementation.

2
votes

In the Operating Systems section of the article, What Every Computer Science Major Should Know, Matt Might recommended Linux Kernel Development by Love. Although this is an advanced topic, the book is very well written.

0
votes

One way to learn a complex code base is to run it in a debugger and see where things take you. For Linux there is the Linux Kernel Debugger.

  • I'm not sure this will work for someone who's still trying what to do with this gigantic piece of code, and how it does things – Mahmoud Hossam Feb 11 '11 at 10:00
  • 1
    I've done this approach with huge code bases. You need an entry point and an idea what to look for, though. – LennyProgrammers Feb 11 '11 at 10:20
  • Yes, that's what I meant, he needs to know what to look for first before debugging the kernel – Mahmoud Hossam Feb 11 '11 at 11:31