Re: How can i track all process context switches in the kernel ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

-- 
mvh Henrik Austad

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux