From 1663e97fe17eea382aa9ba9d9a10d4e83ca6d7e6 Mon Sep 17 00:00:00 2001 From: Keun-young Park Date: Fri, 21 Apr 2017 17:29:26 -0700 Subject: [PATCH] add additional dump for timeout - add sysrq-trigger current tasks dump - This helps detecting kernel thread stuck in a specific driver bug: 37573746 Test: python packages/services/Car/tools/bootanalyze/bootanalyze.py -r -c packages/services/Car/tools/bootanalyze/config.yaml -n 2000 -f -e 15 -w 30 -v -a Change-Id: Icb20b5fba63d601bb937f004f5889a9bc8340b34 --- init/reboot.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/init/reboot.cpp b/init/reboot.cpp index 4d65437de..395d21b65 100644 --- a/init/reboot.cpp +++ b/init/reboot.cpp @@ -205,7 +205,7 @@ static bool FindPartitionsToUmount(std::vector* blockDevPartitions, return true; } -static void DumpUmountDebuggingInfo() { +static void DumpUmountDebuggingInfo(bool dump_all) { int status; if (!security_getenforce()) { LOG(INFO) << "Run lsof"; @@ -214,6 +214,10 @@ static void DumpUmountDebuggingInfo() { true, nullptr, nullptr, 0); } FindPartitionsToUmount(nullptr, nullptr, true); + if (dump_all) { + // dump current tasks, this log can be lengthy, so only dump with dump_all + android::base::WriteStringToFile("t", "/proc/sysrq-trigger"); + } } static UmountStat UmountPartitions(int timeoutMs) { @@ -277,11 +281,11 @@ static UmountStat TryUmountAndFsck(bool runFsck, int timeoutMs) { UmountStat stat = UmountPartitions(timeoutMs - t.duration_ms()); if (stat != UMOUNT_STAT_SUCCESS) { LOG(INFO) << "umount timeout, last resort, kill all and try"; - if (DUMP_ON_UMOUNT_FAILURE) DumpUmountDebuggingInfo(); + if (DUMP_ON_UMOUNT_FAILURE) DumpUmountDebuggingInfo(false); KillAllProcesses(); // even if it succeeds, still it is timeout and do not run fsck with all processes killed UmountPartitions(0); - if (DUMP_ON_UMOUNT_FAILURE) DumpUmountDebuggingInfo(); + if (DUMP_ON_UMOUNT_FAILURE) DumpUmountDebuggingInfo(true); } if (stat == UMOUNT_STAT_SUCCESS && runFsck) {