From bf0fe6ec6598694195bdfb3263912103dbe3f150 Mon Sep 17 00:00:00 2001
From: dgaribal <dgaribal@codeaurora.org>
Date: Fri, 27 Feb 2015 10:43:17 -0800
Subject: [PATCH] linux-ramdump-parser-v2: Optimize taskdump panic stack
 dumping

When attempting to locate panicking tasks via the
"--check-for-panic" option, the taskdump parser currently attempts
to exhaustively check every task in kernel task list to see if it
panicked.

To improve performance, task checking can be limited to tasks that
were listed as currently running at the time the RAM dump was
collected. Other tasks do not need to be checked because a
panicking process is expected to disable IRQs and preemption after
entering the panic handler, and therefore will not yield to any
other tasks executing on the same CPU prior to resetting.

Change-Id: I51d7b979f918e21bfdd2adf2a3429883f11bab6a
---
 linux-ramdump-parser-v2/parsers/taskdump.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/linux-ramdump-parser-v2/parsers/taskdump.py b/linux-ramdump-parser-v2/parsers/taskdump.py
index 83555bd..14db15d 100644
--- a/linux-ramdump-parser-v2/parsers/taskdump.py
+++ b/linux-ramdump-parser-v2/parsers/taskdump.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+# Copyright (c) 2012-2013, 2015 The Linux Foundation. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License version 2 and
@@ -105,7 +105,8 @@ def dump_thread_group(ramdump, thread_group, task_out, check_for_panic=0):
                  0, '    ', task_out)
             task_out.write(
                 '=======================================================\n')
-        else:
+        # Panicking tasks are expected to remain in a TASK_RUNNING state
+        elif task_state == 0:
             find_panic(ramdump, addr_stack, thread_task_name)
 
         next_thr = ramdump.read_word(thread_group)
-- 
GitLab