From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
"Frank Ch. Eigler" <fche@redhat.com>,
Christoph Hellwig <hch@infradead.org>
Subject: [patch 5/5] Linux Kernel Markers - Documentation
Date: Fri, 28 Sep 2007 10:28:50 -0400 [thread overview]
Message-ID: <20070928143200.257494978@polymtl.ca> (raw)
In-Reply-To: 20070928142845.795281397@polymtl.ca
[-- Attachment #1: linux-kernel-markers-documentation.patch --]
[-- Type: text/plain, Size: 4250 bytes --]
Here is some documentation explaining what is/how to use the Linux
Kernel Markers.
Changelog:
- Move the examples to a separate "samples" patch.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Acked-by: "Frank Ch. Eigler" <fche@redhat.com>
CC: Christoph Hellwig <hch@infradead.org>
---
Documentation/markers.txt | 81 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
Index: linux-2.6-lttng/Documentation/markers.txt
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/Documentation/markers.txt 2007-09-24 17:44:56.000000000 -0400
@@ -0,0 +1,81 @@
+ Using the Linux Kernel Markers
+
+ Mathieu Desnoyers
+
+
+This document introduces Linux Kernel Markers and their use. It provides
+examples of how to insert markers in the kernel and connect probe functions to
+them and provides some examples of probe functions.
+
+
+* Purpose of markers
+
+A marker placed in code provides a hook to call a function (probe) that you can
+provide at runtime. A marker can be "on" (a probe is connected to it) or "off"
+(no probe is attached). When a marker is "off" it has no effect, except for
+adding a tiny time penalty (checking a condition for a branch) and space
+penalty (adding a few bytes for the function call at the end of the
+instrumented function and adds a data structure in a separate section). When a
+marker is "on", the function you provide is called each time the marker is
+executed, in the execution context of the caller. When the function provided
+ends its execution, it returns to the caller (continuing from the marker site).
+
+You can put markers at important locations in the code. Markers are
+lightweight hooks that can pass an arbitrary number of parameters,
+described in a printk-like format string, to the attached probe function.
+
+They can be used for tracing and performance accounting.
+
+
+* Usage
+
+In order to use the macro trace_mark, you should include linux/marker.h.
+
+#include <linux/marker.h>
+
+And,
+
+trace_mark(subsystem_event, "%d %s", someint, somestring);
+Where :
+- subsystem_event is an identifier unique to your event
+ - subsystem is the name of your subsystem.
+ - event is the name of the event to mark.
+- "%d %s" is the formatted string for the serializer.
+- someint is an integer.
+- somestring is a char pointer.
+
+Connecting a function (probe) to a marker is done by providing a probe (function
+to call) for the specific marker through marker_probe_register() and can be
+activated by calling marker_arm(). Marker deactivation can be done by calling
+marker_disarm() as many times as marker_arm() has been called. Removing a probe
+is done through marker_probe_unregister(); it will disarm the probe and make
+sure there is no caller left using the probe when it returns. Probe removal is
+preempt-safe because preemption is disabled around the probe call. See the
+"Probe example" section below for a sample probe module.
+
+The marker mechanism supports inserting multiple instances of the same marker.
+Markers can be put in inline functions, inlined static functions, and
+unrolled loops as well as regular functions.
+
+The naming scheme "subsystem_event" is suggested here as a convention intended
+to limit collisions. Marker names are global to the kernel: they are considered
+as being the same whether they are in the core kernel image or in modules.
+Conflicting format strings for markers with the same name will cause the markers
+to be detected to have a different format string not to be armed and will output
+a printk warning which identifies the inconsistency:
+
+"Format mismatch for probe probe_name (format), marker (format)"
+
+
+* Probe / marker example
+
+See the example provided in samples/markers/src
+
+Compile them with your kernel.
+
+Run, as root :
+modprobe marker-example (insmod order is not important)
+modprobe probe-example
+cat /proc/marker-example (returns an expected error)
+rmmod marker-example probe-example
+dmesg
--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
next prev parent reply other threads:[~2007-09-28 14:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-28 14:28 [patch 0/5] Linux Kernel Markers for 2.6.23-rc8-mm2 Mathieu Desnoyers
2007-09-28 14:28 ` [patch 1/5] Combine instrumentation menus in kernel/Kconfig.instrumentation Mathieu Desnoyers
2007-09-28 14:28 ` [patch 2/5] Linux Kernel Markers Mathieu Desnoyers
2007-09-30 1:35 ` Rusty Russell
2007-09-30 14:00 ` Linux Kernel Markers - Coding Style Fixes Mathieu Desnoyers
2007-09-30 14:04 ` Mathieu Desnoyers
2007-10-02 12:10 ` [PATCH] Linux Kernel Markers - Alignment Fix Mathieu Desnoyers
2007-10-01 16:01 ` [PATCH] Change struct marker users Mathieu Desnoyers
2007-09-28 14:28 ` [patch 3/5] Add samples subdir Mathieu Desnoyers
2007-09-28 15:47 ` Randy Dunlap
2007-09-28 16:24 ` Mathieu Desnoyers
2007-09-28 14:28 ` [patch 4/5] Linux Kernel Markers - Samples Mathieu Desnoyers
2007-09-30 14:07 ` [PATCH] Linux Kernel Markers - Samples Coding Style Fix Mathieu Desnoyers
2007-10-11 9:13 ` [patch 4/5] Linux Kernel Markers - Samples Andrew Morton
2007-10-11 13:27 ` Mathieu Desnoyers
2007-10-11 18:32 ` Andrew Morton
2007-09-28 14:28 ` Mathieu Desnoyers [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-09-25 12:11 [patch 0/5] Linux Kernel Markers (redux) Mathieu Desnoyers
2007-09-25 12:11 ` [patch 5/5] Linux Kernel Markers - Documentation Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070928143200.257494978@polymtl.ca \
--to=mathieu.desnoyers@polymtl.ca \
--cc=akpm@linux-foundation.org \
--cc=fche@redhat.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox