From 0ebf9a330d5324a59010618d94402b1a93321cb3 Mon Sep 17 00:00:00 2001 From: Chenghao Zhao Date: Mon, 24 Feb 2025 11:37:09 +0800 Subject: [PATCH] ANDROID: GKI: net: add vendor hook for network quality estimation 1.android_vh_tcp_rcv_rtt_update To record the rcv rtt and its update time. We use "srtt_us" in tcp_sock struct to judge the network quality. But sometimes, an uplink request is sent, and downlink data is received for a long time. During this period, the "srtt_us" is not updated, but the "rcv_rtt_est" may be updated. So in this case, we may choose to use rcv rtt instead of rtt to judge the network quality. Bug: 398691197 Change-Id: I92b26b4302ff7ea5cbabaa9bb3bb71dacfe702db Signed-off-by: Chenghao Zhao --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/net.h | 3 +++ net/ipv4/tcp_input.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index b140bc5bcfd9..05d85a991b10 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -257,6 +257,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_udp_unicast_rcv_skb); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_udp6_unicast_rcv_skb); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_rcv_established_fast_path); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_rcv_established_slow_path); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tcp_rcv_rtt_update); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_should_memcg_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpu_capacity_show); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_init); diff --git a/include/trace/hooks/net.h b/include/trace/hooks/net.h index 8b74d4541773..531c5faf24d4 100644 --- a/include/trace/hooks/net.h +++ b/include/trace/hooks/net.h @@ -26,6 +26,7 @@ DECLARE_HOOK(android_vh_ptype_head, struct sock; struct sockaddr_in6; +struct tcp_sock; DECLARE_HOOK(android_vh_tcp_v4_connect, TP_PROTO(struct sock *sk, struct sockaddr *uaddr), TP_ARGS(sk, uaddr)); DECLARE_HOOK(android_vh_tcp_v6_connect, @@ -86,6 +87,8 @@ DECLARE_HOOK(android_vh_dc_send_copy, TP_PROTO(struct sk_buff *skb, struct net_device *dev), TP_ARGS(skb, dev)); DECLARE_HOOK(android_vh_dc_receive, TP_PROTO(struct sk_buff *skb, int *flag), TP_ARGS(skb, flag)); +DECLARE_HOOK(android_vh_tcp_rcv_rtt_update, + TP_PROTO(struct tcp_sock *tp, u32 sample, int win_dep), TP_ARGS(tp, sample, win_dep)); /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_NET_VH_H */ diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 4b9acaa531f3..a3c09134e9b3 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -649,6 +649,8 @@ static void tcp_rcv_rtt_update(struct tcp_sock *tp, u32 sample, int win_dep) u32 new_sample = tp->rcv_rtt_est.rtt_us; long m = sample; + trace_android_vh_tcp_rcv_rtt_update(tp, sample, win_dep); + if (new_sample != 0) { /* If we sample in larger samples in the non-timestamp * case, we could grossly overestimate the RTT especially