From a9a44851ec76a09ac87600a4f7af72412745fbae Mon Sep 17 00:00:00 2001 From: heshuai1 Date: Fri, 7 May 2021 19:40:52 +0800 Subject: [PATCH] ANDROID: freezer: Add vendor hook to freezer for GKI purpose. Add the vendor hook to freezer.c so that OEM's logic can be executed when the process is about to be frozen. We need to clear the flag for some tasks and rebind task dependencies for optimization purposes. Bug: 187458531 Bug: 281920779 Signed-off-by: heshuai1 Change-Id: Iea42fd9604d6b33ccd6502425416f0dd28eecebb (cherry picked from commit a1580311c36ca28344b2f03b3c8a72d9f8db5bde) --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/cgroup.h | 4 ++++ kernel/freezer.c | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 17f1487ba574..f475163c811e 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -67,6 +67,7 @@ * Export tracepoints that act as a bare tracehook (ie: have no trace event * associated with them) to allow external modules to probe them. */ +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_refrigerator); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_arch_set_freq_scale); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_is_fpsimd_save); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_transaction_init); diff --git a/include/trace/hooks/cgroup.h b/include/trace/hooks/cgroup.h index 51cc0340912c..15582cc572bd 100644 --- a/include/trace/hooks/cgroup.h +++ b/include/trace/hooks/cgroup.h @@ -12,6 +12,10 @@ DECLARE_HOOK(android_vh_cgroup_set_task, TP_PROTO(int ret, struct task_struct *task), TP_ARGS(ret, task)); +DECLARE_RESTRICTED_HOOK(android_rvh_refrigerator, + TP_PROTO(bool f), + TP_ARGS(f), 1); + struct cgroup_subsys; struct cgroup_taskset; DECLARE_HOOK(android_vh_cgroup_attach, diff --git a/kernel/freezer.c b/kernel/freezer.c index 4fad0e6fca64..b672c614b1e9 100644 --- a/kernel/freezer.c +++ b/kernel/freezer.c @@ -12,6 +12,9 @@ #include #include +#undef CREATE_TRACE_POINT +#include + /* total number of freezing conditions in effect */ DEFINE_STATIC_KEY_FALSE(freezer_active); EXPORT_SYMBOL(freezer_active); @@ -75,6 +78,7 @@ bool __refrigerator(bool check_kthr_stop) spin_lock_irq(&freezer_lock); freeze = freezing(current) && !(check_kthr_stop && kthread_should_stop()); + trace_android_rvh_refrigerator(pm_nosig_freezing); spin_unlock_irq(&freezer_lock); if (!freeze)