ANDROID: power: add a vendor hook to log unfrozen tasks

We recently noticed an issue where freezing of user space tasks
is failed due to a process being in uninterruptible sleep state.
Currently, the logging of unfrozen tasks is disabled by default.
Although it can be enabled for debugging via a adb command, it's
usually hard to reproduce the issue. So we want to add a vendor
hook to log unfrozen tasks.

Bug: 240091483
Test: all presubmit tests passed
Change-Id: Ief3d4196ea7220d4897c00a37ab96f456dbf2259
Signed-off-by: Darren Hsu <darrenhsu@google.com>
This commit is contained in:
Darren Hsu
2022-07-28 20:58:48 +08:00
committed by Todd Kjos
parent f2cf53322f
commit 3821e5b25c
3 changed files with 8 additions and 1 deletions

View File

@@ -202,6 +202,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_balance_rt);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_timer_calc_index);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_watchdog_timer_softlockup);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_try_to_freeze_todo);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_try_to_freeze_todo_logging);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_try_to_freeze_todo_unfrozen);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_dequeue_task_idle);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_die_kernel_fault);

View File

@@ -25,6 +25,10 @@ DECLARE_HOOK(android_vh_try_to_freeze_todo,
TP_PROTO(unsigned int todo, unsigned int elapsed_msecs, bool wq_busy),
TP_ARGS(todo, elapsed_msecs, wq_busy));
DECLARE_HOOK(android_vh_try_to_freeze_todo_logging,
TP_PROTO(bool *logging_on),
TP_ARGS(logging_on));
DECLARE_HOOK(android_vh_try_to_freeze_todo_unfrozen,
TP_PROTO(struct task_struct *p),
TP_ARGS(p));

View File

@@ -40,6 +40,7 @@ static int try_to_freeze_tasks(bool user_only)
unsigned int elapsed_msecs;
bool wakeup = false;
int sleep_usecs = USEC_PER_MSEC;
bool todo_logging_on = false;
start = ktime_get_boottime();
@@ -101,7 +102,8 @@ static int try_to_freeze_tasks(bool user_only)
if (wq_busy)
show_workqueue_state();
if (pm_debug_messages_on) {
trace_android_vh_try_to_freeze_todo_logging(&todo_logging_on);
if (pm_debug_messages_on || todo_logging_on) {
read_lock(&tasklist_lock);
for_each_process_thread(g, p) {
if (p != current && !freezer_should_skip(p)