Skip to content

Commit efd9017

Browse files
francisyyandavem330
authored andcommitted
tcp: export sender limits chronographs to TCP_INFO
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>
1 parent b0f71bd commit efd9017

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

include/uapi/linux/tcp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ struct tcp_info {
214214
__u32 tcpi_data_segs_out; /* RFC4898 tcpEStatsDataSegsOut */
215215

216216
__u64 tcpi_delivery_rate;
217+
218+
__u64 tcpi_busy_time; /* Time (usec) busy sending data */
219+
__u64 tcpi_rwnd_limited; /* Time (usec) limited by receive window */
220+
__u64 tcpi_sndbuf_limited; /* Time (usec) limited by send buffer */
217221
};
218222

219223
/* for TCP_MD5SIG socket option */

net/ipv4/tcp.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,6 +2708,25 @@ int compat_tcp_setsockopt(struct sock *sk, int level, int optname,
27082708
EXPORT_SYMBOL(compat_tcp_setsockopt);
27092709
#endif
27102710

2711+
static void tcp_get_info_chrono_stats(const struct tcp_sock *tp,
2712+
struct tcp_info *info)
2713+
{
2714+
u64 stats[__TCP_CHRONO_MAX], total = 0;
2715+
enum tcp_chrono i;
2716+
2717+
for (i = TCP_CHRONO_BUSY; i < __TCP_CHRONO_MAX; ++i) {
2718+
stats[i] = tp->chrono_stat[i - 1];
2719+
if (i == tp->chrono_type)
2720+
stats[i] += tcp_time_stamp - tp->chrono_start;
2721+
stats[i] *= USEC_PER_SEC / HZ;
2722+
total += stats[i];
2723+
}
2724+
2725+
info->tcpi_busy_time = total;
2726+
info->tcpi_rwnd_limited = stats[TCP_CHRONO_RWND_LIMITED];
2727+
info->tcpi_sndbuf_limited = stats[TCP_CHRONO_SNDBUF_LIMITED];
2728+
}
2729+
27112730
/* Return information about state of tcp endpoint in API format. */
27122731
void tcp_get_info(struct sock *sk, struct tcp_info *info)
27132732
{
@@ -2800,6 +2819,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
28002819
info->tcpi_bytes_acked = tp->bytes_acked;
28012820
info->tcpi_bytes_received = tp->bytes_received;
28022821
info->tcpi_notsent_bytes = max_t(int, 0, tp->write_seq - tp->snd_nxt);
2822+
tcp_get_info_chrono_stats(tp, info);
28032823

28042824
unlock_sock_fast(sk, slow);
28052825

0 commit comments

Comments
 (0)