Skip to content

Commit 79ce8f4

Browse files
Daniel Bristot de Oliveirarostedt
authored andcommitted
rtla: Real-Time Linux Analysis tool
The rtla is a meta-tool that includes a set of commands that aims to analyze the real-time properties of Linux. But instead of testing Linux as a black box, rtla leverages kernel tracing capabilities to provide precise information about the properties and root causes of unexpected results. rtla --help works and provide information about the available options. This is just the "main" and the Makefile, no function yet. Link: https://lkml.kernel.org/r/bf9118ed43a09e6c054c9a491cbe7411ad1acd89.1639158831.git.bristot@kernel.org Cc: Tao Zhou <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Tom Zanussi <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Clark Williams <[email protected]> Cc: John Kacur <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Sebastian Andrzej Siewior <[email protected]> Cc: Daniel Bristot de Oliveira <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Daniel Bristot de Oliveira <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent 0878355 commit 79ce8f4

File tree

3 files changed

+184
-0
lines changed

3 files changed

+184
-0
lines changed

tools/tracing/rtla/Makefile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
NAME := rtla
2+
VERSION := 0.5
3+
4+
# From libtracefs:
5+
# Makefiles suck: This macro sets a default value of $(2) for the
6+
# variable named by $(1), unless the variable has been set by
7+
# environment or command line. This is necessary for CC and AR
8+
# because make sets default values, so the simpler ?= approach
9+
# won't work as expected.
10+
define allow-override
11+
$(if $(or $(findstring environment,$(origin $(1))),\
12+
$(findstring command line,$(origin $(1)))),,\
13+
$(eval $(1) = $(2)))
14+
endef
15+
16+
# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
17+
$(call allow-override,CC,$(CROSS_COMPILE)gcc)
18+
$(call allow-override,AR,$(CROSS_COMPILE)ar)
19+
$(call allow-override,STRIP,$(CROSS_COMPILE)strip)
20+
$(call allow-override,PKG_CONFIG,pkg-config)
21+
$(call allow-override,LD_SO_CONF_PATH,/etc/ld.so.conf.d/)
22+
$(call allow-override,LDCONFIG,ldconfig)
23+
24+
INSTALL = install
25+
FOPTS := -flto=auto -ffat-lto-objects -fexceptions -fstack-protector-strong \
26+
-fasynchronous-unwind-tables -fstack-clash-protection
27+
WOPTS := -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -Wno-maybe-uninitialized
28+
29+
TRACEFS_HEADERS := $$($(PKG_CONFIG) --cflags libtracefs)
30+
31+
CFLAGS := -O -g -DVERSION=\"$(VERSION)\" $(FOPTS) $(MOPTS) $(WOPTS) $(TRACEFS_HEADERS)
32+
LDFLAGS := -ggdb
33+
LIBS := $$($(PKG_CONFIG) --libs libtracefs) -lprocps
34+
35+
SRC := $(wildcard src/*.c)
36+
HDR := $(wildcard src/*.h)
37+
OBJ := $(SRC:.c=.o)
38+
DIRS := src
39+
FILES := Makefile README.txt
40+
CEXT := bz2
41+
TARBALL := $(NAME)-$(VERSION).tar.$(CEXT)
42+
TAROPTS := -cvjf $(TARBALL)
43+
BINDIR := /usr/bin
44+
DATADIR := /usr/share
45+
DOCDIR := $(DATADIR)/doc
46+
MANDIR := $(DATADIR)/man
47+
LICDIR := $(DATADIR)/licenses
48+
49+
.PHONY: all
50+
all: rtla
51+
52+
rtla: $(OBJ)
53+
$(CC) -o rtla $(LDFLAGS) $(OBJ) $(LIBS)
54+
55+
static: $(OBJ)
56+
$(CC) -o rtla-static $(LDFLAGS) --static $(OBJ) $(LIBS) -lpthread -ldl
57+
58+
.PHONY: install
59+
install:
60+
$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)
61+
$(INSTALL) rtla -m 755 $(DESTDIR)$(BINDIR)
62+
$(STRIP) $(DESTDIR)$(BINDIR)/rtla
63+
64+
.PHONY: clean tarball
65+
clean:
66+
@test ! -f rtla || rm rtla
67+
@test ! -f rtla-static || rm rtla-static
68+
@test ! -f src/rtla.o || rm src/rtla.o
69+
@test ! -f $(TARBALL) || rm -f $(TARBALL)
70+
@rm -rf *~ $(OBJ) *.tar.$(CEXT)
71+
72+
tarball: clean
73+
rm -rf $(NAME)-$(VERSION) && mkdir $(NAME)-$(VERSION)
74+
cp -r $(DIRS) $(FILES) $(NAME)-$(VERSION)
75+
tar $(TAROPTS) --exclude='*~' $(NAME)-$(VERSION)
76+
rm -rf $(NAME)-$(VERSION)

tools/tracing/rtla/README.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
RTLA: Real-Time Linux Analysis tools
2+
3+
The rtla is a meta-tool that includes a set of commands that
4+
aims to analyze the real-time properties of Linux. But, instead of
5+
testing Linux as a black box, rtla leverages kernel tracing
6+
capabilities to provide precise information about the properties
7+
and root causes of unexpected results.
8+
9+
Installing RTLA
10+
11+
RTLA depends on some libraries and tools. More precisely, it depends on the
12+
following libraries:
13+
14+
- libtracefs
15+
- libtraceevent
16+
- procps
17+
18+
It also depends on python3-docutils to compile man pages.
19+
20+
For development, we suggest the following steps for compiling rtla:
21+
22+
$ git clone git://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git
23+
$ cd libtraceevent/
24+
$ make
25+
$ sudo make install
26+
$ cd ..
27+
$ git clone git://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git
28+
$ cd libtracefs/
29+
$ make
30+
$ sudo make install
31+
$ cd ..
32+
$ cd $rtla_src
33+
$ make
34+
$ sudo make install
35+
36+
For further information, please refer to the rtla man page.

tools/tracing/rtla/src/rtla.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (C) 2021 Red Hat Inc, Daniel Bristot de Oliveira <[email protected]>
4+
*/
5+
6+
#include <getopt.h>
7+
#include <stdlib.h>
8+
#include <string.h>
9+
#include <stdio.h>
10+
11+
/*
12+
* rtla_usage - print rtla usage
13+
*/
14+
static void rtla_usage(void)
15+
{
16+
int i;
17+
18+
static const char *msg[] = {
19+
"",
20+
"rtla version " VERSION,
21+
"",
22+
" usage: rtla COMMAND ...",
23+
"",
24+
" commands:",
25+
"",
26+
NULL,
27+
};
28+
29+
for (i = 0; msg[i]; i++)
30+
fprintf(stderr, "%s\n", msg[i]);
31+
exit(1);
32+
}
33+
34+
/*
35+
* run_command - try to run a rtla tool command
36+
*
37+
* It returns 0 if it fails. The tool's main will generally not
38+
* return as they should call exit().
39+
*/
40+
int run_command(int argc, char **argv, int start_position)
41+
{
42+
return 0;
43+
}
44+
45+
int main(int argc, char *argv[])
46+
{
47+
int retval;
48+
49+
/* is it an alias? */
50+
retval = run_command(argc, argv, 0);
51+
if (retval)
52+
exit(0);
53+
54+
if (argc < 2)
55+
goto usage;
56+
57+
if (strcmp(argv[1], "-h") == 0) {
58+
rtla_usage();
59+
exit(0);
60+
} else if (strcmp(argv[1], "--help") == 0) {
61+
rtla_usage();
62+
exit(0);
63+
}
64+
65+
retval = run_command(argc, argv, 1);
66+
if (retval)
67+
exit(0);
68+
69+
usage:
70+
rtla_usage();
71+
exit(1);
72+
}

0 commit comments

Comments
 (0)