After the previous patch the "task == tt->this_task" checks in back_trace() and
is_task_active() lead to falsely "active" state if ACTIVE() && !LOCAL_ACTIVE().

This is easy to fix, but it seems to me that we can just simplify this logic and
remove the tt->this_task check from back_trace(), although I'm afraid I missed
something.

It look really simple: if LOCAL_ACTIVE() than "this_task" is /usr/bin/crash and
it is obviously running, otherwise we can never assume this if !task_has_cpu().
Not to mention that "deprecation of usage of has_cpu on non-SMP systems" looks
confusing, task_has_cpu() can work without VALID_MEMBER(task_struct_has_cpu).

BTW, I think that task_init() should use "on_cpu" if MEMBER_OFFSET_INIT(has_cpu)
fails, but this is off-topic.

Signed-off-by: Oleg Nesterov <[email protected]>
---
 kernel.c | 3 +--
 task.c   | 8 +++-----
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/kernel.c b/kernel.c
index c82b854..5a392fc 100644
--- a/kernel.c
+++ b/kernel.c
@@ -2800,8 +2800,7 @@ back_trace(struct bt_info *bt)
                return;
        }
 
-       if (LIVE() && !(bt->flags & BT_EFRAME_SEARCH) && 
-            ((bt->task == tt->this_task) || is_task_active(bt->task))) {
+       if (LIVE() && !(bt->flags & BT_EFRAME_SEARCH) && 
is_task_active(bt->task)) {
 
                if (BT_REFERENCE_CHECK(bt) ||
                    bt->flags & (BT_TEXT_SYMBOLS_PRINT|BT_TEXT_SYMBOLS_NOPRINT))
diff --git a/task.c b/task.c
index fd4b700..a6bc9e7 100644
--- a/task.c
+++ b/task.c
@@ -5359,18 +5359,16 @@ is_task_active(ulong task)
 {
        int has_cpu;
 
+       if (LOCAL_ACTIVE() && (task == tt->this_task))
+               return TRUE;
        if (DUMPFILE() && is_panic_thread(task))
                return TRUE;
 
         fill_task_struct(task);
 
-       has_cpu = tt->last_task_read ? 
+       has_cpu = tt->last_task_read ?
                task_has_cpu(task, tt->task_struct) : 0;
 
-       if (!(kt->flags & SMP) && !has_cpu && ACTIVE() && 
-           (task == tt->this_task))
-               has_cpu = TRUE;
-
        return(has_cpu);
 }
 
-- 
2.5.0

--
Crash-utility mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/crash-utility

Reply via email to