-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libbpf-tools/klockstat: Search for correct stack offset in userspace
The klockstat BPF code contains a hard-coded offset (of 4) for the captured stack entries, which is supposed to get rid of the topmost entries that are just locking functions. However, when running the klockstat tool on RHEL, this offset is not correct, leading to output like the following: Caller Avg Wait Count Max Wait Total Wait mutex_lock+0x5 1.1 us 3 1.8 us 3.2 us mutex_lock+0x5 825 ns 5 1.6 us 4.1 us mutex_lock+0x5 1.1 us 4 1.5 us 4.3 us Caller Avg Hold Count Max Hold Total Hold mutex_lock+0x5 18.0 ms 3 23.0 ms 54.0 ms mutex_lock+0x5 1.7 ms 15 2.2 ms 25.1 ms mutex_lock+0x5 1.7 ms 15 2.2 ms 25.1 ms To fix this, remove the offset in the BPF code and add logic in the userspace component to walk the stack frames and find the right offset. We do this by keeping a list of all the possible lock function names we attach to, pre-resolving them into kernel symbol addresses. Then, each time we process a stack trace obtained from the kernel, we walk the stack until we find one of those symbols, and use that (+1) as the stack offset to process. This makes the output work correctly regardless of the offset of the stack offset on a given system. Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
- Loading branch information
Showing
2 changed files
with
74 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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