ANDROID: GKI: Add hooks for sk_alloc.

The vendor module will use 'android_vh_sk_alloc' to
mark some flag bits during sock initialization, and handle
the sock differently based on the flag bit status to ensure
the optimal network experience for the user.
We also use 'android_vh_sk_alloc' to destroy flag bit
information together when the sock is destroyed.

Bug: 345658543
Change-Id: Iae212a391b27848154bd8d5b615a867e76f33e3f
Signed-off-by: Dezhi Huang <huangdezhi@hihonor.com>
This commit is contained in:
h00013079 2024-06-07 16:22:27 +08:00 committed by Treehugger Robot
parent 27547c6a80
commit 6137bb28d6
3 changed files with 8 additions and 0 deletions

View File

@ -376,6 +376,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_percpu_rwsem_down_read);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_percpu_rwsem_up_write);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_percpu_rwsem_wait_complete);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_read_trylock_failed);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sk_alloc);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sk_free);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sd_init_unmap_multi_segment);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sd_setup_unmap_multi_segment);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_scan_type);

View File

@ -64,6 +64,10 @@ DECLARE_HOOK(android_vh_tcp_write_timeout_estab_retrans,
TP_PROTO(struct sock *sk), TP_ARGS(sk));
DECLARE_HOOK(android_vh_tcp_connect,
TP_PROTO(struct sk_buff *skb), TP_ARGS(skb));
DECLARE_HOOK(android_vh_sk_alloc,
TP_PROTO(struct sock *sk), TP_ARGS(sk));
DECLARE_HOOK(android_vh_sk_free,
TP_PROTO(struct sock *sk), TP_ARGS(sk));
/* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_NET_VH_H */

View File

@ -2133,6 +2133,7 @@ static void sk_prot_free(struct proto *prot, struct sock *sk)
cgroup_sk_free(&sk->sk_cgrp_data);
mem_cgroup_sk_free(sk);
trace_android_vh_sk_free(sk);
security_sk_free(sk);
trace_android_rvh_sk_free(sk);
if (slab != NULL)
@ -2178,6 +2179,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
refcount_set(&sk->sk_wmem_alloc, 1);
mem_cgroup_sk_alloc(sk);
trace_android_vh_sk_alloc(sk);
cgroup_sk_alloc(&sk->sk_cgrp_data);
sock_update_classid(&sk->sk_cgrp_data);
sock_update_netprioidx(&sk->sk_cgrp_data);