2

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?

0

1 Answer 1

3

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 mount debugfs for security reasons. That is because any subsystem may use debugfs 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 with debugfs, the tracing directory is still created under debugfs and tracefs 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)
1
  • Note that the mounting of /sys/kernel/debug/tracing can be disabled by "CONFIG_TRACEFS_DISABLE_AUTOMOUNT=y".
    – Étienne
    May 30 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.