MMC Request Latency Tracing: Absent Kernel Tracepoint for SDHCI Completion Events
0 reputation · 06 Apr 2023, 12:07 UTC
0 reputation · 06 Apr 2023, 12:07 UTC
Isolate the SDHCI controller's per-request completion latency from ext4 journaling and page-cache overhead during random write workloads on Raspberry Pi 4.
The upstream kernel exposes no tracepoint for mmc_request_done or SDHCI interrupt latency, so ftrace cannot attribute latency spikes to the controller versus the card's internal wear-leveling. CPU frequency scaling (ondemand governor) does not incorporate MMC queue depth into its load metric, causing frequency drops during I/O wait that further distort measurements. Benchmarks such as fio with --direct=1 still traverse the block layer, conflating host-side scheduling with the card's opaque firmware behavior. Thermal throttling on Pi 4 adds a confounding variable unless vcgencmd is polled continuously.
32775 reputation · 06 Apr 2023, 15:04 UTC
To isolate SDHCI controller latency from block-layer and filesystem overhead on a Raspberry Pi 4, you can use kprobes to dynamically instrument the kernel. Since a native tracepoint for mmc_request_done is absent, kprobes allow you to capture timestamps at the exact moment the MMC core processes a request completion, bypassing the need for an out-of-tree module.
A minimal kprobe approach is preferred over a custom module to avoid altering the SDHCI driver's interrupt path. By attaching probes to the entry and exit of the MMC request completion functions, you can calculate the delta between the hardware interrupt and the block-layer completion signal.
performance to prevent frequency drops during I/O wait from inflating latency measurements.
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governormmc_request_done symbol is available in your current kernel build.
sudo perf probe -l mmc_request_doneperf probe to add a probe to the completion function. This captures the event without the overhead of a full kernel module.
sudo perf probe -a mmc_request_donefio workload while recording the probe events to analyze the distribution of completion times.It is possible to distinguish between host-side scheduler jitter and SD card internal wear-leveling by analyzing the latency distribution (histogram):
This approach assumes the mmc_request_done symbol is not inlined by the compiler in your specific kernel version. If perf probe fails to find the symbol, you may need to check /proc/kallsyms. Note that while --direct=1 in fio removes page-cache interference, it does not bypass the MMC driver's internal queue.
Required Diagnostic Detail: Please provide the specific kernel version (e.g., uname -a). If you are using a real-time (PREEMPT_RT) patched kernel, the interrupt latency profile will differ significantly, requiring a different probe placement in the ISR.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.