______ ______ _ _ _____
| ____| ____| | | |/ ____|
| |__ | |__ | |__| | (___
| __| | __| | __ |\___ \
| |____| | | | | |____) |
|______|_| |_| |_|_____/
eBPF Filesystem Health Sensor
EFHS is a small eBPF tool to measure block I/O latency and spot drive performance spikes. It uses libbpf and CO-RE to hook into the kernel block layer safely.
- MVP Goals: Track I/O latency (issue to completion), show p50/p95/p99 percentiles, and test it against simulated slow drives (
null_blk/dm-delay) usingfio. - Non-Goals: I am not targeting hardware RAID, complex GUIs, or process tracking for the initial version.
The tool has two main parts:
- Kernel (
src/ebpf/): Hooks intoblock_rq_issueandblock_rq_complete. It saves the start time of an I/O request in a BPF Hash Map using thestruct request *pointer as the key, then calculates the duration on completion. - Userspace (
src/userspace/): Loads the BPF program, reads the timestamps via a BPF Ring Buffer, and prints the metrics.
EFHS
├── Makefile
├── README.md
├── src/
│ ├── ebpf/ # sensor.bpf.c (eBPF C code)
│ ├── userspace/ # main.c (Loader and dashboard)
│ └── shared/ # common.h (Shared structs)
├── include/
├── docs/
└── tests/ # Test scripts and virtual disk setup
- Phase 1: The Skeleton - COMPLETED
- Set up standalone libbpf-bootstrap project.
- Hook into
block_rq_issueand verify events show up. - Move data tracking from
trace_pipeto a BPF Ring Buffer. - Calculate basic latency delta (completion time - issue time).
- Implement latency threshold flagging (e.g., mark requests exceeding 100ms as degraded).
- Build
dm-delaylab script to simulate bad sectors and drive stalls. - Add basic latency aggregation (tracking min/max/average and histogram buckets).
- Export structured metrics/events for external consumers (JSON/CLI streaming).
The following features are for extended work:
- MD RAID Topology Mapping: Correlating physical block layer delays to Linux MD software RAID arrays.
- TUI/Dashboard Interface: Custom
ncurses-based terminal UI for live drive health monitoring. - Overhead Benchmarking: Micro-benchmarking eBPF ring buffer strain under extreme I/O workloads.
Requires clang, llvm, libelf-dev, and bpftool.
To compile the eBPF bytecode and userspace app use make
Run the userspace loader:
sudo ./efhs-appTo see raw debug logs out of the kernel sensor during development:
sudo cat /sys/kernel/debug/tracing/trace_pipe- June 2026: Got the build system working. Verified that the
block_rq_issuehook is successfully catching background disk I/O from system daemons likekworkerandjbd2. - July 2026: Streamlined the build system to link against global system dependencies (
-lbpfand systembpftool) rather than compiling them locally. Kernel code made to push live structures into a BPF Ring Buffer, eliminating the need to readtrace_pipeand allowing the userspace C app to process and print structured I/O events in actively.
- ebpf.io (General architecture)
- Kernel.org BPF Maps (Hash map details)
- Man7 bpf-helpers (Helper function signatures)
- eBPF Docs Reference (Interactive helper guide)