ANDROID: Add a vendor hook that allow a module to modify the wake flag

android_vh_do_wake_up_sync:
  To modify the mode value of __wake_up_sync_key and read the sock
  struct pointer param

 android_vh_set_wake_flags:
  To modify the wake flag from a module

Bug: 302977161
Change-Id: Ic75cfde380ea3ff3e50ffbac50e0e12d8c7e31ff
Signed-off-by: Namkyu Kim <namkyu78.kim@samsung.com>
(cherry picked from commit 97368fc2dcc29777e8d3d637d0afdef90e611763)
(cherry picked from commit 0d0f0c5020)
[Dongseok Yi: Moved into kernel/sched/vendor_hooks.c per commit
    5f657b04f4 ("ANDROID: subsystem-specific vendor_hooks.c for
    sched")]
Signed-off-by: Dongseok Yi <dseok.yi@samsung.com>
(cherry picked from commit e97fed285679eee64d142b9e6e286896021ac141)
[quic_subashab@quicinc.com: Change-Id was not preserved for the
cherrypick as there appears to be a change merged through
commit 0d0f0c5020 on same branch but
reverted later. Also squash
commit 91d8cca51891869bee4c9d64677fd6186d3f6430 and update commit text
accordingly.]
Signed-off-by: Subash Abhinov Kasiviswanathan <quic_subashab@quicinc.com>
This commit is contained in:
Namkyu Kim
2021-03-04 09:31:56 +09:00
committed by Subash Abhinov Kasiviswanathan
parent 9b4ff1899e
commit 19919fb4e5
4 changed files with 27 additions and 2 deletions
+8
View File
@@ -247,6 +247,14 @@ DECLARE_RESTRICTED_HOOK(android_rvh_update_thermal_stats,
TP_PROTO(int cpu),
TP_ARGS(cpu), 1);
DECLARE_HOOK(android_vh_do_wake_up_sync,
TP_PROTO(struct wait_queue_head *wq_head, int *done, struct sock *sk),
TP_ARGS(wq_head, done, sk));
DECLARE_HOOK(android_vh_set_wake_flags,
TP_PROTO(int *wake_flags, unsigned int *mode),
TP_ARGS(wake_flags, mode));
/* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_SCHED_H */
+2
View File
@@ -65,3 +65,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_schedule_bug);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_exec);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_update_topology_flags_workfn);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_thermal_stats);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_wake_up_sync);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_wake_flags);
+5 -1
View File
@@ -4,6 +4,7 @@
*
* (C) 2004 Nadia Yvette Chambers, Oracle
*/
#include <trace/hooks/sched.h>
void __init_waitqueue_head(struct wait_queue_head *wq_head, const char *name, struct lock_class_key *key)
{
@@ -207,10 +208,13 @@ EXPORT_SYMBOL_GPL(__wake_up_locked_key_bookmark);
void __wake_up_sync_key(struct wait_queue_head *wq_head, unsigned int mode,
void *key)
{
int wake_flags = WF_SYNC;
if (unlikely(!wq_head))
return;
__wake_up_common_lock(wq_head, mode, 1, WF_SYNC, key);
trace_android_vh_set_wake_flags(&wake_flags, &mode);
__wake_up_common_lock(wq_head, mode, 1, wake_flags, key);
}
EXPORT_SYMBOL_GPL(__wake_up_sync_key);
+12 -1
View File
@@ -138,6 +138,7 @@
#include <net/bpf_sk_storage.h>
#include <trace/events/sock.h>
#include <trace/hooks/sched.h>
#include <net/tcp.h>
#include <net/busy_poll.h>
@@ -3318,9 +3319,19 @@ void sock_def_readable(struct sock *sk)
rcu_read_lock();
wq = rcu_dereference(sk->sk_wq);
if (skwq_has_sleeper(wq))
if (skwq_has_sleeper(wq)) {
int done = 0;
trace_android_vh_do_wake_up_sync(&wq->wait, &done, sk);
if (done)
goto out;
wake_up_interruptible_sync_poll(&wq->wait, EPOLLIN | EPOLLPRI |
EPOLLRDNORM | EPOLLRDBAND);
}
out:
sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
rcu_read_unlock();
}