* [PATCH net-next 1/2] tcp: extract the function to compute delivery rate
@ 2017-07-28 17:28 Wei Wang
2017-07-28 17:28 ` [PATCH net-next 2/2] tcp: add related fields into SCM_TIMESTAMPING_OPT_STATS Wei Wang
2017-08-01 0:26 ` [PATCH net-next 1/2] tcp: extract the function to compute delivery rate David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Wei Wang @ 2017-07-28 17:28 UTC (permalink / raw)
To: David Miller, netdev; +Cc: Yuchung Cheng, Soheil Hassas Yeganeh, Wei Wang
From: Wei Wang <weiwan@google.com>
Refactor the code to extract the function to compute delivery rate.
This function will be used in later commit.
Signed-off-by: Wei Wang <weiwan@google.com>
Acked-by: Yuchung Cheng <ycheng@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
---
net/ipv4/tcp.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 71ce33decd97..65d210d0394c 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -388,6 +388,19 @@ static int retrans_to_secs(u8 retrans, int timeout, int rto_max)
return period;
}
+static u64 tcp_compute_delivery_rate(const struct tcp_sock *tp)
+{
+ u32 rate = READ_ONCE(tp->rate_delivered);
+ u32 intv = READ_ONCE(tp->rate_interval_us);
+ u64 rate64 = 0;
+
+ if (rate && intv) {
+ rate64 = (u64)rate * tp->mss_cache * USEC_PER_SEC;
+ do_div(rate64, intv);
+ }
+ return rate64;
+}
+
/* Address-family independent initialization for a tcp_sock.
*
* NOTE: A lot of things set to zero explicitly by call to
@@ -2823,7 +2836,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
{
const struct tcp_sock *tp = tcp_sk(sk); /* iff sk_type == SOCK_STREAM */
const struct inet_connection_sock *icsk = inet_csk(sk);
- u32 now, intv;
+ u32 now;
u64 rate64;
bool slow;
u32 rate;
@@ -2922,13 +2935,9 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
info->tcpi_data_segs_out = tp->data_segs_out;
info->tcpi_delivery_rate_app_limited = tp->rate_app_limited ? 1 : 0;
- rate = READ_ONCE(tp->rate_delivered);
- intv = READ_ONCE(tp->rate_interval_us);
- if (rate && intv) {
- rate64 = (u64)rate * tp->mss_cache * USEC_PER_SEC;
- do_div(rate64, intv);
+ rate64 = tcp_compute_delivery_rate(tp);
+ if (rate64)
info->tcpi_delivery_rate = rate64;
- }
unlock_sock_fast(sk, slow);
}
EXPORT_SYMBOL_GPL(tcp_get_info);
--
2.14.0.rc0.400.g1c36432dff-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net-next 2/2] tcp: add related fields into SCM_TIMESTAMPING_OPT_STATS
2017-07-28 17:28 [PATCH net-next 1/2] tcp: extract the function to compute delivery rate Wei Wang
@ 2017-07-28 17:28 ` Wei Wang
2017-08-01 0:26 ` David Miller
2017-08-01 0:26 ` [PATCH net-next 1/2] tcp: extract the function to compute delivery rate David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Wei Wang @ 2017-07-28 17:28 UTC (permalink / raw)
To: David Miller, netdev; +Cc: Yuchung Cheng, Soheil Hassas Yeganeh, Wei Wang
From: Wei Wang <weiwan@google.com>
Add the following stats into SCM_TIMESTAMPING_OPT_STATS control msg:
TCP_NLA_PACING_RATE
TCP_NLA_DELIVERY_RATE
TCP_NLA_SND_CWND
TCP_NLA_REORDERING
TCP_NLA_MIN_RTT
TCP_NLA_RECUR_RETRANS
TCP_NLA_DELIVERY_RATE_APP_LMT
Signed-off-by: Wei Wang <weiwan@google.com>
Acked-by: Yuchung Cheng <ycheng@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
---
include/uapi/linux/tcp.h | 8 ++++++++
net/ipv4/tcp.c | 20 +++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
index a5507c977497..030e594bab45 100644
--- a/include/uapi/linux/tcp.h
+++ b/include/uapi/linux/tcp.h
@@ -231,6 +231,14 @@ enum {
TCP_NLA_SNDBUF_LIMITED, /* Time (usec) limited by send buffer */
TCP_NLA_DATA_SEGS_OUT, /* Data pkts sent including retransmission */
TCP_NLA_TOTAL_RETRANS, /* Data pkts retransmitted */
+ TCP_NLA_PACING_RATE, /* Pacing rate in bytes per second */
+ TCP_NLA_DELIVERY_RATE, /* Delivery rate in bytes per second */
+ TCP_NLA_SND_CWND, /* Sending congestion window */
+ TCP_NLA_REORDERING, /* Reordering metric */
+ TCP_NLA_MIN_RTT, /* minimum RTT */
+ TCP_NLA_RECUR_RETRANS, /* Recurring retransmits for the current pkt */
+ TCP_NLA_DELIVERY_RATE_APP_LMT, /* delivery rate application limited ? */
+
};
/* for TCP_MD5SIG socket option */
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 65d210d0394c..be78662faa1a 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2947,8 +2947,12 @@ struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk)
const struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *stats;
struct tcp_info info;
+ u64 rate64;
+ u32 rate;
- stats = alloc_skb(5 * nla_total_size_64bit(sizeof(u64)), GFP_ATOMIC);
+ stats = alloc_skb(7 * nla_total_size_64bit(sizeof(u64)) +
+ 3 * nla_total_size(sizeof(u32)) +
+ 2 * nla_total_size(sizeof(u8)), GFP_ATOMIC);
if (!stats)
return NULL;
@@ -2963,6 +2967,20 @@ struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk)
tp->data_segs_out, TCP_NLA_PAD);
nla_put_u64_64bit(stats, TCP_NLA_TOTAL_RETRANS,
tp->total_retrans, TCP_NLA_PAD);
+
+ rate = READ_ONCE(sk->sk_pacing_rate);
+ rate64 = rate != ~0U ? rate : ~0ULL;
+ nla_put_u64_64bit(stats, TCP_NLA_PACING_RATE, rate64, TCP_NLA_PAD);
+
+ rate64 = tcp_compute_delivery_rate(tp);
+ nla_put_u64_64bit(stats, TCP_NLA_DELIVERY_RATE, rate64, TCP_NLA_PAD);
+
+ nla_put_u32(stats, TCP_NLA_SND_CWND, tp->snd_cwnd);
+ nla_put_u32(stats, TCP_NLA_REORDERING, tp->reordering);
+ nla_put_u32(stats, TCP_NLA_MIN_RTT, tcp_min_rtt(tp));
+
+ nla_put_u8(stats, TCP_NLA_RECUR_RETRANS, inet_csk(sk)->icsk_retransmits);
+ nla_put_u8(stats, TCP_NLA_DELIVERY_RATE_APP_LMT, !!tp->rate_app_limited);
return stats;
}
--
2.14.0.rc0.400.g1c36432dff-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 1/2] tcp: extract the function to compute delivery rate
2017-07-28 17:28 [PATCH net-next 1/2] tcp: extract the function to compute delivery rate Wei Wang
2017-07-28 17:28 ` [PATCH net-next 2/2] tcp: add related fields into SCM_TIMESTAMPING_OPT_STATS Wei Wang
@ 2017-08-01 0:26 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-08-01 0:26 UTC (permalink / raw)
To: weiwan; +Cc: netdev, ycheng, soheil
From: Wei Wang <weiwan@google.com>
Date: Fri, 28 Jul 2017 10:28:20 -0700
> From: Wei Wang <weiwan@google.com>
>
> Refactor the code to extract the function to compute delivery rate.
> This function will be used in later commit.
>
> Signed-off-by: Wei Wang <weiwan@google.com>
> Acked-by: Yuchung Cheng <ycheng@google.com>
> Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 2/2] tcp: add related fields into SCM_TIMESTAMPING_OPT_STATS
2017-07-28 17:28 ` [PATCH net-next 2/2] tcp: add related fields into SCM_TIMESTAMPING_OPT_STATS Wei Wang
@ 2017-08-01 0:26 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-08-01 0:26 UTC (permalink / raw)
To: weiwan; +Cc: netdev, ycheng, soheil
From: Wei Wang <weiwan@google.com>
Date: Fri, 28 Jul 2017 10:28:21 -0700
> From: Wei Wang <weiwan@google.com>
>
> Add the following stats into SCM_TIMESTAMPING_OPT_STATS control msg:
> TCP_NLA_PACING_RATE
> TCP_NLA_DELIVERY_RATE
> TCP_NLA_SND_CWND
> TCP_NLA_REORDERING
> TCP_NLA_MIN_RTT
> TCP_NLA_RECUR_RETRANS
> TCP_NLA_DELIVERY_RATE_APP_LMT
>
> Signed-off-by: Wei Wang <weiwan@google.com>
> Acked-by: Yuchung Cheng <ycheng@google.com>
> Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-01 0:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-28 17:28 [PATCH net-next 1/2] tcp: extract the function to compute delivery rate Wei Wang
2017-07-28 17:28 ` [PATCH net-next 2/2] tcp: add related fields into SCM_TIMESTAMPING_OPT_STATS Wei Wang
2017-08-01 0:26 ` David Miller
2017-08-01 0:26 ` [PATCH net-next 1/2] tcp: extract the function to compute delivery rate David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).