提交 5efc57b3 编写于 作者: X Xuan Zhuo 提交者: Caspar Zhang

alinux: tcp_rt module: peer ports add more statistics

to #27804112

The peer ports add server_time, recv_time, recv_data statistics,
and modify the upload keyword to recv, which is more common for
local and peer.
Signed-off-by: NXuan Zhuo <xuanzhuo@linux.alibaba.com>
Acked-by: NDust Li <dust.li@linux.alibaba.com>
Reviewed-by: NYa Zhao <zhaoya123@linux.alibaba.com>
Reviewed-by: NCambda Zhu <cambda@linux.alibaba.com>
上级 ded7aa68
......@@ -80,15 +80,49 @@ static void tcp_rt_sk_send_data_peer(const struct sock *sk, struct tcp_rt *rt,
/* fall through */
case TCPRT_STAGE_PEER_NONE:
rt->stage_peer = TCPRT_STAGE_PEER_REQUEST;
ktime_get_real_ts64(&rt->start_time);
rt->end_time = rt->start_time;
rt->request_num += 1;
rt->upload_data = 0;
rt->stage_peer = TCPRT_STAGE_PEER_REQUEST;
rt->sent_data = 0;
rt->recv_data = 0;
rt->recv_time = 0;
rt->start_rcv_nxt = tp->rcv_nxt;
rt->last_total_retrans = tp->total_retrans;
rt->lsenttime_us = tcp_clock_us();
break;
default:
rt->lsenttime_us = tcp_clock_us();
break;
}
}
static void tcp_rt_sk_recv_data_peer(const struct sock *sk, struct tcp_rt *rt,
const struct tcp_sock *tp)
{
switch (rt->stage_peer) {
case TCPRT_STAGE_PEER_REQUEST:
rt->stage_peer = TCPRT_STAGE_PEER_RESPONSE;
rt->sent_data = tp->snd_nxt - rt->start_seq;
rt->start_seq = tp->snd_nxt;
rt->lrcvtime_us = tcp_clock_us();
rt->server_time = tcp_clock_us() - rt->lsenttime_us;
ktime_get_real_ts64(&rt->end_time);
return;
case TCPRT_STAGE_PEER_RESPONSE:
ktime_get_real_ts64(&rt->end_time);
if (!RB_EMPTY_ROOT(&tp->out_of_order_queue))
rt->rcv_reorder = 1;
rt->recv_time = tcp_clock_us() - rt->lrcvtime_us;
return;
default:
break;
}
......@@ -106,8 +140,8 @@ static void tcp_rt_sk_send_data_local(const struct sock *sk, struct tcp_rt *rt,
rt->stage = TCPRT_STAGE_RESPONSE;
rt->server_time = this_us - rt->lrcvtime_us;
rt->upload_time = rt->lrcvtime_us - rt->frcvtime_us;
rt->upload_data = tp->rcv_nxt - rt->start_rcv_nxt;
rt->recv_time = rt->lrcvtime_us - rt->frcvtime_us;
rt->recv_data = tp->rcv_nxt - rt->start_rcv_nxt;
/* because recv_data is after rcv_nxt update, so
* record the value at here.
......@@ -124,28 +158,6 @@ static void tcp_rt_sk_send_data_local(const struct sock *sk, struct tcp_rt *rt,
}
}
static void tcp_rt_sk_recv_data_peer(const struct sock *sk, struct tcp_rt *rt,
const struct tcp_sock *tp)
{
switch (rt->stage_peer) {
case TCPRT_STAGE_PEER_REQUEST:
rt->stage_peer = TCPRT_STAGE_PEER_RESPONSE;
rt->upload_data = tp->snd_nxt - rt->start_seq;
rt->start_seq = tp->snd_nxt;
ktime_get_real_ts64(&rt->end_time);
return;
case TCPRT_STAGE_PEER_RESPONSE:
ktime_get_real_ts64(&rt->end_time);
if (!RB_EMPTY_ROOT(&tp->out_of_order_queue))
rt->rcv_reorder = 1;
return;
default:
break;
}
}
static void tcp_rt_sk_recv_data_local(const struct sock *sk, struct tcp_rt *rt,
const struct tcp_sock *tp)
{
......@@ -176,8 +188,8 @@ static void tcp_rt_sk_recv_data_local(const struct sock *sk, struct tcp_rt *rt,
rt->last_update_seq = tp->snd_una;
rt->server_time = 0;
rt->upload_time = 0;
rt->upload_data = 0;
rt->recv_time = 0;
rt->recv_data = 0;
rt->rcv_reorder = 0;
......
......@@ -139,7 +139,7 @@ void tcp_rt_log_printk(const struct sock *sk, char flag, bool fin, bool stats)
char buf[MAX_BUF_SIZE];
int size = 0;
u32 t_rt;
u32 t_seq, t_retrans;
u32 t_seq, t_retrans, recv;
struct timespec64 now;
u32 start_time, mrtt;
......@@ -170,8 +170,8 @@ void tcp_rt_log_printk(const struct sock *sk, char flag, bool fin, bool stats)
size += bufappend(buf, size, t_retrans);
size += bufappend(buf, size, rt->request_num);
size += bufappend(buf, size, rt->server_time);
size += bufappend(buf, size, rt->upload_time);
size += bufappend(buf, size, rt->upload_data);
size += bufappend(buf, size, rt->recv_time);
size += bufappend(buf, size, rt->recv_data);
size += bufappend(buf, size, rt->rcv_reorder);
size += bufappend(buf, size, tp->mss_cache);
buf[size++] = '\n';
......@@ -188,8 +188,8 @@ void tcp_rt_log_printk(const struct sock *sk, char flag, bool fin, bool stats)
stats_add(r->drop, t_retrans);
stats_add(r->packets, t_seq / tp->mss_cache + 1);
stats_add(r->server_time, rt->server_time);
stats_add(r->upload_time, rt->upload_time);
stats_add(r->upload_data, rt->upload_data);
stats_add(r->recv_time, rt->recv_time);
stats_add(r->recv_data, rt->recv_data);
stats_add(r->rtt, mrtt);
}
break;
......@@ -207,7 +207,7 @@ void tcp_rt_log_printk(const struct sock *sk, char flag, bool fin, bool stats)
tp->total_retrans - rt->last_total_retrans);
size += bufappend(buf, size, rt->request_num);
size += bufappend(buf, size, rt->server_time);
size += bufappend(buf, size, rt->upload_time);
size += bufappend(buf, size, rt->recv_time);
size += bufappend(buf, size, tp->snd_nxt - tp->snd_una);
size += bufappend(buf, size, rt->rcv_reorder);
size += bufappend(buf, size, tp->mss_cache);
......@@ -251,16 +251,20 @@ void tcp_rt_log_printk(const struct sock *sk, char flag, bool fin, bool stats)
case LOG_STATUS_P:
t_rt = timespec64_dec(rt->end_time, rt->start_time);
t_seq = rt->upload_data;
t_seq = rt->sent_data;
t_retrans = tp->total_retrans - rt->last_total_retrans;
recv = tp->rcv_nxt - rt->start_rcv_nxt;
size = bufheader(buf, size, flag, sk);
size += bufappend(buf, size, t_seq);
size += bufappend(buf, size, t_rt);
size += bufappend(buf, size, mrtt);
size += bufappend(buf, size, t_retrans);
size += bufappend(buf, size, rt->request_num);
size += bufappend(buf, size, mrtt);
size += bufappend(buf, size, rt->server_time);
size += bufappend(buf, size, rt->recv_time);
size += bufappend(buf, size, recv);
size += bufappend(buf, size, rt->rcv_reorder);
size += bufappend(buf, size, tp->mss_cache);
buf[size++] = '\n';
......@@ -272,11 +276,14 @@ void tcp_rt_log_printk(const struct sock *sk, char flag, bool fin, bool stats)
stats_inc(r->number);
stats_add(r->bytes, t_seq);
stats_add(r->rt, t_rt);
stats_add(r->packets, t_seq / tp->mss_cache + 1);
stats_add(r->drop, t_retrans);
stats_add(r->rtt, mrtt);
stats_add(r->bytes, t_seq);
stats_add(r->rt, t_rt);
stats_add(r->packets, t_seq / tp->mss_cache + 1);
stats_add(r->drop, t_retrans);
stats_add(r->server_time, rt->server_time);
stats_add(r->recv_time, rt->recv_time);
stats_add(r->recv_data, recv);
stats_add(r->rtt, mrtt);
}
break;
}
......@@ -318,17 +325,17 @@ void tcp_rt_timer_output(int port, char *flag, bool alloc)
t.fail = atomic64_xchg(&r->fail, 0);
t.packets = atomic64_xchg(&r->packets, 0);
t.rtt = atomic64_xchg(&r->rtt, 0);
t.upload_time = atomic64_xchg(&r->upload_time, 0);
t.upload_data = atomic64_xchg(&r->upload_data, 0);
t.recv_time = atomic64_xchg(&r->recv_time, 0);
t.recv_data = atomic64_xchg(&r->recv_data, 0);
if (t.number > 0) {
avg.rt = t.rt / t.number;
avg.fail = 1000 * t.fail / t.number;
avg.bytes = t.bytes / t.number;
avg.server_time = t.server_time / t.number;
avg.upload_time = t.upload_time / t.number;
avg.upload_data = t.upload_data / t.number;
avg.rtt = t.rtt / t.number;
avg.rt = t.rt / t.number;
avg.fail = 1000 * t.fail / t.number;
avg.bytes = t.bytes / t.number;
avg.server_time = t.server_time / t.number;
avg.recv_time = t.recv_time / t.number;
avg.recv_data = t.recv_data / t.number;
avg.rtt = t.rtt / t.number;
if (t.packets > 0)
avg.drop = 1000 * t.drop / t.packets;
}
......@@ -337,7 +344,7 @@ void tcp_rt_timer_output(int port, char *flag, bool alloc)
"%llu all %s%u %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
ktime_get_real_seconds(), flag, port, avg.rt,
avg.server_time, avg.drop, avg.rtt, avg.fail, avg.bytes,
avg.upload_time, avg.upload_data, t.number);
avg.recv_time, avg.recv_data, t.number);
if (relay_stats)
relay_write(relay_stats, buf, size);
......
......@@ -62,7 +62,10 @@ struct tcp_rt {
struct timespec64 start_time;
struct timespec64 end_time;
u64 frcvtime_us;
union {
u64 frcvtime_us;
u64 lsenttime_us;
};
u64 lrcvtime_us;
u32 start_seq;
......@@ -72,8 +75,11 @@ struct tcp_rt {
u32 last_update_seq;
int server_time;
int upload_time;
u32 upload_data;
int recv_time;
union {
u32 recv_data;
u32 sent_data;
};
u8 rcv_reorder;
......@@ -90,8 +96,8 @@ struct tcp_rt_stats {
atomic64_t fail;
atomic64_t packets;
atomic64_t rtt;
atomic64_t upload_time;
atomic64_t upload_data;
atomic64_t recv_time;
atomic64_t recv_data;
};
struct _tcp_rt_stats {
......@@ -103,8 +109,8 @@ struct _tcp_rt_stats {
u64 fail;
u64 packets;
u64 rtt;
u64 upload_time;
u64 upload_data;
u64 recv_time;
u64 recv_data;
};
int tcp_rt_output_init(int log_buf_num, int stats_buf_num,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册