]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tcp: export sender limits chronographs to TCP_INFO
authorFrancis Yan <francisyyan@gmail.com>
Mon, 28 Nov 2016 07:07:17 +0000 (23:07 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 30 Nov 2016 15:04:25 +0000 (10:04 -0500)
This patch exports all the sender chronograph measurements collected
in the previous patches to TCP_INFO interface. Note that busy time
exported includes all the other sending limits (rwnd-limited,
sndbuf-limited). Internally the time unit is jiffy but externally
the measurements are in microseconds for future extensions.

Signed-off-by: Francis Yan <francisyyan@gmail.com>
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/uapi/linux/tcp.h
net/ipv4/tcp.c

index 73ac0db487f87cfe3d205c57856ad2d9d5dd33cd..2863b661d6e1c1d217b9832834b21c0fffda8c70 100644 (file)
@@ -214,6 +214,10 @@ struct tcp_info {
        __u32   tcpi_data_segs_out;     /* RFC4898 tcpEStatsDataSegsOut */
 
        __u64   tcpi_delivery_rate;
+
+       __u64   tcpi_busy_time;      /* Time (usec) busy sending data */
+       __u64   tcpi_rwnd_limited;   /* Time (usec) limited by receive window */
+       __u64   tcpi_sndbuf_limited; /* Time (usec) limited by send buffer */
 };
 
 /* for TCP_MD5SIG socket option */
index 259ffb50e429bfe97a2f99f3d4e2762afd2243fb..cdde20f49999cc3c068efc5a8b9f257f72ad5813 100644 (file)
@@ -2708,6 +2708,25 @@ int compat_tcp_setsockopt(struct sock *sk, int level, int optname,
 EXPORT_SYMBOL(compat_tcp_setsockopt);
 #endif
 
+static void tcp_get_info_chrono_stats(const struct tcp_sock *tp,
+                                     struct tcp_info *info)
+{
+       u64 stats[__TCP_CHRONO_MAX], total = 0;
+       enum tcp_chrono i;
+
+       for (i = TCP_CHRONO_BUSY; i < __TCP_CHRONO_MAX; ++i) {
+               stats[i] = tp->chrono_stat[i - 1];
+               if (i == tp->chrono_type)
+                       stats[i] += tcp_time_stamp - tp->chrono_start;
+               stats[i] *= USEC_PER_SEC / HZ;
+               total += stats[i];
+       }
+
+       info->tcpi_busy_time = total;
+       info->tcpi_rwnd_limited = stats[TCP_CHRONO_RWND_LIMITED];
+       info->tcpi_sndbuf_limited = stats[TCP_CHRONO_SNDBUF_LIMITED];
+}
+
 /* Return information about state of tcp endpoint in API format. */
 void tcp_get_info(struct sock *sk, struct tcp_info *info)
 {
@@ -2800,6 +2819,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
        info->tcpi_bytes_acked = tp->bytes_acked;
        info->tcpi_bytes_received = tp->bytes_received;
        info->tcpi_notsent_bytes = max_t(int, 0, tp->write_seq - tp->snd_nxt);
+       tcp_get_info_chrono_stats(tp, info);
 
        unlock_sock_fast(sk, slow);