In the net:{inbound,outbound}_message tracepoint, we are calling the ConnectionTypeAsString helper function that converts the enum to a string. This has been shown to generate quite a few instructions, even when there is no code hooked into the tracepoint.
Here’s the output from gdb when tracing the number of instructions between two breakpoints around this tracepoint (see [1] for how to do this):
Recorded 293 instructions in 27 functions
Tracepoints should be almost zero cost, 293 instructions is a bit much for effectively doing nothing most of the time.
Instead of calling the ConnectionTypeAsString function, simply add a ConnectionType getter that returns the connection type enum directly. This way the tracepoint simplifies to nine instructions that load values into registers in preparation for a tracepoint call, which may or may not be there depending on if there are any attached ebpf programs.
With this patch applied:
Recorded 9 instructions in 1 functions
This tightens up these tracepoints in preparation for enabling tracing in release builds[2].
Signed-off-by: William Casarin jb55@jb55.com
[1] #23724 (comment) [2] #23724