Skip to content

Instantly share code, notes, and snippets.

@majek
Created January 18, 2019 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save majek/b14ab718194e5d960e1e433efff0ebd7 to your computer and use it in GitHub Desktop.
Save majek/b14ab718194e5d960e1e433efff0ebd7 to your computer and use it in GitHub Desktop.
Accept latency -> time from final ACK to accept()
/*
* stap -v accept2.stp <port> <seconds>
*/
global socks[1024]
global intervals
probe kernel.function("inet_csk_reqsk_queue_add@net/ipv4/inet_connection_sock.c").call {
req = $req
socks[req] = gettimeofday_ns()
}
probe kernel.function("inet_csk_accept@net/ipv4/inet_connection_sock.c").call {
sk = $sk
req = @cast(sk, "struct inet_connection_sock")->icsk_accept_queue->rskq_accept_head
sport = htons(@cast(sk, "struct inet_sock")->inet_sport)
t0 = socks[req]
if (t0) {
if (sport == $1) {
intervals <<< (gettimeofday_ns() - t0) / 1000 // in us
}
delete socks[req]
}
}
probe end {
printf("Port " @1 " duration in accept queue\nmin:%dus avg:%dus max:%dus count:%d\n",
@min(intervals), @avg(intervals), @max(intervals),
@count(intervals))
printf("Duration (us):\n")
print(@hist_log(intervals));
printf("\n")
}
%( $# > 1 %?
probe timer.sec($2) {
%:
probe timer.sec(30) {
%)
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment