ArticleslgStudy

computer science

Ftrace

Ftrace is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Ftrace rather than just read about it. In short: ftrace (Function Tracer) is a tracing framework for the Linux kernel. Although its original name, Function Tracer, came from ftrace's ability to record information related to various function calls performed while the kernel is running, ftrace's tracing capabilities cover a much broader range of kernel's internal operations.

Key takeaways

  • Ftrace belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Ftrace to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Ftrace from memory before moving on to harder problems.

Reference excerpt

ftrace (Function Tracer) is a tracing framework for the Linux kernel. Although its original name, Function Tracer, came from ftrace's ability to record information related to various function calls performed while the kernel is running, ftrace's tracing capabilities cover a much broader range of kernel's internal operations.

Details With its various tracer plugins, ftrace can be targeted at different static tracepoints, such as scheduling events, interrupts, memory-mapped I/O, CPU power state transitions, and operations related to file systems and virtualization. Also, dynamic tracking of kernel function calls is available, optionally restrictable to a subset of functions by using globs, and with the possibility to generate call graphs and provide stack usage reports. At the same time, ftrace can be used to measure various latencies within the Linux kernel, such as for how long interrupts or preemption are disabled. An ftrace-enabled Linux kernel is built by enabling the CONFIG_FUNCTION_TRACER kernel configuration option. The entire runtime interaction with ftrace is performed through readable and writable virtual files contained in a specifically mounted debugfs file system; as a result, ftrace requires no specialized userspace utilities to operate. However, there are additional userspace utilities that provide more advanced features for data recording, analysis and visualization; examples of such utilities are trace-cmd and KernelShark. Internally, ftrace relies on the gcc's profiling mechanism to prepend machine instructions to the compiled versions of all source-level kernel functions, which redirect the execution of functions to the ftrace's trampolines and tracer plugins that perform the actual tracing. These "entry point" instructions created by gcc are altered by ftrace when the kernel is booted, and varied later at runtime by ftrace between NOPs and actual jumps to the tracing trampolines, depending on the tracing types and options configured at runtime. ftrace is developed primarily by Steven Rostedt, and it was merged into the Linux kernel mainline in kernel version 2.6.27, which was released on October 9, 2008.

See also

DTrace – a tracing framework for troubleshooting kernel and application problems, originally developed for Solaris ktrace – a BSD Unix and Mac OS X utility that traces kernel–program interactions ltrace – a Linux debugging utility, displays the calls a userland application makes to shared libraries strace – a debugging utility for Linux and some other Unix-like systems, monitors system calls used by a program and all received signals SystemTap – a scripting language and utility used for instrumenting Linux systems

References

External links Debugging the kernel using Ftrace – part 1 and part 2, LWN.net, December 2009, by Steven Rostedt Secrets of the Ftrace function tracer, LWN.net, January 20, 2010, by Steven Rostedt Ftrace: The hidden light switch, LWN.net, August 13, 2014, by Brendan Gregg The source of the e1000e corruption bug, LWN.net, October 21, 2008, by Jonathan Corbet

Worked examples

Example 1 — a first encounter with Ftrace

Start with the simplest possible case. Write down what Ftrace claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Ftrace before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Ftrace ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Ftrace

In research
Ftrace appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Ftrace in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Ftrace is common in secondary-school and first-year university syllabi. It links to neighbouring topics Debugging, Free software programmed in C, Linux kernel features, so understanding it makes those chapters shorter.
In everyday life
Look for Ftrace outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Ftrace” →

How to study Ftrace in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Ftrace means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Ftrace out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Ftrace in simple terms?

ftrace (Function Tracer) is a tracing framework for the Linux kernel. Although its original name, Function Tracer, came from ftrace's ability to record information related to various function calls performed while the kernel is running, ftrace's tracing capabilities cover a much broader range of ke…

Why does Ftrace matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Ftrace?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Ftrace.

Tags

  • Debugging
  • Free software programmed in C
  • Linux kernel features
  • Software using the GNU General Public License
  • Unix programming tools

Keep exploring