Linux kernel's ftrace output format

2019-06-04 05:10发布

I'm using ftrace on Android on a couple of different devices, but I noticed that the output format differs between them. In some cases, the TGID of the current process is included, while in others, it is not.

The TGID is very useful in the current application I'm using ftrace on, and I'm wondering how I could enable that. I'm aware of the sysfs file "/sys/kernel/debug/tracing/options/print-tgid", but this isn't available on my devices, unfortunately. Are there any kernel options or ftrace handles that can be used to add TGID to the ftrace output format?

#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
#                    ^^ (no tgid...)

vs

#                                      _-----=> irqs-off
#                                     / _----=> need-resched
#                                    | / _---=> hardirq/softirq
#                                    || / _--=> preempt-depth
#                                    ||| /     delay
#           TASK-PID    TGID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |        |      |   ||||       |         |
#                        ^^^(tgid is available in this column!)

1条回答
趁早两清
2楼-- · 2019-06-04 06:04

I pinpointed where this functionality was added. Only very new versions of the Android branch of the linux kernel have tgid info available, and no vanilla Linux kernel versions (that I'm aware of). If you apply the patch from https://android.googlesource.com/kernel/common/+/d34f20303f234fb6eae16548055766916cae7c2b%5E!/ to the kernel source tree and build, you should be set. You might have to manually apply the enums in the patch, but you should be set once this is added.

查看更多
登录 后发表回答