#! /usr/bin/env stap global command, syscall_count, syscall_times, this_syscall_time, this_syscall function accumulate () { tid = tid() if (! ([tid] in command)) command[tid] = execname() syscall=pp() # just the substring ideally syscall_count[tid,syscall] ++ this_syscall[tid] = syscall this_syscall_time[tid] = gettimeofday_us() } function decumulate () { tid = tid() syscall = this_syscall[tid] syscall_times[tid,syscall] += gettimeofday_us() - this_syscall_time[tid] # free up memory delete(this_syscall[tid]) delete(this_syscall_time[tid]) } probe kernel.function("sys_*").call { accumulate () } probe kernel.function("sys_*").return { decumulate () } probe timer.ms(5000) { exit () } probe end { foreach ([tid,syscall] in syscall_count- limit 30) { printf("%s(%d) %s count=%d ttime=%d\n", command[tid], tid, syscall, syscall_count[tid,syscall], syscall_times[tid,syscall]) } }