@@ -36,7 +36,9 @@ after adding ``tools-profile`` to the :term:`EXTRA_IMAGE_FEATURES` variable.
So, in order to be able
to access all of the tools described here, you can build and boot
-an ``sdk`` image, perhaps one of::
+an ``sdk`` image, perhaps one of:
+
+.. code-block:: console
$ bitbake core-image-sato-sdk
$ bitbake core-image-weston-sdk
@@ -48,7 +50,9 @@ your :ref:`structure-build-conf-local.conf` file::
EXTRA_IMAGE_FEATURES:append = " tools-profile"
If you use the ``tools-profile`` method, you don't need to build an sdk image ---
-the tracing and profiling tools will be included in non-sdk images as well e.g.::
+the tracing and profiling tools will be included in non-sdk images as well e.g.:
+
+.. code-block:: console
$ bitbake core-image-sato
@@ -62,7 +62,9 @@ Basic perf Usage
The perf tool is pretty much self-documenting. To remind yourself of the
available commands, just type ``perf``, which will show you basic usage
-along with the available perf subcommands::
+along with the available perf subcommands:
+
+.. code-block:: console
root@crownbay:~# perf
@@ -102,7 +104,9 @@ which is a minimally interesting case because it has both file and
network I/O aspects, and at least in the case of standard Yocto images,
it's implemented as part of BusyBox, so the methods we use to analyze it
can be used in a similar way to the whole host of supported BusyBox
-applets in Yocto::
+applets in Yocto:
+
+.. code-block:: console
root@crownbay:~# rm linux-2.6.19.2.tar.bz2; \
wget &YOCTO_DL_URL;/mirror/sources/linux-2.6.19.2.tar.bz2
@@ -110,7 +114,9 @@ applets in Yocto::
The quickest and easiest way to get some basic overall data about what's
going on for a particular workload is to profile it using ``perf stat``.
This command basically profiles using a few default counters and displays
-the summed counts at the end of the run::
+the summed counts at the end of the run:
+
+.. code-block:: console
root@crownbay:~# perf stat wget &YOCTO_DL_URL;/mirror/sources/linux-2.6.19.2.tar.bz2
Connecting to downloads.yoctoproject.org (140.211.169.59:80)
@@ -139,7 +145,9 @@ Also, note that ``perf stat`` isn't restricted to a fixed set of counters
--- basically any event listed in the output of ``perf list`` can be tallied
by ``perf stat``. For example, suppose we wanted to see a summary of all
the events related to kernel memory allocation/freeing along with cache
-hits and misses::
+hits and misses:
+
+.. code-block:: console
root@crownbay:~# perf stat -e kmem:* -e cache-references -e cache-misses wget &YOCTO_DL_URL;/mirror/sources/linux-2.6.19.2.tar.bz2
Connecting to downloads.yoctoproject.org (140.211.169.59:80)
@@ -179,7 +187,9 @@ record``, handing it the workload we want to profile (everything after
``perf record`` and any perf options we hand it --- here none, will be
executed in a new shell). perf collects samples until the process exits
and records them in a file named ``perf.data`` in the current working
-directory::
+directory:
+
+.. code-block:: console
root@crownbay:~# perf record wget &YOCTO_DL_URL;/mirror/sources/linux-2.6.19.2.tar.bz2
@@ -191,7 +201,9 @@ directory::
To see the results in a
"text-based UI" (tui), just run ``perf report``, which will read the
perf.data file in the current working directory and display the results
-in an interactive UI::
+in an interactive UI:
+
+.. code-block:: console
root@crownbay:~# perf report
@@ -218,7 +230,9 @@ Before we do that, however, let's try running a different profile, one
which shows something a little more interesting. The only difference
between the new profile and the previous one is that we'll add the ``-g``
option, which will record not just the address of a sampled function,
-but the entire call chain to the sampled function as well::
+but the entire call chain to the sampled function as well:
+
+.. code-block:: console
root@crownbay:~# perf record -g wget &YOCTO_DL_URL;/mirror/sources/linux-2.6.19.2.tar.bz2
Connecting to downloads.yoctoproject.org (140.211.169.59:80)
@@ -320,12 +334,16 @@ in a :term:`configuration file`::
Once we've done that, we can install the debugging information for BusyBox. The
debug packages once built can be found in ``build/tmp/deploy/rpm/*``
on the host system. Find the ``busybox-dbg-...rpm`` file and copy it
-to the target. For example::
+to the target. For example:
+
+.. code-block:: console
$ scp /home/user/yocto/crownbay-tracing-dbg/build/tmp/deploy/rpm/core2_32/busybox-dbg-1.20.2-r2.core2_32.rpm root@192.168.1.31:
busybox-dbg-1.20.2-r2.core2_32.rpm 100% 1826KB 1.8MB/s 00:01
-Now install the debug RPM on the target::
+Now install the debug RPM on the target:
+
+.. code-block:: console
root@crownbay:~# rpm -i busybox-dbg-1.20.2-r2.core2_32.rpm
@@ -392,7 +410,9 @@ traditional tools can now actually make use of the expanded possibilities now
available to them, and in some cases have, as mentioned previously).
We can get a list of the available events that can be used to profile a
-workload via ``perf list``::
+workload via ``perf list``:
+
+.. code-block:: console
root@crownbay:~# perf list
@@ -535,7 +555,9 @@ workload via ``perf list``::
Only a subset of these would be of interest to us when looking at this
workload, so let's choose the most likely subsystems (identified by the
string before the colon in the ``Tracepoint`` events) and do a ``perf stat``
-run using only those subsystem wildcards::
+run using only those subsystem wildcards:
+
+.. code-block:: console
root@crownbay:~# perf stat -e skb:* -e net:* -e napi:* -e sched:* -e workqueue:* -e irq:* -e syscalls:* wget &YOCTO_DL_URL;/mirror/sources/linux-2.6.19.2.tar.bz2
Performance counter stats for 'wget &YOCTO_DL_URL;/mirror/sources/linux-2.6.19.2.tar.bz2':
@@ -597,7 +619,9 @@ run using only those subsystem wildcards::
Let's pick one of these tracepoints
-and tell perf to do a profile using it as the sampling event::
+and tell perf to do a profile using it as the sampling event:
+
+.. code-block:: console
root@crownbay:~# perf record -g -e sched:sched_wakeup wget &YOCTO_DL_URL;/mirror/sources/linux-2.6.19.2.tar.bz2
@@ -655,14 +679,18 @@ individual steps that go into the higher-level behavior exposed by the
coarse-grained profiling data.
As a concrete example, we can trace all the events we think might be
-applicable to our workload::
+applicable to our workload:
+
+.. code-block:: console
root@crownbay:~# perf record -g -e skb:* -e net:* -e napi:* -e sched:sched_switch -e sched:sched_wakeup -e irq:*
-e syscalls:sys_enter_read -e syscalls:sys_exit_read -e syscalls:sys_enter_write -e syscalls:sys_exit_write
wget &YOCTO_DL_URL;/mirror/sources/linux-2.6.19.2.tar.bz2
We can look at the raw trace output using ``perf script`` with no
-arguments::
+arguments:
+
+.. code-block:: console
root@crownbay:~# perf script
@@ -746,7 +774,9 @@ two programming language bindings, one for Python and one for Perl.
Now that we have the trace data in ``perf.data``, we can use ``perf script
-g`` to generate a skeleton script with handlers for the read / write
-entry / exit events we recorded::
+entry / exit events we recorded:
+
+.. code-block:: console
root@crownbay:~# perf script -g python
generated Python script: perf-script.py
@@ -766,7 +796,9 @@ with its parameters. For example:
print "skbaddr=%u, len=%u, name=%s\n" % (skbaddr, len, name),
We can run that script directly to print all of the events contained in the
-``perf.data`` file::
+``perf.data`` file:
+
+.. code-block:: console
root@crownbay:~# perf script -s perf-script.py
@@ -844,7 +876,9 @@ result of all the per-event tallies. For that, we use the special
for event_name, count in counts.iteritems():
print "%-40s %10s\n" % (event_name, count)
-The end result is a summary of all the events recorded in the trace::
+The end result is a summary of all the events recorded in the trace:
+
+.. code-block:: text
skb__skb_copy_datagram_iovec 13148
irq__softirq_entry 4796
@@ -888,13 +922,17 @@ To do system-wide profiling or tracing, you typically use the ``-a`` flag to
``perf record``.
To demonstrate this, open up one window and start the profile using the
-``-a`` flag (press ``Ctrl-C`` to stop tracing)::
+``-a`` flag (press ``Ctrl-C`` to stop tracing):
+
+.. code-block:: console
root@crownbay:~# perf record -g -a
^C[ perf record: Woken up 6 times to write data ]
[ perf record: Captured and wrote 1.400 MB perf.data (~61172 samples) ]
-In another window, run the ``wget`` test::
+In another window, run the ``wget`` test:
+
+.. code-block:: console
root@crownbay:~# wget &YOCTO_DL_URL;/mirror/sources/linux-2.6.19.2.tar.bz2
Connecting to downloads.yoctoproject.org (140.211.169.59:80)
@@ -915,7 +953,9 @@ unresolvable symbols in the expanded ``Xorg`` call chain).
Note also that we have both kernel and user space entries in the above
snapshot. We can also tell perf to focus on user space but providing a
modifier, in this case ``u``, to the ``cycles`` hardware counter when we
-record a profile::
+record a profile:
+
+.. code-block:: console
root@crownbay:~# perf record -g -a -e cycles:u
^C[ perf record: Woken up 2 times to write data ]
@@ -937,13 +977,17 @@ the entries associated with the ``libc-xxx.so`` DSO.
:width: 70%
We can also use the system-wide ``-a`` switch to do system-wide tracing.
-Here we'll trace a couple of scheduler events::
+Here we'll trace a couple of scheduler events:
+
+.. code-block:: console
root@crownbay:~# perf record -a -e sched:sched_switch -e sched:sched_wakeup
^C[ perf record: Woken up 38 times to write data ]
[ perf record: Captured and wrote 9.780 MB perf.data (~427299 samples) ]
-We can look at the raw output using ``perf script`` with no arguments::
+We can look at the raw output using ``perf script`` with no arguments:
+
+.. code-block:: console
root@crownbay:~# perf script
@@ -966,7 +1010,9 @@ do with what we're interested in, namely events that schedule ``perf``
itself in and out or that wake perf up. We can get rid of those by using
the ``--filter`` option --- for each event we specify using ``-e``, we can add a
``--filter`` after that to filter out trace events that contain fields with
-specific values::
+specific values:
+
+.. code-block:: console
root@crownbay:~# perf record -a -e sched:sched_switch --filter 'next_comm != perf && prev_comm != perf' -e sched:sched_wakeup --filter 'comm != perf'
^C[ perf record: Woken up 38 times to write data ]
@@ -1031,7 +1077,9 @@ perf isn't restricted to the fixed set of static tracepoints listed by
``perf list``. Users can also add their own "dynamic" tracepoints anywhere
in the kernel. For example, suppose we want to define our own
tracepoint on ``do_fork()``. We can do that using the ``perf probe`` perf
-subcommand::
+subcommand:
+
+.. code-block:: console
root@crownbay:~# perf probe do_fork
Added new event:
@@ -1045,7 +1093,9 @@ Adding a new tracepoint via
``perf probe`` results in an event with all the expected files and format
in ``/sys/kernel/debug/tracing/events``, just the same as for static
tracepoints (as discussed in more detail in the trace events subsystem
-section::
+section:
+
+.. code-block:: console
root@crownbay:/sys/kernel/debug/tracing/events/probe/do_fork# ls -al
drwxr-xr-x 2 root root 0 Oct 28 11:42 .
@@ -1070,7 +1120,9 @@ section::
print fmt: "(%lx)", REC->__probe_ip
We can list all dynamic tracepoints currently in
-existence::
+existence:
+
+.. code-block:: console
root@crownbay:~# perf probe -l
probe:do_fork (on do_fork)
@@ -1078,13 +1130,17 @@ existence::
Let's record system-wide (``sleep 30`` is a
trick for recording system-wide but basically do nothing and then wake
-up after 30 seconds)::
+up after 30 seconds):
+
+.. code-block:: console
root@crownbay:~# perf record -g -a -e probe:do_fork sleep 30
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.087 MB perf.data (~3812 samples) ]
-Using ``perf script`` we can see each ``do_fork`` event that fired::
+Using ``perf script`` we can see each ``do_fork`` event that fired:
+
+.. code-block:: console
root@crownbay:~# perf script
@@ -1175,7 +1231,9 @@ configuration as follows::
DISTRO_FEATURES:append = " api-documentation"
The manual pages in text form, along with some other files, such as a set
-of examples, can also be found in the ``perf`` directory of the kernel tree::
+of examples, can also be found in the ``perf`` directory of the kernel tree:
+
+.. code-block:: text
tools/perf/Documentation
@@ -1209,7 +1267,9 @@ Basic ftrace usage
"ftrace" essentially refers to everything included in the ``/tracing``
directory of the mounted debugfs filesystem (Yocto follows the standard
convention and mounts it at ``/sys/kernel/debug``). All the files found in
-``/sys/kernel/debug/tracing`` on a Yocto system are::
+``/sys/kernel/debug/tracing`` on a Yocto system are:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing# ls
README kprobe_events trace
@@ -1234,12 +1294,16 @@ the ftrace documentation.
We'll start by looking at some of the available built-in tracers.
-The ``available_tracers`` file lists the set of available tracers::
+The ``available_tracers`` file lists the set of available tracers:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing# cat available_tracers
blk function_graph function nop
-The ``current_tracer`` file contains the tracer currently in effect::
+The ``current_tracer`` file contains the tracer currently in effect:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing# cat current_tracer
nop
@@ -1249,7 +1313,9 @@ The above listing of ``current_tracer`` shows that the
there's actually no tracer currently in effect.
Writing one of the available tracers into ``current_tracer`` makes the
-specified tracer the current tracer::
+specified tracer the current tracer:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing# echo function > current_tracer
root@sugarbay:/sys/kernel/debug/tracing# cat current_tracer
@@ -1259,7 +1325,9 @@ The above sets the current tracer to be the ``function`` tracer. This tracer
traces every function call in the kernel and makes it available as the
contents of the ``trace`` file. Reading the ``trace`` file lists the
currently buffered function calls that have been traced by the function
-tracer::
+tracer:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing# cat trace | less
@@ -1318,7 +1386,9 @@ great way to learn about how the kernel code works in a dynamic sense.
It is a little more difficult to follow the call chains than it needs to
be --- luckily there's a variant of the function tracer that displays the
-call chains explicitly, called the ``function_graph`` tracer::
+call chains explicitly, called the ``function_graph`` tracer:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing# echo function_graph > current_tracer
root@sugarbay:/sys/kernel/debug/tracing# cat trace | less
@@ -1454,7 +1524,9 @@ One especially important directory contained within the
``/sys/kernel/debug/tracing`` directory is the ``events`` subdirectory, which
contains representations of every tracepoint in the system. Listing out
the contents of the ``events`` subdirectory, we see mainly another set of
-subdirectories::
+subdirectories:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing# cd events
root@sugarbay:/sys/kernel/debug/tracing/events# ls -al
@@ -1503,7 +1575,9 @@ subdirectories::
Each one of these subdirectories
corresponds to a "subsystem" and contains yet again more subdirectories,
each one of those finally corresponding to a tracepoint. For example,
-here are the contents of the ``kmem`` subsystem::
+here are the contents of the ``kmem`` subsystem:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing/events# cd kmem
root@sugarbay:/sys/kernel/debug/tracing/events/kmem# ls -al
@@ -1525,7 +1599,9 @@ here are the contents of the ``kmem`` subsystem::
drwxr-xr-x 2 root root 0 Nov 14 23:19 mm_page_pcpu_drain
Let's see what's inside the subdirectory for a
-specific tracepoint, in this case the one for ``kmalloc``::
+specific tracepoint, in this case the one for ``kmalloc``:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing/events/kmem# cd kmalloc
root@sugarbay:/sys/kernel/debug/tracing/events/kmem/kmalloc# ls -al
@@ -1541,7 +1617,9 @@ tracepoint describes the event in memory, which is used by the various
tracing tools that now make use of these tracepoint to parse the event
and make sense of it, along with a ``print fmt`` field that allows tools
like ftrace to display the event as text. The format of the
-``kmalloc`` event looks like::
+``kmalloc`` event looks like:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing/events/kmem/kmalloc# cat format
name: kmalloc
@@ -1580,20 +1658,26 @@ The ``enable`` file
in the tracepoint directory is what allows the user (or tools such as
``trace-cmd``) to actually turn the tracepoint on and off. When enabled, the
corresponding tracepoint will start appearing in the ftrace ``trace`` file
-described previously. For example, this turns on the ``kmalloc`` tracepoint::
+described previously. For example, this turns on the ``kmalloc`` tracepoint:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing/events/kmem/kmalloc# echo 1 > enable
At the moment, we're not interested in the function tracer or
some other tracer that might be in effect, so we first turn it off, but
if we do that, we still need to turn tracing on in order to see the
-events in the output buffer::
+events in the output buffer:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing# echo nop > current_tracer
root@sugarbay:/sys/kernel/debug/tracing# echo 1 > tracing_on
Now, if we look at the ``trace`` file, we see nothing
-but the ``kmalloc`` events we just turned on::
+but the ``kmalloc`` events we just turned on:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing# cat trace | less
# tracer: nop
@@ -1639,7 +1723,9 @@ but the ``kmalloc`` events we just turned on::
<idle>-0 [000] ..s3 18156.400660: kmalloc: call_site=ffffffff81619b36 ptr=ffff88006d554800 bytes_req=512 bytes_alloc=512 gfp_flags=GFP_ATOMIC
matchbox-termin-1361 [001] ...1 18156.552800: kmalloc: call_site=ffffffff81614050 ptr=ffff88006db34800 bytes_req=576 bytes_alloc=1024 gfp_flags=GFP_KERNEL|GFP_REPEAT
-To again disable the ``kmalloc`` event, we need to send ``0`` to the ``enable`` file::
+To again disable the ``kmalloc`` event, we need to send ``0`` to the ``enable`` file:
+
+.. code-block:: console
root@sugarbay:/sys/kernel/debug/tracing/events/kmem/kmalloc# echo 0 > enable
@@ -1681,11 +1767,15 @@ a per-CPU graphical display. It directly uses trace-cmd as the
plumbing that accomplishes all that underneath the covers (and actually
displays the trace-cmd command it uses, as we'll see).
-To start a trace using KernelShark, first start this tool::
+To start a trace using KernelShark, first start this tool:
+
+.. code-block:: console
root@sugarbay:~# kernelshark
-Then open up the ``Capture`` dialog by choosing from the KernelShark menu::
+Then open up the ``Capture`` dialog by choosing from the KernelShark menu:
+
+.. code-block:: text
Capture | Record
@@ -1739,12 +1829,16 @@ ftrace Documentation
--------------------
The documentation for ftrace can be found in the kernel Documentation
-directory::
+directory:
+
+.. code-block:: text
Documentation/trace/ftrace.txt
The documentation for the trace event subsystem can also be found in the kernel
-Documentation directory::
+Documentation directory:
+
+.. code-block:: text
Documentation/trace/events.txt
@@ -1799,7 +1893,9 @@ extracts from the argument string (``argstr``) of the ``open`` system call.
Normally, to execute this
probe, you'd just install SystemTap on the system you want to probe,
and directly run the probe on that system e.g. assuming the name of the
-file containing the above text is ``trace_open.stp``::
+file containing the above text is ``trace_open.stp``:
+
+.. code-block:: console
root@machine:~# stap trace_open.stp
@@ -1840,7 +1936,9 @@ target, with arguments if necessary.
In order to do this from a remote host, however, you need to have access
to the build for the image you booted. The ``crosstap`` script provides
details on how to do this if you run the script on the host without
-having done a build::
+having done a build:
+
+.. code-block:: console
$ crosstap root@192.168.1.88 trace_open.stp
@@ -1863,19 +1961,25 @@ Practically speaking, that means you need to do the following:
the BSP README and/or the widely available basic documentation
that discusses how to build images).
-- Build an ``-sdk`` version of the image e.g.::
+- Build an ``-sdk`` version of the image e.g.:
+
+ .. code-block:: console
$ bitbake core-image-sato-sdk
- Or build a non-SDK image but include the profiling tools
(add ``tools-profile`` to the :term:`EXTRA_IMAGE_FEATURES`
- variable)::
+ variable):
+
+ .. code-block:: console
$ bitbake core-image-sato
Once you've build the image on the host system, you're ready to
boot it (or the equivalent pre-built image) and use ``crosstap``
- to probe it (you need to source the environment as usual first)::
+ to probe it (you need to source the environment as usual first):
+
+ .. code-block:: console
$ source oe-init-build-env
$ cd ~/my/systemtap/scripts
@@ -1904,7 +2008,9 @@ Running a Script on a Target
----------------------------
Once you've done that, you should be able to run a SystemTap script on
-the target::
+the target:
+
+.. code-block:: console
$ cd /path/to/yocto
$ source oe-init-build-env
@@ -1922,17 +2028,23 @@ the target::
You can also run generated QEMU images with a command like 'runqemu qemux86-64'
Once you've done that, you can ``cd`` to whatever
-directory contains your scripts and use ``crosstap`` to run the script::
+directory contains your scripts and use ``crosstap`` to run the script:
+
+.. code-block:: console
$ cd /path/to/my/systemap/script
$ crosstap root@192.168.7.2 trace_open.stp
-If you get an error connecting to the target e.g.::
+If you get an error connecting to the target e.g.:
+
+.. code-block:: console
$ crosstap root@192.168.7.2 trace_open.stp
error establishing ssh connection on remote 'root@192.168.7.2'
-Try connecting to the target through SSH and see what happens::
+Try connecting to the target through SSH and see what happens:
+
+.. code-block:: console
$ ssh root@192.168.7.2
@@ -2058,7 +2170,9 @@ tracing.
Collecting and viewing a trace on the target (inside a shell)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-First, from the host, connect to the target through SSH::
+First, from the host, connect to the target through SSH:
+
+.. code-block:: console
$ ssh -l root 192.168.1.47
The authenticity of host '192.168.1.47 (192.168.1.47)' can't be established.
@@ -2067,30 +2181,40 @@ First, from the host, connect to the target through SSH::
Warning: Permanently added '192.168.1.47' (RSA) to the list of known hosts.
root@192.168.1.47's password:
-Once on the target, use these steps to create a trace::
+Once on the target, use these steps to create a trace:
+
+.. code-block:: console
root@crownbay:~# lttng create
Spawning a session daemon
Session auto-20121015-232120 created.
Traces will be written in /home/root/lttng-traces/auto-20121015-232120
-Enable the events you want to trace (in this case all kernel events)::
+Enable the events you want to trace (in this case all kernel events):
+
+.. code-block:: console
root@crownbay:~# lttng enable-event --kernel --all
All kernel events are enabled in channel channel0
-Start the trace::
+Start the trace:
+
+.. code-block:: console
root@crownbay:~# lttng start
Tracing started for session auto-20121015-232120
And then stop the trace after awhile or after running a particular workload that
-you want to trace::
+you want to trace:
+
+.. code-block:: console
root@crownbay:~# lttng stop
Tracing stopped for session auto-20121015-232120
-You can now view the trace in text form on the target::
+You can now view the trace in text form on the target:
+
+.. code-block:: console
root@crownbay:~# lttng view
[23:21:56.989270399] (+?.?????????) sys_geteuid: { 1 }, { }
@@ -2136,14 +2260,18 @@ You can now view the trace in text form on the target::
You can now safely destroy the trace
session (note that this doesn't delete the trace --- it's still there in
-``~/lttng-traces``)::
+``~/lttng-traces``):
+
+.. code-block:: console
root@crownbay:~# lttng destroy
Session auto-20121015-232120 destroyed at /home/root
Note that the trace is saved in a directory of the same name as returned by
``lttng create``, under the ``~/lttng-traces`` directory (note that you can change this by
-supplying your own name to ``lttng create``)::
+supplying your own name to ``lttng create``):
+
+.. code-block:: console
root@crownbay:~# ls -al ~/lttng-traces
drwxrwx--- 3 root root 1024 Oct 15 23:21 .
@@ -2159,18 +2287,24 @@ generated by the ``lttng-ust`` build.
The ``hello`` test program isn't installed on the root filesystem by the ``lttng-ust``
build, so we need to copy it over manually. First ``cd`` into the build
-directory that contains the ``hello`` executable::
+directory that contains the ``hello`` executable:
+
+.. code-block:: console
$ cd build/tmp/work/core2_32-poky-linux/lttng-ust/2.0.5-r0/git/tests/hello/.libs
-Copy that over to the target machine::
+Copy that over to the target machine:
+
+.. code-block:: console
$ scp hello root@192.168.1.20:
You now have the instrumented LTTng "hello world" test program on the
target, ready to test.
-First, from the host, connect to the target through SSH::
+First, from the host, connect to the target through SSH:
+
+.. code-block:: console
$ ssh -l root 192.168.1.47
The authenticity of host '192.168.1.47 (192.168.1.47)' can't be established.
@@ -2179,35 +2313,47 @@ First, from the host, connect to the target through SSH::
Warning: Permanently added '192.168.1.47' (RSA) to the list of known hosts.
root@192.168.1.47's password:
-Once on the target, use these steps to create a trace::
+Once on the target, use these steps to create a trace:
+
+.. code-block:: console
root@crownbay:~# lttng create
Session auto-20190303-021943 created.
Traces will be written in /home/root/lttng-traces/auto-20190303-021943
-Enable the events you want to trace (in this case all user space events)::
+Enable the events you want to trace (in this case all user space events):
+
+.. code-block:: console
root@crownbay:~# lttng enable-event --userspace --all
All UST events are enabled in channel channel0
-Start the trace::
+Start the trace:
+
+.. code-block:: console
root@crownbay:~# lttng start
Tracing started for session auto-20190303-021943
-Run the instrumented "hello world" program::
+Run the instrumented "hello world" program:
+
+.. code-block:: console
root@crownbay:~# ./hello
Hello, World!
Tracing... done.
And then stop the trace after awhile or after running a particular workload
-that you want to trace::
+that you want to trace:
+
+.. code-block:: console
root@crownbay:~# lttng stop
Tracing stopped for session auto-20190303-021943
-You can now view the trace in text form on the target::
+You can now view the trace in text form on the target:
+
+.. code-block:: console
root@crownbay:~# lttng view
[02:31:14.906146544] (+?.?????????) hello:1424 ust_tests_hello:tptest: { cpu_id = 1 }, { intfield = 0, intfield2 = 0x0, longfield = 0, netintfield = 0, netintfieldhex = 0x0, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2, boolfield = 1 }
@@ -2219,7 +2365,9 @@ You can now view the trace in text form on the target::
.
You can now safely destroy the trace session (note that this doesn't delete the
-trace --- it's still there in ``~/lttng-traces``)::
+trace --- it's still there in ``~/lttng-traces``):
+
+.. code-block:: console
root@crownbay:~# lttng destroy
Session auto-20190303-021943 destroyed at /home/root
@@ -2264,11 +2412,15 @@ Basic blktrace Usage
--------------------
To record a trace, just run the ``blktrace`` command, giving it the name
-of the block device you want to trace activity on::
+of the block device you want to trace activity on:
+
+.. code-block:: console
root@crownbay:~# blktrace /dev/sdc
-In another shell, execute a workload you want to trace::
+In another shell, execute a workload you want to trace:
+
+.. code-block:: console
root@crownbay:/media/sdc# rm linux-2.6.19.2.tar.bz2; wget &YOCTO_DL_URL;/mirror/sources/linux-2.6.19.2.tar.bz2; sync
Connecting to downloads.yoctoproject.org (140.211.169.59:80)
@@ -2277,7 +2429,9 @@ In another shell, execute a workload you want to trace::
Press ``Ctrl-C`` in the blktrace shell to stop the trace. It
will display how many events were logged, along with the per-cpu file
sizes (blktrace records traces in per-cpu kernel buffers and just
-dumps them to user space for blkparse to merge and sort later)::
+dumps them to user space for blkparse to merge and sort later):
+
+.. code-block:: text
^C=== sdc ===
CPU 0: 7082 events, 332 KiB data
@@ -2285,7 +2439,9 @@ dumps them to user space for blkparse to merge and sort later)::
Total: 8660 events (dropped 0), 406 KiB data
If you examine the files saved to disk, you see multiple files, one per CPU and
-with the device name as the first part of the filename::
+with the device name as the first part of the filename:
+
+.. code-block:: console
root@crownbay:~# ls -al
drwxr-xr-x 6 root root 1024 Oct 27 22:39 .
@@ -2295,7 +2451,9 @@ with the device name as the first part of the filename::
To view the trace events, just call ``blkparse`` in the directory
containing the trace files, giving it the device name that forms the
-first part of the filenames::
+first part of the filenames:
+
+.. code-block:: console
root@crownbay:~# blkparse sdc
@@ -2393,7 +2551,9 @@ Live Mode
blktrace and blkparse are designed from the ground up to be able to
operate together in a "pipe mode" where the standard output of blktrace can be
-fed directly into the standard input of blkparse::
+fed directly into the standard input of blkparse:
+
+.. code-block:: console
root@crownbay:~# blktrace /dev/sdc -o - | blkparse -i -
@@ -2406,7 +2566,9 @@ identify and capture conditions of interest.
There's actually another blktrace command that implements the above
pipeline as a single command, so the user doesn't have to bother typing
-in the above command sequence::
+in the above command sequence:
+
+.. code-block:: console
root@crownbay:~# btrace /dev/sdc
@@ -2421,31 +2583,41 @@ the traced device at all by providing native support for sending all
trace data over the network.
To have blktrace operate in this mode, start blktrace in server mode on the
-host system, which is going to store the captured data::
+host system, which is going to store the captured data:
+
+.. code-block:: console
$ blktrace -l
server: waiting for connections...
On the target system that is going to be traced, start blktrace in client
mode with the -h option to connect to the host system, also passing it the
-device to trace::
+device to trace:
+
+.. code-block:: console
root@crownbay:~# blktrace -d /dev/sdc -h 192.168.1.43
blktrace: connecting to 192.168.1.43
blktrace: connected!
-On the host system, you should see this::
+On the host system, you should see this:
+
+.. code-block:: text
server: connection from 192.168.1.43
-In another shell, execute a workload you want to trace::
+In another shell, execute a workload you want to trace:
+
+.. code-block:: console
root@crownbay:/media/sdc# rm linux-2.6.19.2.tar.bz2; wget &YOCTO_DL_URL;/mirror/sources/linux-2.6.19.2.tar.bz2; sync
Connecting to downloads.yoctoproject.org (140.211.169.59:80)
linux-2.6.19.2.tar.b 100% \|*******************************\| 41727k 0:00:00 ETA
When it's done, do a ``Ctrl-C`` on the target system to stop the
-trace::
+trace:
+
+.. code-block:: text
^C=== sdc ===
CPU 0: 7691 events, 361 KiB data
@@ -2453,7 +2625,9 @@ trace::
Total: 11800 events (dropped 0), 554 KiB data
On the host system, you should also see a trace summary for the trace
-just ended::
+just ended:
+
+.. code-block:: text
server: end of run for 192.168.1.43:sdc
=== sdc ===
@@ -2462,20 +2636,26 @@ just ended::
Total: 11800 events (dropped 0), 554 KiB data
The blktrace instance on the host will
-save the target output inside a ``<hostname>-<timestamp>`` directory::
+save the target output inside a ``<hostname>-<timestamp>`` directory:
+
+.. code-block:: console
$ ls -al
drwxr-xr-x 10 root root 1024 Oct 28 02:40 .
drwxr-sr-x 4 root root 1024 Oct 26 18:24 ..
drwxr-xr-x 2 root root 1024 Oct 28 02:40 192.168.1.43-2012-10-28-02:40:56
-``cd`` into that directory to see the output files::
+``cd`` into that directory to see the output files:
+
+.. code-block:: console
$ ls -l
-rw-r--r-- 1 root root 369193 Oct 28 02:44 sdc.blktrace.0
-rw-r--r-- 1 root root 197278 Oct 28 02:44 sdc.blktrace.1
-And run blkparse on the host system using the device name::
+And run blkparse on the host system using the device name:
+
+.. code-block:: console
$ blkparse sdc
@@ -2538,25 +2718,33 @@ user space tools.
To enable tracing for a given device, use ``/sys/block/xxx/trace/enable``,
where ``xxx`` is the device name. This for example enables tracing for
-``/dev/sdc``::
+``/dev/sdc``:
+
+.. code-block:: console
root@crownbay:/sys/kernel/debug/tracing# echo 1 > /sys/block/sdc/trace/enable
Once you've selected the device(s) you want
-to trace, selecting the ``blk`` tracer will turn the blk tracer on::
+to trace, selecting the ``blk`` tracer will turn the blk tracer on:
+
+.. code-block:: console
root@crownbay:/sys/kernel/debug/tracing# cat available_tracers
blk function_graph function nop
root@crownbay:/sys/kernel/debug/tracing# echo blk > current_tracer
-Execute the workload you're interested in::
+Execute the workload you're interested in:
+
+.. code-block:: console
root@crownbay:/sys/kernel/debug/tracing# cat /media/sdc/testfile.txt
And look at the output (note here that we're using ``trace_pipe`` instead of
trace to capture this trace --- this allows us to wait around on the pipe
-for data to appear)::
+for data to appear):
+
+.. code-block:: console
root@crownbay:/sys/kernel/debug/tracing# cat trace_pipe
cat-3587 [001] d..1 3023.276361: 8,32 Q R 1699848 + 8 [cat]
@@ -2575,7 +2763,9 @@ for data to appear)::
cat-3587 [001] d..1 3023.276497: 8,32 m N cfq3587 activate rq, drv=1
cat-3587 [001] d..2 3023.276500: 8,32 D R 1699848 + 8 [cat]
-And this turns off tracing for the specified device::
+And this turns off tracing for the specified device:
+
+.. code-block:: console
root@crownbay:/sys/kernel/debug/tracing# echo 0 > /sys/block/sdc/trace/enable
@@ -2593,6 +2783,8 @@ section can be found here:
The above manual pages, along with manuals for the other blktrace utilities
(``btt``, ``blkiomon``, etc) can be found in the ``/doc`` directory of the blktrace
-tools git repository::
+tools git repository:
+
+.. code-block:: console
$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git
The manuals are moving to a default of bitbake for code blocks, so a BitBake block needs no language and every other block needs one. This gives the blocks in this manual that are not BitBake their language. AI-Generated: codex/claude-opus 5.5 (xhigh) Signed-off-by: Trevor Woerner <twoerner@gmail.com> --- documentation/profile-manual/intro.rst | 8 +- documentation/profile-manual/usage.rst | 384 ++++++++++++++++++------- 2 files changed, 294 insertions(+), 98 deletions(-)