funcslower(8)
π funcslower β bestie's guide to catching slow kernel functions π
okay so real talk, this is a page from the System Manager's Manual (section 8, the big-girl admin section π
), and it's all about funcslower. It traces kernel functions that are being slower than a threshold, measured in microseconds, and it does it with Linux ftrace. Let's get into it π¦
β¨ NAME β¨
funcslower β trace kernel functions slower than a threshold (microseconds). Uses Linux ftrace.
β¨ SYNOPSIS β¨
funcslower [-aChHPt] [-p PID] [-L TID] [-d secs] funcstring latency_us
β¨ DESCRIPTION β¨
So here's the vibe: this tool uses the Linux ftrace function graph profiler to time kernel functions, and then filters them by a latency threshold. Latency outliers? You can study them this way β confirming they exist, how long they take, and how often they show up. Lowkey iconic for debugging. This tool is a proof of concept using Linux ftrace capabilities on older kernels. (Yes, on older kernels. She's a throwback π)
The output format is based on the ftrace function graph trace format, which is described in the kernel source under Documentation/trace/ftrace.txt. Use the -H option to print column headings. And heads up bestie β the output may be shuffled when different CPU buffers are read. So check the CPU column for changes, or include timestamps (-t) and post sort. π
β οΈ WARNING: This uses dynamic tracing of kernel functions, and could cause kernel panics or freezes. Test, and know what you are doing, before use. Like, actually know what you're doing. Not "I skimmed a blog post" know. π
Also: since this uses ftrace, only the root user can use this tool. periodt.
β¨ REQUIREMENTS β¨
- FTRACE function graph, which you may already have enabled and available on recent kernels π
- And
awk. Yeah, awk. She's doing the heavy lifting as always.
β¨ OPTIONS β¨
-aβ All info. Same as-HPt. Give me everything, no gatekeeping π-Cβ Function durations measure on-CPU time only (exclude sleep time). So like, only the time she was actually awake and working.-dseconds β Set the duration of tracing, in seconds. Trace output will be buffered and printed at the end. This also reduces overheads by buffering in-kernel, instead of printing events as they occur.- The ftrace buffer has a fixed size per-CPU (see
/sys/kernel/debug/tracing/buffer_size_kb). If you think events are missing, try increasing that size. fr fr, check it.
- The ftrace buffer has a fixed size per-CPU (see
-hβ Print usage message.-Hβ Print column headers. Labels, bestie. We love labels β¨-pPID β Only trace kernel functions when this process ID is on-CPU.-LTID β Only trace kernel functions when this thread ID is on-CPU.-Pβ Show process names and process IDs with every line of output.-tβ Show timestamps on every line of output.- funcstring β A function name to trace, which may include file glob style wildcards (
"*") at the beginning or ending of a string only. Eg,"vfs*"means match"vfs"followed by anything. Since the output is verbose, you probably only want to trace single functions, and not use wildcards. (Wildcards = chaos = a wall of text π) - latency_us β Minimum function duration to trace, in units of microseconds. This is filtered in-kernel. slay.
β¨ EXAMPLES β¨
Trace calls to vfs_read(), showing events slower than 10 ms:
# funcslower vfs_read 10000
Same as above, but include column headers, event timestamps, and process names:
# funcslower -HPt vfs_read 10000
Trace slow vfs_read()s for PID 198 only:
# funcslower -p 198 vfs_read 10000
β¨ FIELDS β¨
The output format depends on the kernel version, and headings can be printed using -H. The format is the same as the ftrace function trace format, described in the kernel source under Documentation/trace/ftrace.txt.
Typical fields are:
TIMEβ (Shown with-t.) Time of event, in seconds. β°CPUβ The CPU this event occurred on.TASK/PIDβ (Shown with-P.) The process name (which could include dashes), a dash, and the process ID.DURATIONβ Elapsed time during the function call, inclusive of children. This is also inclusive of sleep time, unless-Cis used.FUNCTION CALLSβ Kernel function returns.
β¨ OVERHEAD β¨
OVERHEADS: Timing and filtering is performed in-kernel context, costing lower overheads than post-processing in user space. If you trace frequent events (eg, pick a common function and a low threshold), you might want to try the "-d secs" option, which buffers events in-kernel instead of printing them live. π§
It's a good idea to start with a high threshold (eg, "100000" for 100 ms) then to decrease it. If you start low instead, you may start printing too many events. (Not the glow-up you wanted, bestie π)
β¨ SOURCE β¨
This is from the perf-tools collection:
https://github.com/brendangregg/perf-tools
Also look under the examples directory for a text file containing example usage, output, and commentary for this tool. π
β¨ OS β¨
Linux π§
β¨ STABILITY β¨
Unstable β in development. She's still growing, okay?? π±
β¨ AUTHOR β¨
Brendan Gregg π
β¨ SEE ALSO β¨
funccount(8), functrace(8), funcgraph(8), kprobe(8)
and that's the whole page bestie!! this one came out of the USER COMMANDS collection on 2014-07-30, filed under funcslower(8) β go forth and catch those slow functions π
β¨
π¦ where this page comes from
- debian bookworm: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1 Β· GPL-2.0-or-later
- debian trixie: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1 Β· GPL-2.0-or-later
- ubuntu jammy: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu1 Β· GPL-2.0-or-later
- ubuntu noble: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu1 Β· GPL-2.0-or-later
- ubuntu resolute: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu2 Β· GPL-2.0-or-later
- ubuntu stonking: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms