Skip to content

Commit

Permalink
rtla: Add timerlat tool and timelart top mode
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Bristot de Oliveira authored and Steven Rostedt committed Jan 13, 2022
1 parent 829a6c0 commit a828cd1
Show file tree
Hide file tree
Showing 5 changed files with 697 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/tracing/rtla/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ install:
$(STRIP) $(DESTDIR)$(BINDIR)/rtla
@test ! -f $(DESTDIR)$(BINDIR)/osnoise || rm $(DESTDIR)$(BINDIR)/osnoise
ln -s $(DESTDIR)$(BINDIR)/rtla $(DESTDIR)$(BINDIR)/osnoise
@test ! -f $(DESTDIR)$(BINDIR)/timerlat || rm $(DESTDIR)$(BINDIR)/timerlat
ln -s $(DESTDIR)$(BINDIR)/rtla $(DESTDIR)$(BINDIR)/timerlat

.PHONY: clean tarball
clean:
Expand Down
5 changes: 5 additions & 0 deletions tools/tracing/rtla/src/rtla.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stdio.h>

#include "osnoise.h"
#include "timerlat.h"

/*
* rtla_usage - print rtla usage
Expand All @@ -25,6 +26,7 @@ static void rtla_usage(void)
"",
" commands:",
" osnoise - gives information about the operating system noise (osnoise)",
" timerlat - measures the timer irq and thread latency",
"",
NULL,
};
Expand All @@ -45,6 +47,9 @@ int run_command(int argc, char **argv, int start_position)
if (strcmp(argv[start_position], "osnoise") == 0) {
osnoise_main(argc-start_position, &argv[start_position]);
goto ran;
} else if (strcmp(argv[start_position], "timerlat") == 0) {
timerlat_main(argc-start_position, &argv[start_position]);
goto ran;
}

return 0;
Expand Down
68 changes: 68 additions & 0 deletions tools/tracing/rtla/src/timerlat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2021 Red Hat Inc, Daniel Bristot de Oliveira <bristot@kernel.org>
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>

#include "timerlat.h"

static void timerlat_usage(void)
{
int i;

static const char * const msg[] = {
"",
"timerlat version " VERSION,
"",
" usage: [rtla] timerlat [MODE] ...",
"",
" modes:",
" top - prints the summary from timerlat tracer",
"",
"if no MODE is given, the top mode is called, passing the arguments",
NULL,
};

for (i = 0; msg[i]; i++)
fprintf(stderr, "%s\n", msg[i]);
exit(1);
}

int timerlat_main(int argc, char *argv[])
{
if (argc == 0)
goto usage;

/*
* if timerlat was called without any argument, run the
* default cmdline.
*/
if (argc == 1) {
timerlat_top_main(argc, argv);
exit(0);
}

if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
timerlat_usage();
exit(0);
} else if (strncmp(argv[1], "-", 1) == 0) {
/* the user skipped the tool, call the default one */
timerlat_top_main(argc, argv);
exit(0);
} else if (strcmp(argv[1], "top") == 0) {
timerlat_top_main(argc-1, &argv[1]);
exit(0);
}

usage:
timerlat_usage();
exit(1);
}
4 changes: 4 additions & 0 deletions tools/tracing/rtla/src/timerlat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: GPL-2.0

int timerlat_top_main(int argc, char *argv[]);
int timerlat_main(int argc, char *argv[]);
Loading

0 comments on commit a828cd1

Please sign in to comment.