From ca2d053a941b897397da24a205783850083d9985 Mon Sep 17 00:00:00 2001 From: Sangmoon Kim Date: Tue, 19 Jan 2021 21:19:01 +0900 Subject: [PATCH] ANDROID: softlockup: add vendor hook for a softlockup task Add hook to gather data of softlockup and summarize it with other information. It helps the bootloader produce the summary information when kernel panic or watchdog reset occurs. It can be obtained through Ramdump, etc., and this information can be used to quickly classify and respond to problems. Bug: 326888644 Bug: 386310634 Change-Id: I5263bbd573c3fa4b4c981ac26c943721ce09506d Signed-off-by: Sangmoon Kim (cherry picked from commit c6e2bf2162446f18b1557f3adcd3ee915ba708f4) --- drivers/android/vendor_hooks.c | 2 ++ include/trace/hooks/softlockup.h | 17 +++++++++++++++++ kernel/watchdog.c | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 include/trace/hooks/softlockup.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index c6b44aa69d7d..59dfa514c4e9 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -52,6 +52,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -193,3 +194,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_shmem_get_folio); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_slab_folio_alloced); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kmalloc_large_alloced); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_ctl_dirty_rate); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_watchdog_timer_softlockup); diff --git a/include/trace/hooks/softlockup.h b/include/trace/hooks/softlockup.h new file mode 100644 index 000000000000..eb2855379d98 --- /dev/null +++ b/include/trace/hooks/softlockup.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM softlockup +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_SOFTLOCKUP_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_SOFTLOCKUP_H +#include + +struct pt_regs; +DECLARE_HOOK(android_vh_watchdog_timer_softlockup, + TP_PROTO(int duration, struct pt_regs *regs, bool is_panic), + TP_ARGS(duration, regs, is_panic)); + +#endif /* _TRACE_HOOK_SOFTLOCKUP_H */ +/* This part must be outside protection */ +#include diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 262691ba62b7..6e09ef3f2c20 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -32,6 +32,8 @@ #include +#include + static DEFINE_MUTEX(watchdog_mutex); #if defined(CONFIG_HARDLOCKUP_DETECTOR) || defined(CONFIG_HARDLOCKUP_DETECTOR_SPARC64) @@ -767,6 +769,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer) clear_bit_unlock(0, &soft_lockup_nmi_warn); } + trace_android_vh_watchdog_timer_softlockup(duration, regs, !!softlockup_panic); add_taint(TAINT_SOFTLOCKUP, LOCKDEP_STILL_OK); if (softlockup_panic) panic("softlockup: hung tasks");