Skip to content

Commit 39d8b66

Browse files
authored
PerfDataExtension plugin
Create PerfDataExtension project with decoding support for perf.data files. Includes a generic events table with details view and a simple files metadata table.
2 parents 278b8c2 + 20dacad commit 39d8b66

20 files changed

+3189
-7
lines changed

LTTngDriver/LTTngDriver.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
<CheckEolTargetFramework>false</CheckEolTargetFramework>
67
<Version>1.2.1</Version>
78
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
89
<Authors>Microsoft</Authors>

LinuxTraceLogCapture.md

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This provides a quick start on how to capture logs on Linux.
55
Logs:
66

77
- [LTTng](https://lttng.org) system trace (requires customized image for boot scenario)
8-
- Perf CPU Sampling
8+
- [perf](https://perf.wiki.kernel.org/)
99
- [cloud-init.log](https://cloud-init.io/)
1010
- Automatically logged by cloud-init to /var/log/cloud-init.log
1111
- [dmesg.iso.log](https://en.wikipedia.org/wiki/Dmesg)
@@ -97,8 +97,44 @@ $ sudo lttng stop
9797
$ sudo lttng destroy
9898
```
9999

100-
# Perf
101-
Perf is used to collect CPU Sampling (cpu-clock) events as LTTng doesn't support capturing these yet. Note: Stacks may require symbol setup
100+
# Perf.data
101+
102+
You can collect and view Linux [kernel-mode](https://www.kernel.org/doc/html/latest/trace/tracepoints.html) and [user-mode](https://docs.kernel.org/trace/user_events.html) tracepoints in the `perf.data` file format.
103+
104+
- Select existing tracepoints that you want to collect, or write your own programs that generate tracepoint events.
105+
- Use the Linux `perf` tool or some other tool to collect tracepoint events into `perf.data` files.
106+
- Use the PerfData extension to view the tracepoints.
107+
108+
## Selecting tracepoints
109+
110+
The Linux kernel and the kernel modules generate many useful tracepoints that you can collect. Look in `/sys/kernel/tracing/events` for the tracepoints that are available to you.
111+
112+
In addition, Linux 6.4 adds support for generating
113+
[user_events](https://docs.kernel.org/trace/user_events.html)
114+
tracepoints from user-mode programs.
115+
116+
- [LinuxTracepoints](https://github.com/microsoft/LinuxTracepoints) contains support for generating `user_events` from C/C++ programs.
117+
- [LinuxTracepoints-Rust](https://github.com/microsoft/LinuxTracepoints-Rust) contains support for generating `user_events` from Rust programs.
118+
119+
## Collecting tracepoints
120+
121+
The Linux [perf](https://perf.wiki.kernel.org/) tool supports collecting tracepoint events using `perf record`.
122+
123+
- Install `perf` from the `linux-perf` or `linux-tools` package.
124+
- Note that some `perf` packages use a wrapper script to help you match the running kernel version with a version-specific build of the `perf` tool, e.g. `perf_VERSION`. For collecting tracepoints, the version doesn't need to match. If you have version mismatch problems, you can safely bypass the wrapper script and directly use the `perf_VERSION` tool.
125+
- Install the `libtraceevent1` package to enable `perf` support for tracepoints.
126+
- Use [perf record](https://www.man7.org/linux/man-pages/man1/perf-record.1.html) to collect traces, e.g. `perf record -o MyFile.perf.data -k monotonic -e "event1_group:event1_name,event2_group:event2_name"`
127+
- Use `-k monotonic` to include clock offset information in the data file.
128+
129+
You can also use other tools that generate `perf.data`-compatible files.
130+
131+
- [libtracepoint-control](https://github.com/microsoft/LinuxTracepoints/tree/main/libtracepoint-control-cpp) includes a library for configuring tracepoint collection sessions and collecting `perf.data` files.
132+
- [tracepoint-collect](https://github.com/microsoft/LinuxTracepoints/blob/main/libtracepoint-control-cpp/tools/tracepoint-collect.cpp) is a simple tool that collects tracepoint events into `perf.data` files.
133+
134+
# Perf.data.txt
135+
Perf is used to collect CPU Sampling (cpu-clock) events as LTTng doesn't support capturing these yet. Note: Stacks may require symbol setup.
136+
137+
The perf CPU Sampling analysis plugin uses perf.data.txt files as input.
102138

103139
[perf](https://perf.wiki.kernel.org/) CPU Sampling(cpu-clock)
104140

@@ -172,4 +208,4 @@ $ tar -czvf perf_cpu.tar.gz perf*
172208
# Presentations
173209

174210
If you want to see a demo or get more in-depth info on using these tools check out a talk given at the [Linux Tracing Summit](https://www.tracingsummit.org/ts/2019/):
175-
>Linux & Windows Perf Analysis using WPA, ([slides](https://www.tracingsummit.org/ts/2019/files/Tracingsummit2019-wpa-berg-gibeau.pdf)) ([video](https://youtu.be/HUbVaIi-aaw))
211+
>Linux & Windows Perf Analysis using WPA, ([slides](https://www.tracingsummit.org/ts/2019/files/Tracingsummit2019-wpa-berg-gibeau.pdf)) ([video](https://youtu.be/HUbVaIi-aaw))

Microsoft-Perf-Tools-Linux-Android.sln

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LTTngCdsUnitTest", "LTTngCd
7373
EndProject
7474
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnitTests", "UnitTests", "{A42944EE-FFCC-4544-9F17-2BBFC94DFC3B}"
7575
EndProject
76+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PerfDataExtension", "PerfDataExtension\PerfDataExtension.csproj", "{02B6DB71-E796-4AFE-9E18-334E2F803393}"
77+
EndProject
78+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PerfDataUnitTest", "PerfDataUnitTest\PerfDataUnitTest.csproj", "{B57A38CD-9641-476C-A2FB-DF24D1700F41}"
79+
EndProject
7680
Global
7781
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7882
Debug|Any CPU = Debug|Any CPU
@@ -163,6 +167,14 @@ Global
163167
{CD7E9DD5-B97F-4B86-999E-92F86A1C1138}.Debug|Any CPU.Build.0 = Debug|Any CPU
164168
{CD7E9DD5-B97F-4B86-999E-92F86A1C1138}.Release|Any CPU.ActiveCfg = Release|Any CPU
165169
{CD7E9DD5-B97F-4B86-999E-92F86A1C1138}.Release|Any CPU.Build.0 = Release|Any CPU
170+
{02B6DB71-E796-4AFE-9E18-334E2F803393}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
171+
{02B6DB71-E796-4AFE-9E18-334E2F803393}.Debug|Any CPU.Build.0 = Debug|Any CPU
172+
{02B6DB71-E796-4AFE-9E18-334E2F803393}.Release|Any CPU.ActiveCfg = Release|Any CPU
173+
{02B6DB71-E796-4AFE-9E18-334E2F803393}.Release|Any CPU.Build.0 = Release|Any CPU
174+
{B57A38CD-9641-476C-A2FB-DF24D1700F41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
175+
{B57A38CD-9641-476C-A2FB-DF24D1700F41}.Debug|Any CPU.Build.0 = Debug|Any CPU
176+
{B57A38CD-9641-476C-A2FB-DF24D1700F41}.Release|Any CPU.ActiveCfg = Release|Any CPU
177+
{B57A38CD-9641-476C-A2FB-DF24D1700F41}.Release|Any CPU.Build.0 = Release|Any CPU
166178
EndGlobalSection
167179
GlobalSection(SolutionProperties) = preSolution
168180
HideSolutionNode = FALSE
@@ -182,6 +194,7 @@ Global
182194
{DB7FCF02-C949-4545-B58C-F514E85AB1FA} = {6A9515FC-D4B2-4221-8E74-78E7AFF0E421}
183195
{9FD0BECC-AC5E-46A8-9749-46CD82BA89DE} = {9B2D4167-1CC7-4D8B-A01C-E9919E809A0A}
184196
{CD7E9DD5-B97F-4B86-999E-92F86A1C1138} = {A42944EE-FFCC-4544-9F17-2BBFC94DFC3B}
197+
{B57A38CD-9641-476C-A2FB-DF24D1700F41} = {A42944EE-FFCC-4544-9F17-2BBFC94DFC3B}
185198
EndGlobalSection
186199
GlobalSection(ExtensibilityGlobals) = postSolution
187200
SolutionGuid = {E96603EA-8E1D-4AA9-A474-D267A116C316}

0 commit comments

Comments
 (0)