Skip to content

Instantly share code, notes, and snippets.

@larytet
Last active July 10, 2017 17:04
Show Gist options
  • Save larytet/ab222c29d5977141d8eb6d4d27150090 to your computer and use it in GitHub Desktop.
Save larytet/ab222c29d5977141d8eb6d4d27150090 to your computer and use it in GitHub Desktop.
Collect system number of syscalls using STAP
// Use MAXMAPENTRIES to set the maximum size of the array
// for example sudo stap -D MAXMAPENTRIES=40000 ./src/driver/load_measurement.stp
global probe_frequency%
global processes%
probe begin
{
printf("Ctrl-C to print the results\n");
}
probe kprocess.exec
{
processes[pid()] = filename
}
probe syscall.read
{
probe_frequency[pid(), name] <<< 1
}
probe end
{
foreach ([pid, name] in probe_frequency)
printf("process=%s, pid=%u, probe=%s, count=%u\n",
processes[pid], pid, name,
@count(probe_frequency[pid, name]))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment