Last active
December 10, 2024 16:26
-
-
Save samueleresca/9c46655d335fa0ba5ad2a48536ab874c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
// Calculate run queue time when thread gets scheduled | |
if (has_key(@wakeup_ts, $next_pid)) | |
{ | |
@runq[comm, $next_pid] = sum(nsecs - @wakeup_ts[$next_pid]); | |
delete(@wakeup_ts, $next_pid); | |
} | |
} | |
tracepoint:sched:sched_wakeup, | |
tracepoint:sched:sched_wakeup_new | |
{ | |
// Track wakeup time | |
@wakeup_ts[tid] = nsecs; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment