What is the difference between procfs, sysfs and debugfs?
Short answer: procfs (/proc) exposes process information and some legacy kernel tunables (/proc/cpuinfo, /proc/<pid>/maps, /proc/sys/ sysctls); new device data should not go there. sysfs (/sys) exposes the structured device model with one value per file and is a stable ABI. debugfs (/sys/kernel/debug) is a free-form debugging interface with no ABI guarantees, usually root-only and often disabled in production kernels.
| procfs | sysfs | debugfs | |
|---|---|---|---|
| Purpose | processes, system info, sysctls | devices, drivers, buses, classes | debugging |
| Format | free-form text | one value per file | anything |
| ABI stability | yes (for existing files) | yes | no |
| Typical use | ps, top, free read it |
udev, configuration tools, power management | register dumps, statistics, fault injection, tracing (tracefs) |
| Driver API | proc_create (discouraged for drivers) |
DEVICE_ATTR_*, attribute groups |
debugfs_create_file/u32/regset32 |
debugfs example: debugfs_create_regset32("regs", 0400, dir, &d->regset) dumps a list of registers; debugfs_create_u32("irq_count", 0444, dir, &d->irq_count) exposes a counter. Errors from debugfs functions can be ignored by design (debugging must not break the driver).
Other pseudo-filesystems: configfs (user space creates kernel objects: USB gadgets, iSCSI targets), tracefs (/sys/kernel/tracing), cgroupfs, bpffs, securityfs.