views:

188

answers:

2

Hello

I want to know, how does the linux kernel do some stuff (receiving a tcp packet). In what order main tcp functions are called. I want to see both interrupt handler (top half), bottom half and even work done by kernel after user calls "read()".

How can I get a function trace from kernel with some linear time scale?

I want to get a trace from single packet, not the profile of kernel when receiving 1000th of packets.

Kernel is 2.6.18 or 2.6.23 (supported in my debian). I can add some patches to it.

A: 

I can't immediately see a way to trace only a single packet at a time. In particular, it may be difficult to get such fine grained tracing since the upper-half of an interrupt handler shouldn't be doing anything blocking (this is dead-lock prone).

Maybe this is overly pedantic, but have you taken a look at the source code? I know from experience the TCP layer is very well commented, both in recording intent and referencing the RFCs.

I can highly recommend TCP/IP Illustrated, esp Volume 2, the Implementation (website). Its very good, and walks through the code line by line. From the description, "Combining 500 illustrations with 15,000 lines of real, working code...". The source code included is from the BSD kernel, but the stacks are extremely similar, and comparing the two is often instructive.

Willi Ballenthin
TCP/IP Illustrated is already open in adobe on my pc :). It is about BSD. The TCP reno is the same, but the infrastructure is not.I want smth like this "preemption latency trace v1.1.5 on 2.6.17-rt1-smp-latency-trace" http://software.itags.org/linux-unix/434207/ but I don't know how to start it.
osgx
trace can be written to preallocated ring buffer. It will be no locking.
osgx
+1  A: 

You want oprofile. It can give you timings for (a selected subset of) your entire system, which means you can trace network activity from the device to the application and back again, through the kernel and all the libraries.

Andrew McGregor
PLEASE, READ THE QUESTION! |" not the profile of kernel when receiving 1000th|"I want EXACT trace
osgx
Don't shout. Ok, find Documentation/ftrace.txt in your kernel source, or look at http://sourceware.org/systemtap/oprofile would give you the exact trace if you only sent it one packet.
Andrew McGregor
oprofile can check IP every N commands (80k). It will be more then 100 functions in 80 k ticks.
osgx
please, add link to ftrace to answer. seems to be the best. Also, is there a good manual ("fast start") of ftrace?
osgx
Look in the source to your kernel, the file is Documentation/ftrace.txt relative to the root of a kernel source tree. There's a copy here http://lwn.net/Articles/290277/ but it is always best to look in your own kernel for these files.
Andrew McGregor