Hi Henrik, On Tue, May 20, 2008 at 1:13 PM, Henrik Austad <henrikau@xxxxxxxxxxxxxx> wrote: > On Saturday 17 May 2008 14:09:17 Manish Katiyar wrote: >> On Sat, May 17, 2008 at 5:34 PM, Indraneel Mukherjee >> >> <mukherjee.indraneel@xxxxxxxxx> wrote: >> > Hi, >> > I've put the following print in context_switch() in kernel/sched.c >> > printk( " %d ", next->pid); >> > >> > Can that serve the purpose as well? >> >> It might, but as Johannes pointed out, it might be too many context >> switches per sec. to track so you might want to restrict it in some >> way. > > What if you (and I'm just thinking loudly now, this might be a bad idea) > a) create a buffer in kernelmode, say 1MB > b) for every context-switch, add PID (and whatever extra information you need) > to this buffer. Use it like a ring-buffer, so if you overflow, you just > overwrite the oldest entries > c) create a device-driver (block-type would be most appropriate I guess) that > read (and empty) the buffer. > d) Then, you only need to create a small user-land script that reads the > block-driver often enought to extract the info. > > Does this make any sense? > > I am actually quite keen to try this out, so I might have something working > soon (where soon is defined to contain all integers from 1 to infinity) :-) > >> But the basic Q is why do you want that output ? How are you going to >> interpret it ? What are you trying to do ? > > I cant speak for Mukhherjee, but personally, it would be nice to know *how* > often the processes are being scheduled, regardles of tick or not, and also > for how long they have been running etc. I think you can get some of the above stats from /proc/%PID/schedstat It will give the following for your process: 1. Sum of all time spent running on the CPU. 2. Sum of all time spent waiting on a runqueue. 3. Num of time slices run on the CPU. A program to report how a process is doing under a scheduling policy is available at: http://eaglet.rain.com/rick/linux/schedstat/v12/latency.c And more info at http://eaglet.rain.com/rick/linux/schedstat/index.html OR linux/Documentation/sched-stats.txt HTH Indro > > -- > mvh Henrik Austad > -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ