问题描述
ftrace
用于内核的函数跟踪.现在它是如何处理中断的.它可以在中断模式下跟踪内核函数吗?如果是这样,你能解释一下它是如何工作的.我正在尝试编写一个跟踪函数调用的函数,它在 Supervisor 模式下工作正常,但在中断模式下不起作用(进入循环).我需要让它在 IRQ 模式下工作.
ftrace
is used for function tracing of kernel. Now how does it work for interrupts. Can it track kernel functions in interrupt mode. If so can you explain how it works. I am trying to write a function that tracks function calls and it works fine in Supervisor mode but does not work in interrupt mode (goes into loop). I need to make it work in IRQ mode.
推荐答案
如 Linux内核 ARM 异常堆栈 init 详细信息,Linux 使用的 IRQ 堆栈量是最小的.ARM 有几个存储寄存器,包括用于 IRQ 模式的 lr
和 sp
.在 Linux ARM 内核中,这些寄存器仅用于将信息传输到主管 (8K) 堆栈.这个监督栈是按内核进程分配的,还包含一个任务上下文块,带有指向内存管理器、调度器和文件系统的指针 信息.
As in Linux kernel ARM exception stack init details, the amount of IRQ stack used by Linux is minimal. ARM has several banked registers including lr
and sp
for the IRQ modes. In the Linux ARM kernel, these registers are used only briefly to transfer information to the supervisor (8K) stack. This supervisor stack is allocate per kernel process and also contain a task context block with pointers to the memory manager, scheduler and file system information.
因此在 Linux 中,supervisor stack 具有所有模式的堆栈信息,包括 FIQ、IRQ、未定义指令、数据和指令错误.这意味着只需要跟踪一个堆栈.特殊信息(伪汇编器)包含在 entry-armv.S,例如UNWIND(.fnend)
和ENDPROC(__irq_usr)
内核使用 ELF 信息创建展开表,允许堆栈跟踪代码了解堆栈上的数据布局.
So in Linux, the supervisor stack has the stack information for all modes, including FIQ, IRQ, undefined instruction, data and instruction faults. This means only one stack needs to be traced. Special information (pseudo assembler) is included in entry-armv.S, such as UNWIND(.fnend)
and ENDPROC(__irq_usr)
which annotate the kernel with ELF information to create unwind tables that allow the stack tracing code to understand the layout of data on the stack.
ARM Linux 中的矢量页面映射有一些额外的细节,例如作为 vector_name
进行堆栈/模式切换的汇编宏.vector_name
汇编宏是唯一在 IRQ 模式下实际执行的代码.irq_usr
和 irq_svc
在主管模式下执行,使用主管堆栈.
Vector page mapping in ARM Linux has some additional details such as the vector_name
assembler macro which does the stack/mode switching. The vector_name
assembler macro is the only code that actually executes in IRQ mode. irq_usr
and irq_svc
execute in supervisor mode, with the supervisor stack.
这篇关于ftrace 如何跟踪中断服务例程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!