/usr/share/systemtap/examples/process
NameSizeModeActions
auditbt.meta4290644editdlrm
auditbt.stp6220755editdlrm
auditbt.tcl790644editdlrm
chng_cpu.meta7750644editdlrm
chng_cpu.stp10490755editdlrm
chng_cpu.tcl1400644editdlrm
cycle_thief.meta10820644editdlrm
cycle_thief.stp28930755editdlrm
cycle_thief.txt59740644editdlrm
errsnoop.meta5750644editdlrm
errsnoop.stp10150755editdlrm
forktracker.meta5250644editdlrm
forktracker.stp6010755editdlrm
futexes.meta5200644editdlrm
futexes.stp11180755editdlrm
futexes.txt9440644editdlrm
futexes2.meta5930644editdlrm
futexes2.stp20140644editdlrm
ltrace.meta3140644editdlrm
ltrace.stp30070755editdlrm
ltrace.tcl1220644editdlrm
migrate.meta7460644editdlrm
migrate.stp10370755editdlrm
mutex-contention.meta4790644editdlrm
mutex-contention.stp55590755editdlrm
mutex-contention.tcl790644editdlrm
noptrace.meta5120644editdlrm
noptrace.stp22350755editdlrm
noptrace.txt12120644editdlrm
pfiles.meta4500644editdlrm
pfiles.stp245230755editdlrm
plimit.meta3870644editdlrm
plimit.stp30290755editdlrm
procmod_watcher.meta6570644editdlrm
procmod_watcher.stp24060644editdlrm
proctop.meta6010644editdlrm
proctop.stp42450755editdlrm
proctop.txt86540644editdlrm
proc_snoop.stp11330755editdlrm
proc_snoop_parser.xml8180644editdlrm
proc_snoop_parser_instructions.txt21800644editdlrm
psig.meta3540644editdlrm
psig.stp56160755editdlrm
pstrace_exec.meta5450644editdlrm
pstrace_exec.stp4650755editdlrm
pstree.meta4550644editdlrm
pstree.stp19570755editdlrm
rlimit_nofile.meta3190644editdlrm
rlimit_nofile.stp11510755editdlrm
sched-latency.meta4700644editdlrm
sched-latency.stp5080644editdlrm
sched-latency.txt15660644editdlrm
schedtimes.meta8140644editdlrm
schedtimes.stp39490755editdlrm
schedtimes.txt32780644editdlrm
semop-watch.meta2670644editdlrm
semop-watch.stp8220755editdlrm
sigkill.meta5600644editdlrm
sigkill.stp6560755editdlrm
sigmon.meta6690644editdlrm
sigmon.stp9320755editdlrm
sig_by_pid.meta3570644editdlrm
sig_by_pid.stp10780755editdlrm
sig_by_pid.txt15140644editdlrm
sig_by_proc.meta3640644editdlrm
sig_by_proc.stp8510755editdlrm
sig_by_proc.txt9510644editdlrm
sleepingBeauties.meta5810644editdlrm
sleepingBeauties.stp13640755editdlrm
sleepingBeauties.tcl1400644editdlrm
sleeptime.meta6010644editdlrm
sleeptime.stp14690755editdlrm
spawn_seeker.meta8540644editdlrm
spawn_seeker.stp15260755editdlrm
spawn_seeker.txt13180644editdlrm
strace.meta3850644editdlrm
strace.stp20810755editdlrm
strace.txt36720644editdlrm
syscalls_by_pid.meta5140644editdlrm
syscalls_by_pid.stp6330755editdlrm
syscalls_by_pid.txt5970644editdlrm
syscalls_by_proc.meta5310644editdlrm
syscalls_by_proc.stp6920755editdlrm
syscalls_by_proc.txt11300644editdlrm
syscalltimes62910755editdlrm
syscalltimes.meta4540644editdlrm
syscalltimes.txt114590644editdlrm
thread-business.meta3460644editdlrm
thread-business.stp8660755editdlrm
thread-business.txt28230644editdlrm
threadstacks.meta5850644editdlrm
threadstacks.stp17890755editdlrm
threadstacks.tcl790644editdlrm
wait4time.meta6580644editdlrm
wait4time.stp13470755editdlrm
Edit: /usr/share/systemtap/examples/process/schedtimes.stp (3949B)
#!/usr/bin/stap ############################################################ # Schedtimes.stp # # Copyright (C) 2009, 2014 Red Hat, Inc. # # This program is free software you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # Authors: Jason Baron # Josh Stone # profiles threads and displays their run times, queued times, # wait times, including i/o wait times. # Has two modes. When no arguments are given it profiles all # threads. Alternatively, you can pass -c "program name" ############################################################ //constants global DEAD=-1, RUNNING=1, QUEUED=2, SLEEPING=3 global run_time, queued_time, sleep_time, iowait_time global pid_state, pid_names // For new enough kernels, roughly 2.6.32+, the @defined(@task->in_iowait) // tests will succeed and reduce these macros to nothing, including these // pid-iowait arrays. For older kernels, the rq fallback will remain. global pid_in_iowait global pid_iowait_count @define in_iowait(task) %( @choose_defined(@task->in_iowait, (pid_in_iowait[@task->pid] ? pid_in_iowait[@task->pid]-- : 0)) %) @define clear_iowait(rq, task) %( if (!@defined(@task->in_iowait)) pid_iowait_count[@task->pid] = @nr_iowait(@rq) %) @define set_iowait(rq, task) %( if (!@defined(@task->in_iowait)) pid_in_iowait[@task->pid] = (@nr_iowait(@rq) > pid_iowait_count[@task->pid]) %) @define nr_iowait(rq) %( atomic_read(&@cast(@rq, "rq", "kernel")->nr_iowait) %) global previous_timestamp function timestamp() { return cpu_clock_us(0) } function update_times(pid, now) { delta = now - previous_timestamp[pid] previous_timestamp[pid] = now if ((state = pid_state[pid]) > 0) { if (state == SLEEPING) sleep_time[pid] += delta else if (state == QUEUED) queued_time[pid] += delta else if (state == RUNNING) run_time[pid] += delta } return delta } function task_targeted(task) { pid = task_pid(task) if (pid && (!target() || target_set_pid(pid))) { pid_names[task_tid(task)] = task_execname(task) return 1 } return 0 } // Update the task name after exec probe kernel.trace("sched_process_exec")!, kprocess.exec_complete { if (tid() in pid_names) pid_names[tid()] = execname() } probe kernel.trace("sched_switch") { // Task $prev is scheduled off this cpu if (task_targeted($prev)) { pid = $prev->pid state = task_state($prev) update_times(pid, timestamp()) if (state > 0) { @set_iowait($rq, $prev) pid_state[pid] = SLEEPING } else if (state == 0) { pid_state[pid] = QUEUED } else { pid_state[pid] = DEAD } } // Task $next is scheduled onto this cpu if (task_targeted($next)) { pid = $next->pid update_times(pid, timestamp()) @clear_iowait($rq, $next) pid_state[pid] = RUNNING } } probe kernel.trace("sched_wakeup") { // Task $p is awakened if (@choose_defined($success, 1) && task_targeted($p)) { pid = $p->pid delta = update_times(pid, timestamp()) if (pid_state[pid] == SLEEPING && @in_iowait($p)) { iowait_time[pid] += delta } pid_state[pid] = QUEUED } } // Give task $p a final accounting probe kernel.trace("sched_process_exit") { if (task_targeted($p)) { pid = $p->pid update_times(pid, timestamp()) pid_state[pid] = DEAD } } probe end { t = timestamp() printf ("\n%16s: %6s %10s %10s %10s %10s %10s\n\n", "execname", "pid", "run(us)", "sleep(us)", "iowait(us)", "queued(us)", "total(us)") foreach (pid+ in pid_state) { update_times(pid, t) printf("%16s: %6d %10d %10d %10d %10d %10d\n", pid_names[pid], pid, run_time[pid], sleep_time[pid], iowait_time[pid], queued_time[pid], (run_time[pid] + sleep_time[pid] + queued_time[pid])) } }