如何使ftrace function_graph跟踪程序可以使用linux内核函数?

时间:2022-03-15 02:03:30

I want to trace a function during kernel boot process with ftrace function_graph to understand what it does, but it is not available in available_filter_functions.

我想用ftrace function_graph在内核引导过程中跟踪一个函数,以了解它的作用,但是在available_filter_functions中是不可用的。

I tried to export it with EXPORT_SYMBOL(), guessing that it will made it available but this is not the case.

我尝试用EXPORT_SYMBOL()导出它,猜测它将使它可用,但事实并非如此。

Do you have a solution ?

你有解决办法吗?

For information, functions I want to trace are persistent_ram_init_ringbuffer and persistent_ram_early_init in Android kernel 3.4.

关于信息,我要跟踪的函数是Android内核3.4中的persistent_ram_init_ringbuffer和persistent_ram_early_init。

I read through the documentation but found nothing on this and grep did not helped more...

我看了文件,但没有发现什么,grep没有帮助更多……

Thanks

谢谢

2 个解决方案

#1


8  

The problem is that those functions are annotated with __init and __devinit, which are black listed by ftrace function tracer.

问题是这些函数是用__init和__devinit注释的,这是ftrace函数跟踪程序列出的黑色。

Why? Because as module init functions (or kernel init functions) they are loaded during initialization and removed when the initialization is complete. Every function that ftrace traces is kept in a special compact table. Currently, there's no way to tell ftrace that those functions have been removed (freed) and that ftrace should remove them from its table. If we were to just ignore that, then when function tracing is enabled, ftrace will try to modify locations that no longer exist and can cause all sorts of issues (remember the e1000e bug?).

为什么?因为作为模块init函数(或内核init函数),它们在初始化过程中被加载,在初始化完成时被删除。ftrace跟踪的每个函数都保存在一个特殊的紧凑表中。目前,没有办法告诉ftrace这些函数已经被删除(释放),而ftrace应该从表中删除它们。如果我们忽略这一点,那么当启用函数跟踪时,ftrace将尝试修改不再存在并可能导致各种问题的位置(还记得e1000e bug吗?)

If you really want to trace them, then remove those annotations. Then they should appear in the list of functions to trace.

如果您真的想跟踪它们,那么删除那些注释。然后它们应该出现在要跟踪的函数列表中。

#2


1  

http://lwn.net/Articles/370423/

http://lwn.net/Articles/370423/

http://www.mjmwired.net/kernel/Documentation/trace/ftrace.txt

http://www.mjmwired.net/kernel/Documentation/trace/ftrace.txt

these links might help. first is thing i found by googling. second is ftrace documentation

这些链接可能会有所帮助。首先是我在谷歌上找到的东西。二是ftrace文档

#1


8  

The problem is that those functions are annotated with __init and __devinit, which are black listed by ftrace function tracer.

问题是这些函数是用__init和__devinit注释的,这是ftrace函数跟踪程序列出的黑色。

Why? Because as module init functions (or kernel init functions) they are loaded during initialization and removed when the initialization is complete. Every function that ftrace traces is kept in a special compact table. Currently, there's no way to tell ftrace that those functions have been removed (freed) and that ftrace should remove them from its table. If we were to just ignore that, then when function tracing is enabled, ftrace will try to modify locations that no longer exist and can cause all sorts of issues (remember the e1000e bug?).

为什么?因为作为模块init函数(或内核init函数),它们在初始化过程中被加载,在初始化完成时被删除。ftrace跟踪的每个函数都保存在一个特殊的紧凑表中。目前,没有办法告诉ftrace这些函数已经被删除(释放),而ftrace应该从表中删除它们。如果我们忽略这一点,那么当启用函数跟踪时,ftrace将尝试修改不再存在并可能导致各种问题的位置(还记得e1000e bug吗?)

If you really want to trace them, then remove those annotations. Then they should appear in the list of functions to trace.

如果您真的想跟踪它们,那么删除那些注释。然后它们应该出现在要跟踪的函数列表中。

#2


1  

http://lwn.net/Articles/370423/

http://lwn.net/Articles/370423/

http://www.mjmwired.net/kernel/Documentation/trace/ftrace.txt

http://www.mjmwired.net/kernel/Documentation/trace/ftrace.txt

these links might help. first is thing i found by googling. second is ftrace documentation

这些链接可能会有所帮助。首先是我在谷歌上找到的东西。二是ftrace文档