aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <[email protected]>2020-11-18 09:34:05 -0500
committerSteven Rostedt (VMware) <[email protected]>2021-02-02 17:02:07 -0500
commitbefe6d946551d65cddbd32b9cb0170b0249fd5ed (patch)
tree042adb0e059bdc373404942b462d3062b9776075 /tools/perf/scripts/python/Perf-Trace-Util/lib/Perf
parentf2a99ddfd0aaff5f5c53ea1f652b5160ba5ee9b7 (diff)
tracepoint: Do not fail unregistering a probe due to memory failure
The list of tracepoint callbacks is managed by an array that is protected by RCU. To update this array, a new array is allocated, the updates are copied over to the new array, and then the list of functions for the tracepoint is switched over to the new array. After a completion of an RCU grace period, the old array is freed. This process happens for both adding a callback as well as removing one. But on removing a callback, if the new array fails to be allocated, the callback is not removed, and may be used after it is freed by the clients of the tracepoint. There's really no reason to fail if the allocation for a new array fails when removing a function. Instead, the function can simply be replaced by a stub function that could be cleaned up on the next modification of the array. That is, instead of calling the function registered to the tracepoint, it would call a stub function in its place. Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] [ Note, this version does use undefined compiler behavior (assuming that a stub function with no parameters or return, can be called by a location that thinks it has parameters but still no return value. Static calls do the same thing, so this trick is not without precedent. There's another solution that uses RCU tricks and is more complex, but can be an alternative if this solution becomes an issue. Link: https://lore.kernel.org/lkml/[email protected]/ ] Cc: Peter Zijlstra <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Martin KaFai Lau <[email protected]> Cc: Song Liu <[email protected]> Cc: Yonghong Song <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: John Fastabend <[email protected]> Cc: KP Singh <[email protected]> Cc: netdev <[email protected]> Cc: bpf <[email protected]> Cc: Kees Cook <[email protected]> Cc: Florian Weimer <[email protected]> Fixes: 97e1c18e8d17b ("tracing: Kernel Tracepoints") Reported-by: [email protected] Reported-by: [email protected] Reported-by: Matt Mullins <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]> Tested-by: Matt Mullins <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python/Perf-Trace-Util/lib/Perf')
0 files changed, 0 insertions, 0 deletions