[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAPF+HwUVUeYr8yB+qR0RAMOSzcmPks7VzVQFfKNNFW-JQYi8jw@mail.gmail.com>
Date: Fri, 7 Aug 2015 22:49:48 +0300
From: Donatas Abraitis <donatas.abraitis@...il.com>
To: netdev@...r.kernel.org
Subject: tcp_update_metrics() fail fast before declaring variables
Hi folks,
one short question regarding net.ipv4.tcp_no_metrics_save sysctl
parameter. Code snippet is actually the following:
void tcp_update_metrics(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
struct dst_entry *dst = __sk_dst_get(sk);
if (sysctl_tcp_nometrics_save)
return;
Why this 'if' statement can't be moved before variables? I think fail
fast could save some instructions in this place. Any thoughts?
Here is the performance benchmarking results:
Test #1 (sysctl -w net.ipv4.tcp_no_metrics_save=0)
sum: 79726, avg: 1295ns
min: 453ns, max: 16487ns
Test #2 (sysctl -w net.ipv4.tcp_no_metrics_save=1)
sum: 77515, avg: 1181ns
min: 431ns, max: 15989ns
Benchmarked with Systemtap:
global c;
probe kernel.function("tcp_update_metrics").return
{
c <<< (gettimeofday_ns() - @entry(gettimeofday_ns()));
}
probe timer.s(60)
{
printf("sum: %d, avg: %dns\n", @count(c), @avg(c));
printf("min: %dns, max: %dns\n", @min(c), @max(c));
delete c;
exit();
}
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists