How does ftrace track interrupt service routines?

血红的双手。 提交于 2019-12-11 07:04:32

问题


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.


回答1:


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.

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.

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.



来源:https://stackoverflow.com/questions/41534450/how-does-ftrace-track-interrupt-service-routines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!