Kernel Marker
   HOME

TheInfoList



OR:

Kernel markers were a static kernel instrumentation support mechanism for
Linux kernel The Linux kernel is a Free and open-source software, free and open source Unix-like kernel (operating system), kernel that is used in many computer systems worldwide. The kernel was created by Linus Torvalds in 1991 and was soon adopted as the k ...
source code, allowing special tools such as
LTTng LTTng (Linux Trace Toolkit: next generation) is a system software package for correlated tracing of the Linux kernel, applications and libraries. The project was originated by Mathieu Desnoyers with an initial release in 2005. Its predecessor is ...
Tracepoints and Markers
, LTTng's Tracing Wiki
or
SystemTap In computing, SystemTap () is a scripting language and tool for dynamically instrumenting running production Linux-based operating systems. System administrators can use SystemTap to extract, filter and summarize data in order to enable diagnosi ...
Using Markers
SystemTap Wiki
to
trace Trace may refer to: Arts and entertainment Music * ''Trace'' (Son Volt album), 1995 * ''Trace'' (Died Pretty album), 1993 * Trace (band), a Dutch progressive rock band * ''The Trace'' (album), by Nell Other uses in arts and entertainment * ...
information exposed by these probe points. Kernel markers were declared in the kernel code by one-liners of the form: trace_mark(name, format_string, ...); Where name is the marker's unique name, and format_string describes the remaining arguments' types. A marker can be on or off depending on whether a probe is connected to it or not. Code which wants to hook into a trace point first calls: int marker_probe_register(const char *name, const char *format_string, marker_probe_func *probe, void *pdata); to register its probe callback with the marker point (pdata is a private data value that the code wants to pass to the probe). Later, the probe is turned on and off using: int marker_arm(const char *name); int marker_disarm(const char *name); Using markers has a negligible overhead thanks in part to ''Immediate Values'',Mathieu Desnoyers
[patch 08/10
/nowiki> Immediate Value - Documentation">atch 08/10">[patch 08/10
/nowiki> Immediate Value - Documentation/ref> another support mechanism that embeds switches in the code that can be dynamically turned on and off, without using a memory reference and thus saving cache lines.Mathieu Desnoyers
[patch 7/8
/nowiki> Immediate Values - Documentation]
The initial motivation to create this static instrumentation infrastructure was the large performance overhead induced by the predating dynamic instrumentation mechanism Kprobe mechanism, which depends on
breakpoint In software development, a breakpoint is an intentional stopping or pausing place in a computer program, program, put in place for debugging purposes. It is also sometimes simply referred to as a pause. More generally, a breakpoint is a means o ...
s. Static instrumentation can also more easily survive source code changes because the markers are in the source code. Kernel Markers consisted essentially of a C preprocessing macro which added, in the instrumented function, a branch over a
function call In computer programming, a function (also procedure, method, subroutine, routine, or subprogram) is a callable unit of software logic that has a well-defined interface and behavior and can be invoked multiple times. Callable units provide a p ...
. By doing so, neither the
stack Stack may refer to: Places * Stack Island, an island game reserve in Bass Strait, south-eastern Australia, in Tasmania’s Hunter Island Group * Blue Stack Mountains, in Co. Donegal, Ireland People * Stack (surname) (including a list of people ...
setup nor the function call are executed when instrumentation is not enabled. By identifying the branch executing stack setup and function call as unlikely (using the gcc built-in expect()), a hint is given to the
compiler In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
to position the tracing instructions away from
cache line A CPU cache is a hardware cache used by the central processing unit (CPU) of a computer to reduce the average cost (time or energy) to access data from the main memory. A cache is a smaller, faster memory, located closer to a processor core, which ...
s involved in standard kernel execution.Mathieu Desnoyers
''Low-Impact Operating System Tracing''
Ph. D. Dissertation, Département de génie informatique et génie logiciel, École Polytechnique de Montréal, Université de Montréal, December 2009
Two Kernel Markers drawbacks were identified which led to its replacement by
Tracepoint 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, ftra ...
s: * Type verification was limited to scalar types because the API is based on format strings. This could be problematic if pointers must be dereferenced by the tracer code. * The Markers "hide" the instrumentation in the source code, keeping no global registry of the instrumentation. This makes namespace conventions and tracking of instrumentation modification difficult unless the whole kernel tree is monitored. A patch-set implementing them was merged into version 2.6.24,Linux 2.6.24 Changelog
Linux Kernel Newbies
which was released on January 24, 2008. To address issues regarding kernel markers, Mathieu Desnoyers, their original author, implemented a simpler and more type-safe version of static probe points named
Tracepoint 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, ftra ...
s. A patch-set implementing Tracepoints was merged into version 2.6.28,Linux 2.6.28 Changelog
Linux Kernel Newbies
which was released on December 25, 2008. Starting then, kernel markers were slowly removed from kernel sources and eventually fully removed in Linux kernel 2.6.32,Linux 2.6.32 Changelog
Linux Kernel Newbies
Christoph Hellwig
fc537766
tracing: Remove markers, Torvalds' Linux git tree
which was released on December 3, 2009.


See also

*
Kernel debugger A kernel debugger is a debugger present in some operating system kernels to ease debugging and kernel development by the kernel developers. A kernel debugger might be a stub implementing low-level operations, with a full-blown debugger such as GN ...


References

{{Reflist


External links

* Jonathan Corbet,
Kernel markers
', LWN.net, 2007 * Mathieu Desnoyers,
Using the Linux Kernel Markers
',
Linux kernel The Linux kernel is a Free and open-source software, free and open source Unix-like kernel (operating system), kernel that is used in many computer systems worldwide. The kernel was created by Linus Torvalds in 1991 and was soon adopted as the k ...
documentation, 2008 * Jonathan Corbet,
Tracing: no shortage of options
', LWN.net, 2008 Linux kernel features