Last active
December 10, 2024 16:31
-
-
Save samueleresca/91a7793206ded928d13cc0e215aca9a9 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
// The futex states as defined in uapi/linux/futex.h | |
#define FUTEX_WAIT 0 | |
#define FUTEX_WAIT_BITSET 9 | |
#define FUTEX_PRIVATE_FLAG 128 | |
#define FUTEX_WAIT_PRIVATE (FUTEX_WAIT | FUTEX_PRIVATE_FLAG) | |
#define FUTEX_WAIT_BITSET_PRIVATE (FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG) | |
// Track futex wait operations (lock attempts) | |
tracepoint:syscalls:sys_enter_futex | |
/args->op == FUTEX_WAIT || args->op == FUTEX_WAIT_BITSET || args->op == FUTEX_WAIT_PRIVATE || args->op == FUTEX_WAIT_BITSET_PRIVATE / | |
{ | |
@lock_ts[tid] = nsecs; | |
} | |
// Track futex wake operations (lock release) | |
tracepoint:syscalls:sys_exit_futex | |
/has_key(@lock_ts, tid)/ | |
{ | |
@lck[comm, tid] = sum(nsecs - @lock_ts[tid]); | |
delete(@lock_ts, tid); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment