2022-08-03 15:01:14

by Steven Rostedt

[permalink] [raw]
Subject: [GIT PULL] rtla: Updates for 5.20/6.0


Linus,

Real Time Analysis Tool updates for 5.20 / 6.0

Changes to RTLA:

- Fix a double free

- Define syscall numbers for RISCV

- Fix Makefile when called from -C tools

- Use calloc() to check for memory allocation failures


Please pull the latest trace-rtla-v5.20 tree, which can be found at:


git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-rtla-v5.20

Tag SHA1: ae546e8855f305db853d17a6509e267286dc5b2d
Head SHA1: dd0b15bda48f59eb7dee17fab91eda8389f0e98d


Andreas Schwab (2):
rtla: Fix double free
rtla: Define syscall numbers for riscv

Daniel Bristot de Oliveira (1):
rtla: Fix Makefile when called from -C tools/

jianchunfu (1):
rtla/utils: Use calloc and check the potential memory allocation failure

----
tools/tracing/rtla/Makefile | 2 +-
tools/tracing/rtla/src/trace.c | 9 +++++++--
tools/tracing/rtla/src/utils.c | 7 ++++---
3 files changed, 12 insertions(+), 6 deletions(-)
---------------------------
diff --git a/tools/tracing/rtla/Makefile b/tools/tracing/rtla/Makefile
index 3822f4ea5f49..1bea2d16d4c1 100644
--- a/tools/tracing/rtla/Makefile
+++ b/tools/tracing/rtla/Makefile
@@ -1,6 +1,6 @@
NAME := rtla
# Follow the kernel version
-VERSION := $(shell cat VERSION 2> /dev/null || make -sC ../../.. kernelversion)
+VERSION := $(shell cat VERSION 2> /dev/null || make -sC ../../.. kernelversion | grep -v make)

# From libtracefs:
# Makefiles suck: This macro sets a default value of $(2) for the
diff --git a/tools/tracing/rtla/src/trace.c b/tools/tracing/rtla/src/trace.c
index 5784c9f9e570..e1ba6d9f4265 100644
--- a/tools/tracing/rtla/src/trace.c
+++ b/tools/tracing/rtla/src/trace.c
@@ -134,13 +134,18 @@ void trace_instance_destroy(struct trace_instance *trace)
if (trace->inst) {
disable_tracer(trace->inst);
destroy_instance(trace->inst);
+ trace->inst = NULL;
}

- if (trace->seq)
+ if (trace->seq) {
free(trace->seq);
+ trace->seq = NULL;
+ }

- if (trace->tep)
+ if (trace->tep) {
tep_free(trace->tep);
+ trace->tep = NULL;
+ }
}

/*
diff --git a/tools/tracing/rtla/src/utils.c b/tools/tracing/rtla/src/utils.c
index 5352167a1e75..663a047f794d 100644
--- a/tools/tracing/rtla/src/utils.c
+++ b/tools/tracing/rtla/src/utils.c
@@ -106,8 +106,9 @@ int parse_cpu_list(char *cpu_list, char **monitored_cpus)

nr_cpus = sysconf(_SC_NPROCESSORS_CONF);

- mon_cpus = malloc(nr_cpus * sizeof(char));
- memset(mon_cpus, 0, (nr_cpus * sizeof(char)));
+ mon_cpus = calloc(nr_cpus, sizeof(char));
+ if (!mon_cpus)
+ goto err;

for (p = cpu_list; *p; ) {
cpu = atoi(p);
@@ -224,7 +225,7 @@ long parse_ns_duration(char *val)
#elif __arm__
# define __NR_sched_setattr 380
# define __NR_sched_getattr 381
-#elif __aarch64__
+#elif __aarch64__ || __riscv
# define __NR_sched_setattr 274
# define __NR_sched_getattr 275
#elif __powerpc__


2022-08-05 16:51:40

by Steven Rostedt

[permalink] [raw]
Subject: Re: [GIT PULL] rtla: Updates for 5.20/6.0

On Fri, 5 Aug 2022 09:40:25 -0700
Linus Torvalds <[email protected]> wrote:

> On Wed, Aug 3, 2022 at 7:49 AM Steven Rostedt <[email protected]> wrote:
> >
> > Changes to RTLA:
>
> Btw, I note that the error messages for missing libraries got fixed
> (already some time ago, not this pull), but didn't get around to
> actually building until now.
>
> It says to do
>
> e.g., 'dnf install libtraceevent' on Fedora
>
> but it's actually the devel packages that are needed for building, not
> the bare libraries.
>
> So it should be libtraceevent-devel, and libtracefs-devel.

Thanks for the report (I obviously have them installed, and thus didn't see
this :-/). Not to mention, I always forget to add the -dev/-devel appendix
to my packages.

Daniel,

Can you send a fix?

Thanks!

-- Steve

2022-08-05 17:00:47

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PULL] rtla: Updates for 5.20/6.0

On Wed, Aug 3, 2022 at 7:49 AM Steven Rostedt <[email protected]> wrote:
>
> Changes to RTLA:

Btw, I note that the error messages for missing libraries got fixed
(already some time ago, not this pull), but didn't get around to
actually building until now.

It says to do

e.g., 'dnf install libtraceevent' on Fedora

but it's actually the devel packages that are needed for building, not
the bare libraries.

So it should be libtraceevent-devel, and libtracefs-devel.

Linus

2022-08-05 17:55:34

by pr-tracker-bot

[permalink] [raw]
Subject: Re: [GIT PULL] rtla: Updates for 5.20/6.0

The pull request you sent on Wed, 3 Aug 2022 10:49:36 -0400:

> git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git trace-rtla-v5.20

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/29b1d469f3f6842ee4115f0b21f018fc44176468

Thank you!

--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

Subject: Re: [GIT PULL] rtla: Updates for 5.20/6.0

On 8/5/22 18:47, Steven Rostedt wrote:
> On Fri, 5 Aug 2022 09:40:25 -0700
> Linus Torvalds <[email protected]> wrote:
>
>> On Wed, Aug 3, 2022 at 7:49 AM Steven Rostedt <[email protected]> wrote:
>>>
>>> Changes to RTLA:
>>
>> Btw, I note that the error messages for missing libraries got fixed
>> (already some time ago, not this pull), but didn't get around to
>> actually building until now.
>>
>> It says to do
>>
>> e.g., 'dnf install libtraceevent' on Fedora
>>
>> but it's actually the devel packages that are needed for building, not
>> the bare libraries.

right!

>> So it should be libtraceevent-devel, and libtracefs-devel.
>
> Thanks for the report (I obviously have them installed, and thus didn't see
> this :-/). Not to mention, I always forget to add the -dev/-devel appendix
> to my packages.
>
> Daniel,
>
> Can you send a fix?

Yes, I will do that. I will also do minimal fedora install and cross-check this further.

Thanks!
-- Daniel

2022-08-06 16:02:19

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PULL] rtla: Updates for 5.20/6.0

On Sat, Aug 6, 2022 at 6:01 AM Daniel Bristot de Oliveira
<[email protected]> wrote:
>
> Yes, I will do that. I will also do minimal fedora install and cross-check this further.

For extra bonus points, if you can state all missing packages in one
go (instead of "oops you don't have Xyz" followed by install of Xyz,
followed by "Oops, now you don't have Abc") that would be nice too.

But at this point the fundamental problem with incomprehensible error
messages is long gone, so it's not a big deal and not worth lots of
effort. More of a "if it's easy enough.."

Linus

2022-08-06 18:28:41

by John Kacur

[permalink] [raw]
Subject: Re: [GIT PULL] rtla: Updates for 5.20/6.0



On Sat, 6 Aug 2022, Linus Torvalds wrote:

> On Sat, Aug 6, 2022 at 6:01 AM Daniel Bristot de Oliveira
> <[email protected]> wrote:
> >
> > Yes, I will do that. I will also do minimal fedora install and cross-check this further.
>
> For extra bonus points, if you can state all missing packages in one
> go (instead of "oops you don't have Xyz" followed by install of Xyz,
> followed by "Oops, now you don't have Abc") that would be nice too.
>
> But at this point the fundamental problem with incomprehensible error
> messages is long gone, so it's not a big deal and not worth lots of
> effort. More of a "if it's easy enough.."
>
> Linus
>

Daniel, if it helps,
for Fedora I've got

Build Time Requires
-------------------
BuildRequires: gcc
BuildRequires: python3-docutils
BuildRequires: procps-ng-devel
BuildRequires: libtraceevent-devel
BuildRequires: libtracefs-devel

Run Time Requires
----------------
Requires: procps-ng
Requires: libtraceevent
Requires: libtracefs

John Kacur

2022-08-06 18:42:51

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PULL] rtla: Updates for 5.20/6.0

On Sat, Aug 6, 2022 at 11:22 AM Steven Rostedt <[email protected]> wrote:
>
>
> With the below patch, it will show the warnings for both libtraceevent and
> libtracefs if they are not installed:

Remove some of the unnecessary asterisk noise, and I'll be happy.

It's not like that really adds anything.

Linus

2022-08-06 18:47:44

by Steven Rostedt

[permalink] [raw]
Subject: Re: [GIT PULL] rtla: Updates for 5.20/6.0

On Sat, 6 Aug 2022 08:52:29 -0700
Linus Torvalds <[email protected]> wrote:

> For extra bonus points, if you can state all missing packages in one
> go (instead of "oops you don't have Xyz" followed by install of Xyz,
> followed by "Oops, now you don't have Abc") that would be nice too.
>
> But at this point the fundamental problem with incomprehensible error
> messages is long gone, so it's not a big deal and not worth lots of
> effort. More of a "if it's easy enough.."

With the below patch, it will show the warnings for both libtraceevent and
libtracefs if they are not installed:

$ make
********************************************
** NOTICE: libtraceevent version 1.5 or higher not found
**
** Consider installing the latest libtraceevent from your
** distribution, e.g., 'dnf install libtraceevent-devel' on Fedora,
** or from source:
**
** https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
**
********************************************
********************************************
** NOTICE: libtracefs version 1.3 or higher not found
**
** Consider installing the latest libtracefs from your
** distribution, e.g., 'dnf install libtracefs-devel' on Fedora,
** or from source:
**
** https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/
**
********************************************
Makefile:106: *** Please add the necessary dependencies. Stop.

-- Steve

diff --git a/tools/tracing/rtla/Makefile b/tools/tracing/rtla/Makefile
index 1bea2d16d4c1..a8c89b5b8fa5 100644
--- a/tools/tracing/rtla/Makefile
+++ b/tools/tracing/rtla/Makefile
@@ -61,15 +61,19 @@ endif
LIBTRACEEVENT_MIN_VERSION = 1.5
LIBTRACEFS_MIN_VERSION = 1.3

+.PHONY: all warnings
+all: warnings rtla
+
TEST_LIBTRACEEVENT = $(shell sh -c "$(PKG_CONFIG) --atleast-version $(LIBTRACEEVENT_MIN_VERSION) libtraceevent > /dev/null 2>&1 || echo n")
ifeq ("$(TEST_LIBTRACEEVENT)", "n")
+WARNINGS += warning_traceevent
.PHONY: warning_traceevent
warning_traceevent:
@echo "********************************************"
@echo "** NOTICE: libtraceevent version $(LIBTRACEEVENT_MIN_VERSION) or higher not found"
@echo "**"
@echo "** Consider installing the latest libtraceevent from your"
- @echo "** distribution, e.g., 'dnf install libtraceevent' on Fedora,"
+ @echo "** distribution, e.g., 'dnf install libtraceevent-devel' on Fedora,"
@echo "** or from source:"
@echo "**"
@echo "** https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/ "
@@ -80,12 +84,13 @@ endif
TEST_LIBTRACEFS = $(shell sh -c "$(PKG_CONFIG) --atleast-version $(LIBTRACEFS_MIN_VERSION) libtracefs > /dev/null 2>&1 || echo n")
ifeq ("$(TEST_LIBTRACEFS)", "n")
.PHONY: warning_tracefs
+WARNINGS += warning_tracefs
warning_tracefs:
@echo "********************************************"
@echo "** NOTICE: libtracefs version $(LIBTRACEFS_MIN_VERSION) or higher not found"
@echo "**"
@echo "** Consider installing the latest libtracefs from your"
- @echo "** distribution, e.g., 'dnf install libtracefs' on Fedora,"
+ @echo "** distribution, e.g., 'dnf install libtracefs-devel' on Fedora,"
@echo "** or from source:"
@echo "**"
@echo "** https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/ "
@@ -93,8 +98,12 @@ warning_tracefs:
@echo "********************************************"
endif

-.PHONY: all
-all: rtla
+ifneq ("$(WARNINGS)", "")
+ERROR_OUT = $(error Please add the necessary dependencies)
+endif
+
+warnings: $(WARNINGS)
+ $(ERROR_OUT)

rtla: $(OBJ)
$(CC) -o rtla $(LDFLAGS) $(OBJ) $(LIBS)

2022-08-06 18:53:44

by Steven Rostedt

[permalink] [raw]
Subject: Re: [GIT PULL] rtla: Updates for 5.20/6.0

On Sat, 6 Aug 2022 11:24:28 -0700
Linus Torvalds <[email protected]> wrote:

> > With the below patch, it will show the warnings for both libtraceevent and
> > libtracefs if they are not installed:
>
> Remove some of the unnecessary asterisk noise, and I'll be happy.
>
> It's not like that really adds anything.

Is the second one I sent better? The consolidated version.

The asterisks do at least highlight the reason of failure.

-- Steve

2022-08-06 18:57:23

by Steven Rostedt

[permalink] [raw]
Subject: Re: [GIT PULL] rtla: Updates for 5.20/6.0

On Sat, 6 Aug 2022 14:45:17 -0400
Steven Rostedt <[email protected]> wrote:

> +ifneq ("$(WARNINGS)", "")
> +ERROR_OUT = $(error Please add the necessary dependencies)

add +endif

> +
> +warnings: $(WARNINGS)
> + $(ERROR_OUT)

remove +endif

2022-08-06 19:12:13

by Linus Torvalds

[permalink] [raw]
Subject: Re: [GIT PULL] rtla: Updates for 5.20/6.0

On Sat, Aug 6, 2022 at 11:52 AM Steven Rostedt <[email protected]> wrote:
>
> Is the second one I sent better? The consolidated version.
>
> The asterisks do at least highlight the reason of failure.

Better. But I think you could remove even more. It's not like we need
the whole ascii framing etc.

It looks very 90s to me. "cowsay" and all that..

But it's not like I care deeply about the retro look.

Linus

2022-08-06 19:22:09

by Steven Rostedt

[permalink] [raw]
Subject: Re: [GIT PULL] rtla: Updates for 5.20/6.0

On Sat, 6 Aug 2022 14:22:03 -0400
Steven Rostedt <[email protected]> wrote:

> With the below patch, it will show the warnings for both libtraceevent and
> libtracefs if they are not installed:
>
> $ make
> ********************************************
> ** NOTICE: libtraceevent version 1.5 or higher not found
> **
> ** Consider installing the latest libtraceevent from your
> ** distribution, e.g., 'dnf install libtraceevent-devel' on Fedora,
> ** or from source:
> **
> ** https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
> **
> ********************************************
> ********************************************
> ** NOTICE: libtracefs version 1.3 or higher not found
> **
> ** Consider installing the latest libtracefs from your
> ** distribution, e.g., 'dnf install libtracefs-devel' on Fedora,
> ** or from source:
> **
> ** https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/
> **
> ********************************************
> Makefile:106: *** Please add the necessary dependencies. Stop.


Or to even make it less noisy:

$ make
********************************************
** NOTICE: Failed build dependencies
**
** Required Libraries:
** libtraceevent version 1.5 or higher
** libtracefs version 1.3 or higher
**
** Consider installing the latest libtracefs from your
** distribution, e.g., 'dnf install libtraceevent-devel libtracefs-devel' on Fedora,
** or from source:
**
** https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
** https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/
**
********************************************
Makefile:106: *** Please add the necessary dependencies. Stop.

-- Steve


diff --git a/tools/tracing/rtla/Makefile b/tools/tracing/rtla/Makefile
index 1bea2d16d4c1..cc9478dabd8b 100644
--- a/tools/tracing/rtla/Makefile
+++ b/tools/tracing/rtla/Makefile
@@ -61,40 +61,50 @@ endif
LIBTRACEEVENT_MIN_VERSION = 1.5
LIBTRACEFS_MIN_VERSION = 1.3

+.PHONY: all warnings show_warnings
+all: warnings rtla
+
TEST_LIBTRACEEVENT = $(shell sh -c "$(PKG_CONFIG) --atleast-version $(LIBTRACEEVENT_MIN_VERSION) libtraceevent > /dev/null 2>&1 || echo n")
ifeq ("$(TEST_LIBTRACEEVENT)", "n")
-.PHONY: warning_traceevent
-warning_traceevent:
- @echo "********************************************"
- @echo "** NOTICE: libtraceevent version $(LIBTRACEEVENT_MIN_VERSION) or higher not found"
- @echo "**"
- @echo "** Consider installing the latest libtraceevent from your"
- @echo "** distribution, e.g., 'dnf install libtraceevent' on Fedora,"
- @echo "** or from source:"
- @echo "**"
- @echo "** https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/ "
- @echo "**"
- @echo "********************************************"
+WARNINGS = show_warnings
+MISSING_LIBS += echo "** libtraceevent version $(LIBTRACEEVENT_MIN_VERSION) or higher";
+MISSING_PACKAGES += "libtraceevent-devel"
+MISSING_SOURCE += echo "** https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/ ";
endif

TEST_LIBTRACEFS = $(shell sh -c "$(PKG_CONFIG) --atleast-version $(LIBTRACEFS_MIN_VERSION) libtracefs > /dev/null 2>&1 || echo n")
ifeq ("$(TEST_LIBTRACEFS)", "n")
-.PHONY: warning_tracefs
-warning_tracefs:
- @echo "********************************************"
- @echo "** NOTICE: libtracefs version $(LIBTRACEFS_MIN_VERSION) or higher not found"
- @echo "**"
- @echo "** Consider installing the latest libtracefs from your"
- @echo "** distribution, e.g., 'dnf install libtracefs' on Fedora,"
- @echo "** or from source:"
- @echo "**"
- @echo "** https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/ "
- @echo "**"
- @echo "********************************************"
+WARNINGS = show_warnings
+MISSING_LIBS += echo "** libtracefs version $(LIBTRACEFS_MIN_VERSION) or higher";
+MISSING_PACKAGES += "libtracefs-devel"
+MISSING_SOURCE += echo "** https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/ ";
endif

-.PHONY: all
-all: rtla
+define show_dependencies
+ @echo "********************************************"; \
+ echo "** NOTICE: Failed build dependencies"; \
+ echo "**"; \
+ echo "** Required Libraries:"; \
+ $(MISSING_LIBS) \
+ echo "**"; \
+ echo "** Consider installing the latest libtracefs from your"; \
+ echo "** distribution, e.g., 'dnf install $(MISSING_PACKAGES)' on Fedora,"; \
+ echo "** or from source:"; \
+ echo "**"; \
+ $(MISSING_SOURCE) \
+ echo "**"; \
+ echo "********************************************"
+endef
+
+show_warnings:
+ $(call show_dependencies);
+
+ifneq ("$(WARNINGS)", "")
+ERROR_OUT = $(error Please add the necessary dependencies)
+
+warnings: $(WARNINGS)
+ $(ERROR_OUT)
+endif

rtla: $(OBJ)
$(CC) -o rtla $(LDFLAGS) $(OBJ) $(LIBS)

2022-08-06 19:51:16

by Steven Rostedt

[permalink] [raw]
Subject: Re: [GIT PULL] rtla: Updates for 5.20/6.0

On Sat, 6 Aug 2022 12:05:52 -0700
Linus Torvalds <[email protected]> wrote:

> It looks very 90s to me. "cowsay" and all that..
>
> But it's not like I care deeply about the retro look.

I thought it would bring back some nostalgia. ;-)

As I'm pretty much the same age as you, it's probably why I tend to like it.

-- Steve