Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit a828cd1

Browse files
Daniel Bristot de Oliveirarostedt
Daniel Bristot de Oliveira
authored andcommitted
rtla: Add timerlat tool and timelart top mode
The rtla timerlat tool is an interface for the timerlat tracer. The timerlat tracer dispatches a kernel thread per-cpu. These threads set a periodic timer to wake themselves up and go back to sleep. After the wakeup, they collect and generate useful information for the debugging of operating system timer latency. The timerlat tracer outputs information in two ways. It periodically prints the timer latency at the timer IRQ handler and the Thread handler. It also provides information for each noise via the osnoise tracepoints. The rtla timerlat top mode displays a summary of the periodic output from the timerlat tracer. Here is one example of the rtla timerlat tool output: ---------- %< ---------- [root@alien ~]# rtla timerlat top -c 0-3 -d 1m Timer Latency 0 00:01:00 | IRQ Timer Latency (us) | Thread Timer Latency (us) CPU COUNT | cur min avg max | cur min avg max 0 #60001 | 0 0 0 3 | 1 1 1 6 1 #60001 | 0 0 0 3 | 2 1 1 5 2 #60001 | 0 0 1 6 | 1 1 2 7 3 #60001 | 0 0 0 7 | 1 1 1 11 ---------- >% ---------- Running: # rtla timerlat --help # rtla timerlat top --help provides information about the available options. Link: https://lkml.kernel.org/r/e95032e20c2b88c962195bf7693bb53c9ebcced8.1639158831.git.bristot@kernel.org Cc: Tao Zhou <tao.zhou@linux.dev> Cc: Ingo Molnar <mingo@redhat.com> Cc: Tom Zanussi <zanussi@kernel.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Juri Lelli <juri.lelli@redhat.com> Cc: Clark Williams <williams@redhat.com> Cc: John Kacur <jkacur@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Daniel Bristot de Oliveira <bristot@kernel.org> Cc: linux-rt-users@vger.kernel.org Cc: linux-trace-devel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 829a6c0 commit a828cd1

File tree

5 files changed

+697
-0
lines changed

5 files changed

+697
-0
lines changed

tools/tracing/rtla/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ install:
6262
$(STRIP) $(DESTDIR)$(BINDIR)/rtla
6363
@test ! -f $(DESTDIR)$(BINDIR)/osnoise || rm $(DESTDIR)$(BINDIR)/osnoise
6464
ln -s $(DESTDIR)$(BINDIR)/rtla $(DESTDIR)$(BINDIR)/osnoise
65+
@test ! -f $(DESTDIR)$(BINDIR)/timerlat || rm $(DESTDIR)$(BINDIR)/timerlat
66+
ln -s $(DESTDIR)$(BINDIR)/rtla $(DESTDIR)$(BINDIR)/timerlat
6567

6668
.PHONY: clean tarball
6769
clean:

tools/tracing/rtla/src/rtla.c

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <stdio.h>
1010

1111
#include "osnoise.h"
12+
#include "timerlat.h"
1213

1314
/*
1415
* rtla_usage - print rtla usage
@@ -25,6 +26,7 @@ static void rtla_usage(void)
2526
"",
2627
" commands:",
2728
" osnoise - gives information about the operating system noise (osnoise)",
29+
" timerlat - measures the timer irq and thread latency",
2830
"",
2931
NULL,
3032
};
@@ -45,6 +47,9 @@ int run_command(int argc, char **argv, int start_position)
4547
if (strcmp(argv[start_position], "osnoise") == 0) {
4648
osnoise_main(argc-start_position, &argv[start_position]);
4749
goto ran;
50+
} else if (strcmp(argv[start_position], "timerlat") == 0) {
51+
timerlat_main(argc-start_position, &argv[start_position]);
52+
goto ran;
4853
}
4954

5055
return 0;

tools/tracing/rtla/src/timerlat.c

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (C) 2021 Red Hat Inc, Daniel Bristot de Oliveira <bristot@kernel.org>
4+
*/
5+
#include <sys/types.h>
6+
#include <sys/stat.h>
7+
#include <pthread.h>
8+
#include <stdlib.h>
9+
#include <string.h>
10+
#include <unistd.h>
11+
#include <errno.h>
12+
#include <fcntl.h>
13+
#include <stdio.h>
14+
15+
#include "timerlat.h"
16+
17+
static void timerlat_usage(void)
18+
{
19+
int i;
20+
21+
static const char * const msg[] = {
22+
"",
23+
"timerlat version " VERSION,
24+
"",
25+
" usage: [rtla] timerlat [MODE] ...",
26+
"",
27+
" modes:",
28+
" top - prints the summary from timerlat tracer",
29+
"",
30+
"if no MODE is given, the top mode is called, passing the arguments",
31+
NULL,
32+
};
33+
34+
for (i = 0; msg[i]; i++)
35+
fprintf(stderr, "%s\n", msg[i]);
36+
exit(1);
37+
}
38+
39+
int timerlat_main(int argc, char *argv[])
40+
{
41+
if (argc == 0)
42+
goto usage;
43+
44+
/*
45+
* if timerlat was called without any argument, run the
46+
* default cmdline.
47+
*/
48+
if (argc == 1) {
49+
timerlat_top_main(argc, argv);
50+
exit(0);
51+
}
52+
53+
if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
54+
timerlat_usage();
55+
exit(0);
56+
} else if (strncmp(argv[1], "-", 1) == 0) {
57+
/* the user skipped the tool, call the default one */
58+
timerlat_top_main(argc, argv);
59+
exit(0);
60+
} else if (strcmp(argv[1], "top") == 0) {
61+
timerlat_top_main(argc-1, &argv[1]);
62+
exit(0);
63+
}
64+
65+
usage:
66+
timerlat_usage();
67+
exit(1);
68+
}

tools/tracing/rtla/src/timerlat.h

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
int timerlat_top_main(int argc, char *argv[]);
4+
int timerlat_main(int argc, char *argv[]);

0 commit comments

Comments
 (0)