How do tracefs
and debugfs
differ? It looks like both can trace functions, system calls, etc. When to go for debugfs
and when should we should use tracefs
?
1 Answer
You should use /sys/kernel/tracing
. Both /sys/kernel/tracing
and /sys/kernel/debug/tracing
are tracefs
mounts, so in theory they are equivalent. However, the second one depends on debugfs
being available (since it is created inside the debugfs
mount).
Before tracefs
was introduced, tracing was only available through debugfs
, so the entry in debugfs
(/sys/kernel/debug/tracing
) was kept for backward compatibility with old applications. Now tracing does not depend on debugfs
anymore and tracefs
has its own separate mount point (/sys/kernel/tracing
).
See the relevant patch:
There has been complaints that tracing is tied too much to
debugfs
, as there are systems that would like to perform tracing, but do not mountdebugfs
for security reasons. That is because any subsystem may usedebugfs
for debugging, and these interfaces are not always tested for security.[...]
To maintain backward compatibility with older tools that expect that the
tracing
directory is mounted withdebugfs
, thetracing
directory is still created underdebugfs
andtracefs
is automatically mounted there.
And indeed:
$ mount -t tracefs
tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)
tracefs on /sys/kernel/debug/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)
-
Note that the mounting of /sys/kernel/debug/tracing can be disabled by "CONFIG_TRACEFS_DISABLE_AUTOMOUNT=y".– ÉtienneMay 30 at 9:42