netlat: add more queue latency check point

add two more queue latency check point
1. the first fastopen data package
2. when the rx skb filled the hole of the skb in ofo queue

Reviewed-by: kernelxing <kernelxing@tencent.com>
Signed-off-by: MengEn Sun <mengensun@tencent.com>
This commit is contained in:
MengEn Sun 2024-05-15 16:50:03 +08:00 committed by mengensun
parent dcaebf61e6
commit 4440f45d14
4 changed files with 25 additions and 9 deletions

View File

@ -11,6 +11,7 @@
#include<net/tcp.h>
#include<net/netns/generic.h>
#include<net/netns_mbuf.h>
#include "netlat.h"
struct netlat_net_data {
int ack;
@ -427,7 +428,7 @@ static void netlat_exit_ipv4_ctl_table(struct net *net)
/* print msg to per net mbuf when latency from
* netif to queued on tcp receive queue
*/
void netlat_queue_check(struct sock *sk, struct sk_buff *skb)
void netlat_queue_check(struct sock *sk, struct sk_buff *skb, int flags)
{
struct net *net;
s64 lat;
@ -456,11 +457,16 @@ void netlat_queue_check(struct sock *sk, struct sk_buff *skb)
lat = lat < 0 ? 0 : lat;
if (lat < thresh)
return;
if (flags & QUEUE_FLAG_RCV)
net_mbuf_print(net, "TCP QU %u %pI4 %d %pI4 %d\n",
(unsigned int)lat,
&sk->sk_rcv_saddr, (int)sk->sk_num,
&sk->sk_daddr, (int)ntohs(sk->sk_dport));
else /* QUEUE_FLAG_OFO for now */
net_mbuf_print(net, "TCP OO %u %pI4 %d %pI4 %d\n",
(unsigned int)lat,
&sk->sk_rcv_saddr, (int)sk->sk_num,
&sk->sk_daddr, (int)ntohs(sk->sk_dport));
}
EXPORT_SYMBOL(netlat_queue_check);

View File

@ -10,6 +10,10 @@
#define H______NETLAT
#ifdef CONFIG_NETLAT
#define QUEUE_FLAG_OFO 0x1
#define QUEUE_FLAG_RCV 0x2
int netlat_net_init(void);
void netlat_net_exit(void);
void netlat_ack_check(struct sock *sk, struct sk_buff *skb);
@ -23,7 +27,7 @@ do { \
} \
} while (0)
void netlat_queue_check(struct sock *sk, struct sk_buff *skb);
void netlat_queue_check(struct sock *sk, struct sk_buff *skb, int flags);
void netlat_pick_check(struct sock *sk, struct sk_buff *skb);
#else /* CONFIG_NETLAT */
@ -38,7 +42,10 @@ static __always_inline void netlat_tcp_enrtxqueue(struct sock *sk,
struct sk_buff *skb) { };
#define netlat_check(oldest, sk, skb)
#define netlat_queue_check(sk, skb)
#define QUEUE_FLAG_OFO 0x1
#define QUEUE_FLAG_RCV 0x2
#define netlat_queue_check(sk, skb, flags)
#define netlat_pick_check(sk, skb)
#endif /* !CONFIG_NETLAT */
#endif

View File

@ -3,6 +3,7 @@
#include <linux/tcp.h>
#include <linux/rcupdate.h>
#include <net/tcp.h>
#include "netlat.h"
void tcp_fastopen_init_key_once(struct net *net)
{
@ -194,6 +195,7 @@ void tcp_fastopen_add_skb(struct sock *sk, struct sk_buff *skb)
TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_SYN;
tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
netlat_queue_check(sk, skb, QUEUE_FLAG_RCV);
__skb_queue_tail(&sk->sk_receive_queue, skb);
tp->syn_data_acked = 1;

View File

@ -4802,6 +4802,7 @@ static void tcp_ofo_queue(struct sock *sk)
eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen);
tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq);
fin = TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN;
netlat_queue_check(sk, skb, QUEUE_FLAG_OFO);
if (!eaten)
__skb_queue_tail(&sk->sk_receive_queue, skb);
else
@ -4989,7 +4990,7 @@ static int __must_check tcp_queue_rcv(struct sock *sk, struct sk_buff *skb,
int eaten;
struct sk_buff *tail = skb_peek_tail(&sk->sk_receive_queue);
netlat_queue_check(sk, skb);
netlat_queue_check(sk, skb, QUEUE_FLAG_RCV);
eaten = (tail &&
tcp_try_coalesce(sk, tail,
skb, fragstolen)) ? 1 : 0;