2022-01-11 17:32:00

by Steven Rostedt

[permalink] [raw]
Subject: [for-next][PATCH 16/31] rtla: Real-Time Linux Analysis tool

From: Daniel Bristot de Oliveira <[email protected]>

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/f59acda8bc513c4a6c279a9bc3ad112a20690e68.1638182284.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]>
---
tools/tracing/rtla/Makefile | 76 +++++++++++++++++++++++++++++++++++
tools/tracing/rtla/README.txt | 36 +++++++++++++++++
tools/tracing/rtla/src/rtla.c | 72 +++++++++++++++++++++++++++++++++
3 files changed, 184 insertions(+)
create mode 100644 tools/tracing/rtla/Makefile
create mode 100644 tools/tracing/rtla/README.txt
create mode 100644 tools/tracing/rtla/src/rtla.c

diff --git a/tools/tracing/rtla/Makefile b/tools/tracing/rtla/Makefile
new file mode 100644
index 000000000000..fbb755100c7e
--- /dev/null
+++ b/tools/tracing/rtla/Makefile
@@ -0,0 +1,76 @@
+NAME := rtla
+VERSION := 0.4
+
+# From libtracefs:
+# Makefiles suck: This macro sets a default value of $(2) for the
+# variable named by $(1), unless the variable has been set by
+# environment or command line. This is necessary for CC and AR
+# because make sets default values, so the simpler ?= approach
+# won't work as expected.
+define allow-override
+ $(if $(or $(findstring environment,$(origin $(1))),\
+ $(findstring command line,$(origin $(1)))),,\
+ $(eval $(1) = $(2)))
+endef
+
+# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
+$(call allow-override,CC,$(CROSS_COMPILE)gcc)
+$(call allow-override,AR,$(CROSS_COMPILE)ar)
+$(call allow-override,STRIP,$(CROSS_COMPILE)strip)
+$(call allow-override,PKG_CONFIG,pkg-config)
+$(call allow-override,LD_SO_CONF_PATH,/etc/ld.so.conf.d/)
+$(call allow-override,LDCONFIG,ldconfig)
+
+INSTALL = install
+FOPTS := -flto=auto -ffat-lto-objects -fexceptions -fstack-protector-strong \
+ -fasynchronous-unwind-tables -fstack-clash-protection
+WOPTS := -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -Wno-maybe-uninitialized
+
+TRACEFS_HEADERS := $$($(PKG_CONFIG) --cflags libtracefs)
+
+CFLAGS := -O -g -DVERSION=\"$(VERSION)\" $(FOPTS) $(MOPTS) $(WOPTS) $(TRACEFS_HEADERS)
+LDFLAGS := -ggdb
+LIBS := $$($(PKG_CONFIG) --libs libtracefs) -lprocps
+
+SRC := $(wildcard src/*.c)
+HDR := $(wildcard src/*.h)
+OBJ := $(SRC:.c=.o)
+DIRS := src
+FILES := Makefile README.txt
+CEXT := bz2
+TARBALL := $(NAME)-$(VERSION).tar.$(CEXT)
+TAROPTS := -cvjf $(TARBALL)
+BINDIR := /usr/bin
+DATADIR := /usr/share
+DOCDIR := $(DATADIR)/doc
+MANDIR := $(DATADIR)/man
+LICDIR := $(DATADIR)/licenses
+
+.PHONY: all
+all: rtla
+
+rtla: $(OBJ)
+ $(CC) -o rtla $(LDFLAGS) $(OBJ) $(LIBS)
+
+static: $(OBJ)
+ $(CC) -o rtla-static $(LDFLAGS) --static $(OBJ) $(LIBS) -lpthread -ldl
+
+.PHONY: install
+install:
+ $(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)
+ $(INSTALL) rtla -m 755 $(DESTDIR)$(BINDIR)
+ $(STRIP) $(DESTDIR)$(BINDIR)/rtla
+
+.PHONY: clean tarball
+clean:
+ @test ! -f rtla || rm rtla
+ @test ! -f rtla-static || rm rtla-static
+ @test ! -f src/rtla.o || rm src/rtla.o
+ @test ! -f $(TARBALL) || rm -f $(TARBALL)
+ @rm -rf *~ $(OBJ) *.tar.$(CEXT)
+
+tarball: clean
+ rm -rf $(NAME)-$(VERSION) && mkdir $(NAME)-$(VERSION)
+ cp -r $(DIRS) $(FILES) $(NAME)-$(VERSION)
+ tar $(TAROPTS) --exclude='*~' $(NAME)-$(VERSION)
+ rm -rf $(NAME)-$(VERSION)
diff --git a/tools/tracing/rtla/README.txt b/tools/tracing/rtla/README.txt
new file mode 100644
index 000000000000..6c88446f7e74
--- /dev/null
+++ b/tools/tracing/rtla/README.txt
@@ -0,0 +1,36 @@
+RTLA: Real-Time Linux Analysis tools
+
+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.
+
+Installing RTLA
+
+RTLA depends on some libraries and tools. More precisely, it depends on the
+following libraries:
+
+ - libtracefs
+ - libtraceevent
+ - procps
+
+It also depends on python3-docutils to compile man pages.
+
+For development, we suggest the following steps for compiling rtla:
+
+ $ git clone git://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git
+ $ cd libtraceevent/
+ $ make
+ $ sudo make install
+ $ cd ..
+ $ git clone git://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git
+ $ cd libtracefs/
+ $ make
+ $ sudo make install
+ $ cd ..
+ $ cd $rtla_src
+ $ make
+ $ sudo make install
+
+For further information, please refer to the rtla man page.
diff --git a/tools/tracing/rtla/src/rtla.c b/tools/tracing/rtla/src/rtla.c
new file mode 100644
index 000000000000..5ae2664ed47d
--- /dev/null
+++ b/tools/tracing/rtla/src/rtla.c
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 Red Hat Inc, Daniel Bristot de Oliveira <[email protected]>
+ */
+
+#include <getopt.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+/*
+ * rtla_usage - print rtla usage
+ */
+static void rtla_usage(void)
+{
+ int i;
+
+ static const char *msg[] = {
+ "",
+ "rtla version " VERSION,
+ "",
+ " usage: rtla COMMAND ...",
+ "",
+ " commands:",
+ "",
+ NULL,
+ };
+
+ for (i = 0; msg[i]; i++)
+ fprintf(stderr, "%s\n", msg[i]);
+ exit(1);
+}
+
+/*
+ * run_command - try to run a rtla tool command
+ *
+ * It returns 0 if it fails. The tool's main will generally not
+ * return as they should call exit().
+ */
+int run_command(int argc, char **argv, int start_position)
+{
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int retval;
+
+ /* is it an alias? */
+ retval = run_command(argc, argv, 0);
+ if (retval)
+ exit(0);
+
+ if (argc < 2)
+ goto usage;
+
+ if (strcmp(argv[1], "-h") == 0) {
+ rtla_usage();
+ exit(0);
+ } else if (strcmp(argv[1], "--help") == 0) {
+ rtla_usage();
+ exit(0);
+ }
+
+ retval = run_command(argc, argv, 1);
+ if (retval)
+ exit(0);
+
+usage:
+ rtla_usage();
+ exit(1);
+}
--
2.33.0


Subject: Re: [for-next][PATCH 16/31] rtla: Real-Time Linux Analysis tool

Hi Steven!

On 1/11/22 18:30, Steven Rostedt wrote:
> From: Daniel Bristot de Oliveira <[email protected]>
>
> 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/f59acda8bc513c4a6c279a9bc3ad112a20690e68.1638182284.git.bristot@kernel.org

Thanks for picking RTLA!

Just one problem, you are picking the V8, but we actually had a V9:
https://lore.kernel.org/lkml/[email protected]/

-- Daniel

2022-01-12 16:22:11

by Steven Rostedt

[permalink] [raw]
Subject: Re: [for-next][PATCH 16/31] rtla: Real-Time Linux Analysis tool

On Wed, 12 Jan 2022 12:15:13 +0100
Daniel Bristot de Oliveira <[email protected]> wrote:

> > Link: https://lkml.kernel.org/r/f59acda8bc513c4a6c279a9bc3ad112a20690e68.1638182284.git.bristot@kernel.org
>
> Thanks for picking RTLA!
>
> Just one problem, you are picking the V8, but we actually had a V9:
> https://lore.kernel.org/lkml/[email protected]/

Strange. I should have picked it up from Patchwork.

https://patchwork.kernel.org/project/linux-trace-devel/list/?series=604588

Not sure how that happened. As it's not kernel code, I may rebase to
fix it.

-- Steve

2022-01-12 16:31:06

by Steven Rostedt

[permalink] [raw]
Subject: Re: [for-next][PATCH 16/31] rtla: Real-Time Linux Analysis tool

On Wed, 12 Jan 2022 11:21:59 -0500
Steven Rostedt <[email protected]> wrote:

>
> Strange. I should have picked it up from Patchwork.
>
> https://patchwork.kernel.org/project/linux-trace-devel/list/?series=604588

The above is the wrong v9 :-p (Now I see how this could have happened!)

Should have been:

https://patchwork.kernel.org/project/linux-trace-devel/list/?series=593861

-- Steve

>
> Not sure how that happened. As it's not kernel code, I may rebase to
> fix it.
>

Subject: Re: [for-next][PATCH 16/31] rtla: Real-Time Linux Analysis tool

On 1/12/22 17:30, Steven Rostedt wrote:
> On Wed, 12 Jan 2022 11:21:59 -0500
> Steven Rostedt <[email protected]> wrote:
>
>> Strange. I should have picked it up from Patchwork.
>>
>> https://patchwork.kernel.org/project/linux-trace-devel/list/?series=604588
> The above is the wrong v9 :-p (Now I see how this could have happened!)
>
> Should have been:
>
> https://patchwork.kernel.org/project/linux-trace-devel/list/?series=593861

That is it, thanks Steve!

-- Daniel

2022-01-12 17:14:38

by Steven Rostedt

[permalink] [raw]
Subject: Re: [for-next][PATCH 16/31] rtla: Real-Time Linux Analysis tool

On Wed, 12 Jan 2022 11:30:54 -0500
Steven Rostedt <[email protected]> wrote:

> On Wed, 12 Jan 2022 11:21:59 -0500
> Steven Rostedt <[email protected]> wrote:
>
> >
> > Strange. I should have picked it up from Patchwork.
> >
> > https://patchwork.kernel.org/project/linux-trace-devel/list/?series=604588
>
> The above is the wrong v9 :-p (Now I see how this could have happened!)
>
> Should have been:
>
> https://patchwork.kernel.org/project/linux-trace-devel/list/?series=593861
>

And by making this mistake, I noticed something in doing the diff. You
put rtla into Documentation/tools. It should be in tools/ itself, not
the Documentation directory.

-- Steve

2022-01-12 17:16:33

by Steven Rostedt

[permalink] [raw]
Subject: Re: [for-next][PATCH 16/31] rtla: Real-Time Linux Analysis tool

On Wed, 12 Jan 2022 12:14:26 -0500
Steven Rostedt <[email protected]> wrote:

> And by making this mistake, I noticed something in doing the diff. You
> put rtla into Documentation/tools. It should be in tools/ itself, not
> the Documentation directory.

At least it use to be in tools/tracing/rtla, but this series has code
in Documentation/tools/rtla, was it not fully moved over?

-- Steve

Subject: Re: [for-next][PATCH 16/31] rtla: Real-Time Linux Analysis tool

On 1/12/22 18:16, Steven Rostedt wrote:
> On Wed, 12 Jan 2022 12:14:26 -0500
> Steven Rostedt <[email protected]> wrote:
>
>> And by making this mistake, I noticed something in doing the diff. You
>> put rtla into Documentation/tools. It should be in tools/ itself, not
>> the Documentation directory.
> At least it use to be in tools/tracing/rtla, but this series has code
> in Documentation/tools/rtla, was it not fully moved over?

The code is in tools/tracing/rtla/. The documentation is in
Documentation/tools/rtla. It was requested by Corbet in the v3 [1].

Am I missing something?

[1] https://lore.kernel.org/lkml/[email protected]/

-- Daniel