0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-28 01:04:41 +08:00
easy_profiler/scripts/context_switch_logger.stp
Sergey Yagovtsev 9521f8ac02 Store context switch timestamp on linux.
It's need to run systemtap util for loading kernel module. This kernel module capture context switch timestamp and systemtap store it in the temp file.
Before running profiling application you should run systemtap script with root privileges as following:
\# stap -o /tmp/cs_profiling_info.log scripts/context_switch_logger.stp name APPLICATION_NAME
where APPLICATION_NAME is profiling application
2016-09-05 22:11:03 +03:00

37 lines
836 B
Plaintext

global target_pid
global target_name
probe scheduler.ctxswitch {
if (target_pid != 0
&& next_pid != target_pid
&& prev_pid != target_pid)
next
if (target_name != ""
&& prev_task_name != target_name
&& next_task_name != target_name)
next
//printf("Switch from %d(%s) to %d(%s) at %d\n",prev_tid, prev_task_name,next_tid,next_task_name, gettimeofday_ns())
printf("%d %d %d\n",gettimeofday_ns(),prev_tid, next_tid )
}
probe begin
{
target_pid = 0
target_name = ""
%( $# == 1 || $# > 2 %?
log("Wrong number of arguments, use none, 'pid nr' or 'name proc'")
exit()
%)
%( $# == 2 %?
if(@1 == "pid")
target_pid = strtol(@2, 10)
if(@1 == "name")
target_name = @2
%)
}