Skip to content

Instantly share code, notes, and snippets.

@samueleresca
Last active November 27, 2024 21:58
Show Gist options
  • Save samueleresca/2ef2907401b636a2e3cf527bf95a41a8 to your computer and use it in GitHub Desktop.
Save samueleresca/2ef2907401b636a2e3cf527bf95a41a8 to your computer and use it in GitHub Desktop.
// On-CPU time tracking tracking
tracepoint:sched:sched_switch
{
$prev_pid = args->prev_pid;
$next_pid = args->next_pid;
$prev_state = args->prev_state;
// Record on-CPU time for previous task
if (has_key(@start, $prev_pid))
{
@cpu[comm, $prev_pid] = sum(nsecs - @start[$prev_pid]);
}
// Start timing for next thread
@start[$next_pid] = nsecs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment