ANDROID: hung_task: Add vendor hook for hung task detect

Add vendor hook for hung task detect, so we can decide which
threads need to check, avoiding false alarms.

Bug: 188684133
Change-Id: I5d7dfeb071cbfda8121134c38a458202aaa3a8c6
Signed-off-by: Huang Yiwei <hyiwei@codeaurora.org>
This commit is contained in:
Huang Yiwei
2021-04-07 17:08:00 +08:00
committed by Treehugger Robot
parent 76d3a9d92e
commit fd84c02872
3 changed files with 36 additions and 3 deletions
+3
View File
@@ -35,6 +35,7 @@
#include <trace/hooks/selinux.h>
#include <trace/hooks/syscall_check.h>
#include <trace/hooks/remoteproc.h>
#include <trace/hooks/hung_task.h>
/*
* Export tracepoints that act as a bare tracehook (ie: have no trace event
@@ -149,3 +150,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_util_est_update);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_setscheduler_uclamp);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rproc_recovery);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rproc_recovery_set);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_uninterruptible_tasks);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_uninterruptible_tasks_dn);
+24
View File
@@ -0,0 +1,24 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM hung_task
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_HUNG_TASK_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_HUNG_TASK_H
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
DECLARE_HOOK(android_vh_check_uninterruptible_tasks,
TP_PROTO(struct task_struct *t, unsigned long timeout,
bool *need_check),
TP_ARGS(t, timeout, need_check));
DECLARE_HOOK(android_vh_check_uninterruptible_tasks_dn,
TP_PROTO(void *unused),
TP_ARGS(unused));
#endif /* _TRACE_HOOK_HUNG_TASK_H */
/* This part must be outside protection */
#include <trace/define_trace.h>
+9 -3
View File
@@ -24,6 +24,8 @@
#include <linux/sched/sysctl.h>
#include <trace/events/sched.h>
#undef CREATE_TRACE_POINTS
#include <trace/hooks/hung_task.h>
/*
* The number of tasks checked:
@@ -180,6 +182,7 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
int max_count = sysctl_hung_task_check_count;
unsigned long last_break = jiffies;
struct task_struct *g, *t;
bool need_check = true;
/*
* If the system crashed already then all bets are off,
@@ -198,10 +201,13 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
goto unlock;
last_break = jiffies;
}
/* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */
if (READ_ONCE(t->__state) == TASK_UNINTERRUPTIBLE)
check_hung_task(t, timeout);
trace_android_vh_check_uninterruptible_tasks(t, timeout, &need_check);
if (need_check)
/* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */
if (READ_ONCE(t->__state) == TASK_UNINTERRUPTIBLE)
check_hung_task(t, timeout);
}
trace_android_vh_check_uninterruptible_tasks_dn(NULL);
unlock:
rcu_read_unlock();
if (hung_task_show_lock)