Skip to content

Commit db63c41

Browse files
thoootTom Ootjersdicaryldillon-caryl
authored
Fix parsing issues and add support for additional events to the Linux perf text file parser (#2286)
* Handle some parsing edge cases and add support for disk IO events * Fix issues with previous change * Add support for wakeup events * Add support for old event format as well * Add perfview event processing for process_exec * Fix style issue * Add test for sched:exec_process * Add support for IRQ events --------- Co-authored-by: Tom Ootjers <tomoot@ntdev.microsoft.com> Co-authored-by: Dillon Caryl <dicaryl@microsoft.com> Co-authored-by: dillon-caryl <dcaryl@hotmail.com>
1 parent a8605fe commit db63c41

File tree

6 files changed

+669
-57
lines changed

6 files changed

+669
-57
lines changed

src/LinuxTracing.Tests/EventParseTests.cs

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Linq;
77
using Xunit;
88
using System.Linq.Expressions;
9+
using System;
910

1011
namespace LinuxTracingTests
1112
{
@@ -65,7 +66,7 @@ ScheduleSwitch[] switches
6566
Assert.Equal(pids[i], linuxEvent.ProcessID);
6667
Assert.Equal(tids[i], linuxEvent.ThreadID);
6768
Assert.Equal(cpus[i], linuxEvent.CpuNumber);
68-
Assert.Equal(times[i], linuxEvent.TimeMSec);
69+
Assert.True(Math.Abs(times[i] - linuxEvent.TimeMSec) <= 0.0001);
6970
Assert.Equal(timeProperties[i], linuxEvent.TimeProperty);
7071
Assert.Equal(events[i], linuxEvent.EventName);
7172
Assert.Equal(eventProperties[i], linuxEvent.EventProperty);
@@ -257,5 +258,56 @@ public void CornerCaseProcessNames()
257258
eventKinds: null,
258259
switches: null);
259260
}
261+
262+
[Fact]
263+
public void DiskIoNoStacks()
264+
{
265+
string path = Constants.GetTestingPerfDumpPath("disk_io_no_stacks");
266+
HeaderTest(path, blockedTime: false,
267+
commands: new string[] { "fio", "swapper", "fio", "swapper" },
268+
pids: new int[] { 236193, 0, 236193, 0 },
269+
tids: new int[] { 236193, 0, 236193, 0 },
270+
cpus: new int[] { 21, 12, 21, 12 },
271+
times: new double[] { 1791.544, 1791.615, 1791.628, 1791.699 },
272+
timeProperties: new int[] { 1, 1, 1, 1 },
273+
events: new string[] { "block", "block", "block", "block" },
274+
eventProperties: new string[] { "block_rq_issue: 259,76 R 4096 () 57622160 + 8 [fio] ffffffff8beead90 blk_mq_start_request ([kernel.kallsyms])", "block_rq_complete: 259,76 R () 57622160 + 8 [0] ffffffff8bee2b4c blk_update_request ([kernel.kallsyms])", "block_rq_issue: 259,76 R 4096 () 82612968 + 8 [fio] ffffffff8beead90 blk_mq_start_request ([kernel.kallsyms])", "block_rq_complete: 259,76 R () 82612968 + 8 [0] ffffffff8bee2b4c blk_update_request ([kernel.kallsyms])" },
275+
eventKinds: new EventKind[] { EventKind.BlockRequestIssue, EventKind.BlockRequestComplete, EventKind.BlockRequestIssue, EventKind.BlockRequestComplete },
276+
switches: null);
277+
}
278+
279+
[Fact]
280+
public void OneWakeup()
281+
{
282+
string path = Constants.GetTestingPerfDumpPath("one_wakeup");
283+
HeaderTest(path, blockedTime: false,
284+
commands: new string[] { "swapper", "swapper" },
285+
pids: new int[] { 0, 0 },
286+
tids: new int[] { 0, 0 },
287+
cpus: new int[] { 9, 9 },
288+
times: new double[] { 0.0, 0.0 },
289+
timeProperties: new int[] { 1, 1 },
290+
events: new string[] { "sched", "sched" },
291+
eventProperties: new string[] { "sched_wakeup: comm=fio pid=243615 prio=120 target_cpu=031 ffffffff8bad311d ttwu_do_wakeup ([kernel.kallsyms])", "sched_wakeup: task fio:243615 [120] success=1 [031] ffffffff8bad311d ttwu_do_wakeup ([kernel.kallsyms])" },
292+
eventKinds: new EventKind[] { EventKind.Wakeup, EventKind.Wakeup },
293+
switches: null);
294+
}
295+
296+
[Fact]
297+
public void ExecProcess()
298+
{
299+
string path = Constants.GetTestingPerfDumpPath("exec_process");
300+
HeaderTest(path, blockedTime: false,
301+
commands: new string[] { "probe-bcache" },
302+
pids: new int[] { 286053, 286053 },
303+
tids: new int[] { 286053, 286053 },
304+
cpus: new int[] { 3, 3 },
305+
times: new double[] { 0.0, 0.0 },
306+
timeProperties: new int[] { 1, 1 },
307+
events: new string[] { "sched" },
308+
eventProperties: new string[] { "sched_process_exec: filename=/lib/udev/probe-bcache pid=286053 old_pid=286053" },
309+
eventKinds: new EventKind[] { EventKind.ProcessExec },
310+
switches: null);
311+
}
260312
}
261313
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
 fio 236193/236193 [021] 1.791544: 1 block:block_rq_issue: 259,76 R 4096 () 57622160 + 8 [fio] ffffffff8beead90 blk_mq_start_request ([kernel.kallsyms])
2+
swapper 0/0 [012] 1.791615: 1 block:block_rq_complete: 259,76 R () 57622160 + 8 [0] ffffffff8bee2b4c blk_update_request ([kernel.kallsyms])
3+
fio 236193/236193 [021] 1.791628: 1 block:block_rq_issue: 259,76 R 4096 () 82612968 + 8 [fio] ffffffff8beead90 blk_mq_start_request ([kernel.kallsyms])
4+
swapper 0/0 [012] 1.791699: 1 block:block_rq_complete: 259,76 R () 82612968 + 8 [0] ffffffff8bee2b4c blk_update_request ([kernel.kallsyms])
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
probe-bcache 286053/286053 [003] 0.0: 1 sched:sched_process_exec: filename=/lib/udev/probe-bcache pid=286053 old_pid=286053
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
comm 0/0 [000] 0.0: event: event_properties
1+
comm 0/0 [000] 0.0: event/call-graph=no/: event_properties
22

33
comm 0/0 [000] 0.0: event: event_properties
44
address symbol (module)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
 swapper 0/0 [009] 0.0: 1 sched:sched_wakeup: comm=fio pid=243615 prio=120 target_cpu=031 ffffffff8bad311d ttwu_do_wakeup ([kernel.kallsyms])
2+
swapper 0/0 [009] 0.0: 1 sched:sched_wakeup: task fio:243615 [120] success=1 [031] ffffffff8bad311d ttwu_do_wakeup ([kernel.kallsyms])

0 commit comments

Comments
 (0)