Giter VIP home page Giter VIP logo

Comments (3)

stffrdhrn avatar stffrdhrn commented on June 25, 2024

Failure in openrisc code:

< shorne@lianli ~/work/linux > ./scripts/faddr2line vmlinux save_stack_trace_tsk+0x40/0x74 stack_trace_save_tsk+0x44/0x58
save_stack_trace_tsk+0x40/0x74:
save_stack_trace_tsk at arch/openrisc/kernel/stacktrace.c:77

stack_trace_save_tsk+0x44/0x58:
stack_trace_save_tsk at kernel/stacktrace.c:308

Code:

void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
{
        unsigned long *sp = NULL;

        if (tsk == current)
                sp = (unsigned long *) &sp;
        else
                sp = (unsigned long *) KSTK_ESP(tsk);

        unwind_stack(trace, sp, save_stack_address_nosched);  <-- Failed calling this
}

From above the args are:

  • GPR03: d6f09bc4 (trace)
  • GPR04: 7fc60f5c (sp) <-- this is getting a bogus value?
  • GPR05: c00099b4 (save_stack_address_nosched)

Confirmation on c00099b4

< shorne@lianli ~/work/linux > or1k-elf-objdump -d vmlinux| grep -A3 c00099b4                                                                                              
c00099b4 <save_stack_address_nosched>:                                                                                                                                     |
c00099b4:       9c 21 ff ec     l.addi r1,r1,-20                                                                                                                           |
c00099b8:       d4 01 a0 08     l.sw 8(r1),r20
c00099bc:       1a 80 00 00     l.movhi r20,0x0
c00099c0:       d4 01 10 0c     l.sw 12(r1),r2

PC reported c00097fc

c0009798 <unwind_stack>:
c0009798:       9e 24 00 03     l.addi r17,r4,3
c000979c:       a6 31 1f fc     l.andi r17,r17,0x1ffc
c00097a0:       1a 60 00 00     l.movhi r19,0x0
c00097a4:       e4 11 98 00     l.sfeq r17,r19
c00097a8:       10 00 00 49     l.bf c00098cc <unwind_stack+0x134>
c00097ac:       15 00 00 00     l.nop 0x0
c00097b0:       9c 21 ff e4     l.addi r1,r1,-28
c00097b4:       d4 01 80 00     l.sw 0(r1),r16
c00097b8:       d4 01 90 04     l.sw 4(r1),r18
c00097bc:       d4 01 a0 08     l.sw 8(r1),r20
c00097c0:       d4 01 b0 0c     l.sw 12(r1),r22
c00097c4:       d4 01 c0 10     l.sw 16(r1),r24
c00097c8:       d4 01 10 14     l.sw 20(r1),r2
c00097cc:       d4 01 48 18     l.sw 24(r1),r9
c00097d0:       9c 41 00 1c     l.addi r2,r1,28
c00097d4:       e2 43 18 04     l.or r18,r3,r3
c00097d8:       e2 85 28 04     l.or r20,r5,r5
c00097dc:       9e 04 00 07     l.addi r16,r4,7
c00097e0:       1a c0 00 00     l.movhi r22,0x0
c00097e4:       00 00 00 06     l.j c00097fc <unwind_stack+0x64>
c00097e8:       ab 00 00 01     l.ori r24,r0,0x1
c00097ec:       1a 60 00 00     l.movhi r19,0x0
c00097f0:       e4 31 98 00     l.sfne r17,r19
c00097f4:       0c 00 00 2a     l.bnf c000989c <unwind_stack+0x104>
c00097f8:       9e 10 00 04     l.addi r16,r16,4
c00097fc:       04 00 9b b7     l.jal c00306d8 <__kernel_text_address>  <--- PC is reported here
c0009800:       84 70 ff f5     l.lwz r3,-11(r16)
c0009804:       1a 20 00 00     l.movhi r17,0x0

from linux.

stffrdhrn avatar stffrdhrn commented on June 25, 2024

This is fixed with the following patch. However, the stack traces don't look so hot.

For example:

 # cat /proc/2/stack 
[<0>] lock_acquire+0x118/0x4b8

Compared to the x86 stack for kthread:

# sudo cat /proc/2/stack
[<0>] kthreadd+0x2d0/0x2f0
[<0>] ret_from_fork+0x35/0x40
diff --git a/arch/openrisc/kernel/stacktrace.c b/arch/openrisc/kernel/stacktrace.c
index 43f140a28bc7..ac91614509c8 100644
--- a/arch/openrisc/kernel/stacktrace.c
+++ b/arch/openrisc/kernel/stacktrace.c
@@ -13,6 +13,7 @@
 #include <linux/export.h>
 #include <linux/sched.h>
 #include <linux/sched/debug.h>
+#include <linux/sched/task_stack.h>
 #include <linux/stacktrace.h>
 
 #include <asm/processor.h>
@@ -68,12 +69,17 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 {
        unsigned long *sp = NULL;
 
+       if (!try_get_task_stack(tsk))
+               return;
+
        if (tsk == current)
                sp = (unsigned long *) &sp;
        else
-               sp = (unsigned long *) KSTK_ESP(tsk);
+               sp = (unsigned long *) task_thread_info(tsk)->ksp;
 
        unwind_stack(trace, sp, save_stack_address_nosched);
+
+       put_task_stack(tsk);
 }

from linux.

stffrdhrn avatar stffrdhrn commented on June 25, 2024

fix queued for merge in 5.9 window

from linux.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.