Some RTLA fixes
cover Some RTLA fixes
The first is a change in the Makefile to make rtla use the kernel version.
The other fixes are in the error path when rtla fails to enable the tracers. I got some segmentation faults when trying to use rtla with kernel versions that do not support multiple instances (i.e., 5.14 and 5.15) and fixed them. I also found some inconsistency in error messages and also did a cleanup there.
Daniel Bristot de Oliveira (4):
rtla: Follow kernel version
rtla/utils: Fix session duration parsing
rtla/trace: Error message fixup
rtla/osnoise: Fix segmentation fault when failing to enable -t
tools/tracing/rtla/Makefile | 4 +++- tools/tracing/rtla/src/osnoise.c | 3 +++ tools/tracing/rtla/src/trace.c | 8 ++++---- tools/tracing/rtla/src/utils.c | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/4 rtla: Follow kernel version
To avoid having commits with new version, it is just easier to follow kernel version.
--- tools/tracing/rtla/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/tracing/rtla/Makefile +3 -1
@@ -1,5 +1,6 @@ NAME := rtla -VERSION := 0.5 +# Follow the kernel version +VERSION := $(shell cat VERSION 2> /dev/null || make -sC ../../.. kernelversion) # From libtracefs: # Makefiles suck: This macro sets a default value of $(2) for the
@@ -85,6 +86,7 @@ clean: doc_clean tarball: clean rm -rf $(NAME)-$(VERSION) && mkdir $(NAME)-$(VERSION) + echo $(VERSION) > $(NAME)-$(VERSION)/VERSION cp -r $(DIRS) $(FILES) $(NAME)-$(VERSION) mkdir $(NAME)-$(VERSION)/Documentation/ cp -rp $(SRCTREE)/../../../Documentation/tools/rtla/* $(NAME)-$(VERSION)/Documentation/
Signature · 1 line
2.34.1
PATCH 2/4 rtla/utils: Fix session duration parsing
In reply to Daniel Bristot de OliveiraUse gmtime to format the duration time. This avoids problems when the system uses local time different of Pisa's Local Time.
--- tools/tracing/rtla/src/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/tracing/rtla/src/utils.c +2 -2
@@ -77,11 +77,11 @@ void get_duration(time_t start_time, char *output, int output_size)time_t duration; duration =difftime (now, start_time); - tm_info =localtime (&duration); + tm_info =gmtime (&duration);snprintf (output, output_size,"%3d %02d:%02d:%02d" , tm_info->tm_yday, - tm_info->tm_hour -1 , + tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec); }
Signature · 1 line
2.34.1
PATCH 3/4 rtla/trace: Error message fixup
In reply to Daniel Bristot de OliveiraUse capital and change "tracer %s" to "%s tracer".
No functional change.
--- tools/tracing/rtla/src/trace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/tracing/rtla/src/trace.c +4 -4
@@ -20,14 +20,14 @@ int enable_tracer_by_name(struct tracefs_instance *inst, const char *tracer_name tracer =TRACEFS_TRACER_CUSTOM ; -debug_msg ("enabling %s tracer\n" , tracer_name); +debug_msg ("Enabling %s tracer\n" , tracer_name); retval =tracefs_tracer_set (inst, tracer, tracer_name);if (retval <0 ) {if (errno ==ENODEV ) -err_msg ("tracer %s not found!\n" , tracer_name); +err_msg ("Tracer %s not found!\n" , tracer_name); -err_msg ("failed to enable the tracer %s\n" , tracer_name); +err_msg ("Failed to enable the %s tracer\n" , tracer_name);return -1 ; }
@@ -44,7 +44,7 @@ void disable_tracer(struct tracefs_instance *inst) retval =tracefs_tracer_set (inst, t);if (retval <0 ) -err_msg ("oops, error disabling tracer\n" ); +err_msg ("Oops, error disabling tracer\n" ); }/*
Signature · 1 line
2.34.1
Steven Rostedt
maintainerRe: [PATCH 3/4] rtla/trace: Error message fixup
Quoted 3 lines · On Fri, 4 Feb 2022 17:24:04 +0100 Daniel Bristot de Oliveira…
Use capital and change "tracer %s" to "%s tracer".
No functional change.
Technically, there is a functional change. Yes, changing output strings is functional changes. What a non functional change would be, is moving code around, but the logic stays the same (or adding macro helpers, and such).
I'll keep this as is, but just stating it as an FYI.
-- Steve
PATCH 4/4 rtla/osnoise: Fix segmentation fault when failing to enable -t
In reply to Daniel Bristot de Oliveirartla osnoise and timerlat are causing a segmentation fault when running with the --trace option on a kernel that does not support multiple instances. For example:
[root@f34 rtla]# rtla osnoise top -t
failed to enable the tracer osnoise
Could not enable osnoiser tracer for tracing
Failed to enable the trace instance
Segmentation fault (core dumped)
This error happens because the exit code of the tools is trying to destroy the trace instance that failed to be created.
Make osnoise_destroy_tool() aware of possible NULL osnoise_tool *, and do not attempt to destroy it.
--- tools/tracing/rtla/src/osnoise.c | 3 +++ 1 file changed, 3 insertions(+)
tools/tracing/rtla/src/osnoise.c +3 -0
@@ -750,6 +750,9 @@ void osnoise_put_context(struct osnoise_context *context)*/ void osnoise_destroy_tool (struct osnoise_tool *top) { +if (!top) +return ; +trace_instance_destroy (&top->trace);if (top->context)
Signature · 1 line
2.34.1
Steven Rostedt
maintainerRe: [PATCH 4/4] rtla/osnoise: Fix segmentation fault when failing to enable -t
tools/tracing/rtla/src/osnoise.c void osnoise_put_context(struct osnoise_context *context) · line 758
Quoted 12 lines · On Fri, 4 Feb 2022 17:24:05 +0100 Daniel Bristot de Oliveira…
tools/tracing/rtla/src/osnoise.c +3
-0@@ -750,6 +750,9 @@ void osnoise_put_context(struct osnoise_context *context)*/ void osnoise_destroy_tool (struct osnoise_tool *top) { +if (!top) +return ; +trace_instance_destroy (&top->trace);if (top->context)
Um, don't you still need to initialize everything to NULL?
i.e.
nt osnoise_top_main(int argc, char **argv)
{
struct osnoise_top_params *params;
struct trace_instance *trace;
struct osnoise_tool *record;
struct osnoise_tool *tool;
int return_value = 1;
int retval;Does not guarantee that record and tool will be initialized to NULL.
-- Steve
Re: [PATCH 4/4] rtla/osnoise: Fix segmentation fault when failing to enable -t
Quoted 30 lines · Steven Rostedt
tools/tracing/rtla/src/osnoise.c void osnoise_put_context(struct osnoise_context *context) · line 758
Quoted 12 lines · On Fri, 4 Feb 2022 17:24:05 +0100 Daniel Bristot de Oliveira…
tools/tracing/rtla/src/osnoise.c +3
-0@@ -750,6 +750,9 @@ void osnoise_put_context(struct osnoise_context *context)*/ void osnoise_destroy_tool (struct osnoise_tool *top) { +if (!top) +return ; +trace_instance_destroy (&top->trace);if (top->context)Um, don't you still need to initialize everything to NULL?
i.e.
nt
osnoise_top_main(int argc, char **argv){ struct osnoise_top_params *params; struct trace_instance *trace; struct osnoise_tool *record; struct osnoise_tool *tool; int return_value = 1; int retval;
Quoted 1 line
Does not guarantee that record and tool will be initialized to NULL.
Aaarrrg, you're right.
As this is not related to the other patches, could you just ignore this one, so I can re-send alone?
-- Daniel
Steven Rostedt
maintainerRe: [PATCH 4/4] rtla/osnoise: Fix segmentation fault when failing to enable -t
Quoted 3 lines · On Fri, 4 Feb 2022 18:46:59 +0100 Daniel Bristot de Oliveira…
As this is not related to the other patches, could you just ignore this one, so I can re-send alone?
Sure.
-- Steve