Skip to contentSkip to conversation

rtla: Updates for 5.20

PATCH New Steven Rostedt 1 participant 5 messages Jul 31, 2022 Real-time Linux Analysis (rtla) tools

lore
Share & tools
lore
author maintainer
#3 lore raw

PATCH 3/4 rtla: Fix double free

In reply to Steven Rostedt

From: Andreas Schwab <[email protected]>

Avoid double free by making trace_instance_destroy indempotent. When trace_instance_init fails, it calls trace_instance_destroy, but its only caller osnoise_destroy_tool calls it again.

---
 tools/tracing/rtla/src/trace.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tools/tracing/rtla/src/trace.c +7 -2
index 5784c9f9e570..e1ba6d9f4265 100644
@@ -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;
+	}
 }
 
 /*
Signature · 1 line
2.35.1
author maintainer
#1 lore raw

PATCH 1/4 rtla/utils: Use calloc and check the potential memory allocation failure

In reply to Steven Rostedt

From: jianchunfu <[email protected]>

Replace malloc with calloc and add memory allocating check of mon_cpus before used.

Fixes 7d0dc9576dc3 ("rtla/timerlat: Add --dma-latency option")
---
 tools/tracing/rtla/src/utils.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/tracing/rtla/src/utils.c +3 -2
index 5352167a1e75..5ae2fa96fde1 100644
@@ -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);
Signature · 1 line
2.35.1
author maintainer
#2 lore raw

PATCH 2/4 rtla: Fix Makefile when called from -C tools/

In reply to Steven Rostedt

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

Sedat Dilek reported an error on rtla Makefile when running:

    $ make -C tools/ clean
    [...]
    make[2]: Entering directory
    '/home/dileks/src/linux-kernel/git/tools/tracing/rtla'
    [...]
    '/home/dileks/src/linux-kernel/git/Documentation/tools/rtla'
    /bin/sh: 1: test: rtla-make[2]:: unexpected operator    <------ The problem
    rm: cannot remove '/home/dileks/src/linux-kernel/git': Is a directory
    make[2]: *** [Makefile:120: clean] Error 1
    make[2]: Leaving directory

This occurred because the rtla calls kernel's Makefile to get the version in silence mode, e.g.,

    $ make -sC ../../.. kernelversion
    5.19.0-rc4

But the -s is being ignored when rtla's makefile is called indirectly, so the output looks like this:

    $ make -C ../../.. kernelversion
    make: Entering directory '/root/linux'
    5.19.0-rc4
    make: Leaving directory '/root/linux'

Using 'grep -v make' avoids this problem, e.g.,

    $ make -C ../../.. kernelversion | grep -v make
    5.19.0-rc4

Thus, add | grep -v make.

---
 tools/tracing/rtla/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tracing/rtla/Makefile +1 -1
index 3822f4ea5f49..1bea2d16d4c1 100644
@@ -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
Signature · 1 line
2.35.1

Steven Rostedt

author maintainer
#0 lore raw

cover rtla: Updates for 5.20

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(-)
author maintainer
#4 lore raw

PATCH 4/4 rtla: Define syscall numbers for riscv

From: Andreas Schwab <[email protected]>

RISC-V uses the same (generic) syscall numbers as ARM64.

---
 tools/tracing/rtla/src/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tracing/rtla/src/utils.c +1 -1
index 5ae2fa96fde1..663a047f794d 100644
@@ -225,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__
Signature · 1 line
2.35.1