Re: Task profiling in Linux

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

 



On Sun, Oct 23, 2005 at 22:50:44 +0200, Claudio Scordino wrote:
> Hi all.
> 
> I need some help to make profiling of an application on Linux. I need to 
> measure the computation time between different points of my program, 
> considering only the CPU time that the task has actually executed (i.e. 
> without the intervals of time that the task has been preempted by other 
> tasks).
> 
> To accomplish that, I can't just read the current time in different parts of 
> the program, nor I can set and use a timer, because this wouldn't consider 
> preemptions...

That's what profiler is for. There is a profiler in the GNU compiler
suite, called gprof. Does that not fullfill your needs?

> I found out that Linux provides the getrusage() syscall which provides the 
> information that I need. This syscall also says both user and system times 
> used by the task, which is a very useful thing.
> 
> However, it has two main drawbacks:
> 
> - its precision is very low: I'm working with real-time tasks on a Athlon-64  
> and I need a more accurate estimation

Yes, it's jiffies. 

> - it can't be invoked by a generic task to know the execution time of another 
> task
> 
> The only idea that I had is to insert some hooks in the kernel functions and 
> use some high resolution timer to compute the time that my task has 
> actually executed. This timer starts whenever the task obtains the CPU, and is 
> stopped whenever the task yields the CPU.
> 
> Therefore, I just need to know which functions are invoked when a task starts  
> executing on the CPU and when it looses the CPU.

Task switching always boils down to schedule(). Plus the user/system
time distinction must be handled in kernel entry/exit.

Actually you want to look where task->signal->utime and
task->signal->stime (for any value of task, most often current) are
updated and hook there.

--
						 Jan 'Bulb' Hudec <bulb@xxxxxx>

Attachment: signature.asc
Description: Digital signature


[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