]> www.infradead.org Git - users/jedix/linux-maple.git/commit
perf lock: Retrieve owner callstack in bpf program
authorChun-Tse Shao <ctshao@google.com>
Thu, 27 Feb 2025 00:28:54 +0000 (16:28 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Fri, 28 Feb 2025 08:29:37 +0000 (00:29 -0800)
commit425bc88352150506075a3aca80750419b5eac4a5
tree2e3f7e010c8df25833f164055984a360efd715a1
parent17ae7f904977f3d097004f91158abcc10e0df484
perf lock: Retrieve owner callstack in bpf program

This implements per-callstack aggregation of lock owners in addition to
per-thread.  The owner callstack is captured using `bpf_get_task_stack()`
at `contention_begin()` and it also adds a custom stackid function for the
owner stacks to be compared easily.

The owner info is kept in a hash map using lock addr as a key to handle
multiple waiters for the same lock.  At `contention_end()`, it updates the
owner lock stat based on the info that was saved at `contention_begin()`.
If there are more waiters, it'd update the owner pid to itself as
`contention_end()` means it gets the lock now.  But it also needs to check
the return value of the lock function in case task was killed by a signal
or something.

Signed-off-by: Chun-Tse Shao <ctshao@google.com>
Tested-by: Athira Rajeev <atrajeev@linux.ibm.com>
Link: https://lore.kernel.org/r/20250227003359.732948-3-ctshao@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/bpf_skel/lock_contention.bpf.c