fs: Add Kernel-level VFS Performance Profiler
Build Documentation / build-html (push) Has been cancelled

This adds a kernel-level performance profiler for the VFS.
By enabling CONFIG_FS_PROFILER, the core VFS system calls
(file_read, file_write, file_open, and file_close) are
instrumented to track high-resolution execution times using
clock_systime_timespec() seamlessly.

The collected statistics are exposed dynamically via a new
procfs node at /proc/fs/profile, allowing CI regression
testing without needing external debugging tools.

Signed-off-by: Sumit6307 <sumitkesar6307@gmail.com>
This commit is contained in:
Sumit6307
2026-03-26 01:04:12 +05:30
committed by Alan C. Assis
parent 727502ea9b
commit b2b78d2f8a
17 changed files with 316 additions and 0 deletions
@@ -543,6 +543,7 @@ NuttX provides support for a variety of file systems out of the box.
nxffs.rst
partition.rst
procfs.rst
profiler.rst
romfs.rst
rpmsgfs.rst
smartfs.rst
@@ -0,0 +1,38 @@
==============================
VFS Performance Profiler
==============================
The Virtual File System (VFS) Performance Profiler provides a simple, in-kernel
mechanism to track execution times and invocation counts for core VFS operations
(read, write, open, close) seamlessly. This is highly suitable for
CI/CD automated regression testing and performance bottleneck identification.
Configuration
=============
To enable the profiler, select ``CONFIG_FS_PROFILER`` in your Kconfig.
To expose the metrics dynamically via procfs, ensure ``CONFIG_FS_PROCFS`` is enabled, and
the profiler node is included via ``CONFIG_FS_PROCFS_PROFILER``.
Usage
=====
When enabled, the profiler automatically intercepts calls to the underlying
inode operations and records the execution elapsed times using ``perf_gettime()``.
Since no blocking mutexes are used during updates (fast ``atomic.h`` operations
are utilized instead), the overhead is extremely minimal and safely scales on SMP.
To view the current statistics collectively from the NuttShell (NSH), simply
read the node:
.. code-block:: bash
nsh> cat /proc/fs/profile
VFS Performance Profile:
Reads: 12 (Total time: 4500120 ns)
Writes: 3 (Total time: 95050 ns)
Opens: 15 (Total time: 1005000 ns)
Closes: 15 (Total time: 45000 ns)
The reported times are in the raw ticks/units provided by ``perf_gettime()`` on
your specific architecture.