From 71ad82fd4552ce345983fef709ccfe7c7fe45591 Mon Sep 17 00:00:00 2001 From: songfeng Date: Thu, 28 Mar 2024 10:02:29 +0800 Subject: [PATCH] ANDROID: vendor_hook: fix issue vip thread do not sleep while no vip work to make sure trace_android_vh_binder_has_special_work_ilocked will be called in any case in android native logic (here just fix is: binder_thread_read (non_block case) -> | binder_wait_for_work -> | if(binder_has_work_ilocked(...)) -> | fase: schedule true: break -> ), if binder_has_work_ilocked do not deal with trace_android_vh_binder_has_special_work_ilocked vip thread maybe return true because proc->todo list is not empty but it has not vip work (special work with special binder_transaction:flag) fix it by: move trace_android_vh_binder_has_special_work_ilocked for binder_has_work to binder_has_work_ilocked Fixs: 24bb8fc82e60("ANDROID: vendor_hooks: add hooks in driver/android/binder.c") | https://android-review.googlesource.com/c/kernel/common/+/2897624 Bug: 318782978 Change-Id: I8ced722c71c82942e626f04dce950e8df580ae95 Signed-off-by: songfeng --- drivers/android/binder.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index cc6c9ceca866..0b23409a116e 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -544,14 +544,19 @@ static bool binder_has_work_ilocked(struct binder_thread *thread, bool do_proc_work) { int ret = 0; + bool has_work = false; trace_android_vh_binder_has_work_ilocked(thread, do_proc_work, &ret); if (ret) return true; - return thread->process_todo || + has_work = + thread->process_todo || thread->looper_need_return || (do_proc_work && !binder_worklist_empty_ilocked(&thread->proc->todo)); + trace_android_vh_binder_has_special_work_ilocked(thread, do_proc_work, &has_work); + + return has_work; } static bool binder_has_work(struct binder_thread *thread, bool do_proc_work) @@ -560,7 +565,6 @@ static bool binder_has_work(struct binder_thread *thread, bool do_proc_work) binder_inner_proc_lock(thread->proc); has_work = binder_has_work_ilocked(thread, do_proc_work); - trace_android_vh_binder_has_special_work_ilocked(thread, do_proc_work, &has_work); binder_inner_proc_unlock(thread->proc); return has_work;