lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAP4=nvQ=qj6STkXH=iDvpcesgj-0aBXPhHhXc5POyjWuwuzWYg@mail.gmail.com>
Date: Wed, 19 Feb 2025 13:49:17 +0100
From: Tomas Glozar <tglozar@...hat.com>
To: Costa Shulyupin <costa.shul@...hat.com>
Cc: Steven Rostedt <rostedt@...dmis.org>, Daniel Bristot de Oliveira <bristot@...nel.org>, 
	John Kacur <jkacur@...hat.com>, "Luis Claudio R. Goncalves" <lgoncalv@...hat.com>, 
	Eder Zulian <ezulian@...hat.com>, Dan Carpenter <dan.carpenter@...aro.org>, 
	Gabriele Monaco <gmonaco@...hat.com>, linux-trace-kernel@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] rtla: Refactor save_trace_to_file

st 19. 2. 2025 v 12:52 odesílatel Costa Shulyupin
<costa.shul@...hat.com> napsal:
>
> The functions osnoise_hist_main(), osnoise_top_main(),
> timerlat_hist_main(), and timerlat_top_main() are lengthy and contain
> duplicated code.
>

There is definitely a bunch of code that needs to be unified in rtla.
My idea is to eventually merge top and hist, see my note to the cover
letter to the BPF patchset [1].

[1] https://lore.kernel.org/linux-trace-kernel/20250218145859.27762-1-tglozar@redhat.com/

> Refactor by consolidating the duplicate lines into the
> save_trace_to_file() function.
>
> Signed-off-by: Costa Shulyupin <costa.shul@...hat.com>

Thank you for the cleanup patch.

Reviewed-by: Tomas Glozar <tglozar@...hat.com>
Tested-by: Tomas Glozar <tglozar@...hat.com>

> ---
>  tools/tracing/rtla/src/osnoise_hist.c  | 5 +----
>  tools/tracing/rtla/src/osnoise_top.c   | 5 +----
>  tools/tracing/rtla/src/timerlat_hist.c | 5 +----
>  tools/tracing/rtla/src/timerlat_top.c  | 5 +----
>  tools/tracing/rtla/src/trace.c         | 4 ++++
>  5 files changed, 8 insertions(+), 16 deletions(-)
>
> diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
> index b4930b835b0a1..7c6ef67ef3e6c 100644
> --- a/tools/tracing/rtla/src/osnoise_hist.c
> +++ b/tools/tracing/rtla/src/osnoise_hist.c
> @@ -983,10 +983,7 @@ int osnoise_hist_main(int argc, char *argv[])
>
>         if (osnoise_trace_is_off(tool, record)) {
>                 printf("rtla osnoise hit stop tracing\n");
> -               if (params->trace_output) {
> -                       printf("  Saving trace to %s\n", params->trace_output);
> -                       save_trace_to_file(record->trace.inst, params->trace_output);
> -               }
> +               save_trace_to_file(record->trace.inst, params->trace_output);
>         }
>
>  out_hist:
> diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
> index 4772677ac762c..0eeefbbbf3173 100644
> --- a/tools/tracing/rtla/src/osnoise_top.c
> +++ b/tools/tracing/rtla/src/osnoise_top.c
> @@ -813,10 +813,7 @@ int osnoise_top_main(int argc, char **argv)
>
>         if (osnoise_trace_is_off(tool, record)) {
>                 printf("osnoise hit stop tracing\n");
> -               if (params->trace_output) {
> -                       printf("  Saving trace to %s\n", params->trace_output);
> -                       save_trace_to_file(record->trace.inst, params->trace_output);
> -               }
> +               save_trace_to_file(record->trace.inst, params->trace_output);
>         }
>
>  out_top:
> diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
> index 6d7d0a2d45b47..5f54b268a1033 100644
> --- a/tools/tracing/rtla/src/timerlat_hist.c
> +++ b/tools/tracing/rtla/src/timerlat_hist.c
> @@ -1390,10 +1390,7 @@ int timerlat_hist_main(int argc, char *argv[])
>                 if (!params->no_aa)
>                         timerlat_auto_analysis(params->stop_us, params->stop_total_us);
>
> -               if (params->trace_output) {
> -                       printf("  Saving trace to %s\n", params->trace_output);
> -                       save_trace_to_file(record->trace.inst, params->trace_output);
> -               }
> +               save_trace_to_file(record->trace.inst, params->trace_output);
>         }
>
>  out_hist:
> diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
> index 05a9403b01d26..1e64e6216bc2e 100644
> --- a/tools/tracing/rtla/src/timerlat_top.c
> +++ b/tools/tracing/rtla/src/timerlat_top.c
> @@ -1159,10 +1159,7 @@ int timerlat_top_main(int argc, char *argv[])
>                 if (!params->no_aa)
>                         timerlat_auto_analysis(params->stop_us, params->stop_total_us);
>
> -               if (params->trace_output) {
> -                       printf("  Saving trace to %s\n", params->trace_output);
> -                       save_trace_to_file(record->trace.inst, params->trace_output);
> -               }
> +               save_trace_to_file(record->trace.inst, params->trace_output);
>         } else if (params->aa_only) {
>                 /*
>                  * If the trace did not stop with --aa-only, at least print the
> diff --git a/tools/tracing/rtla/src/trace.c b/tools/tracing/rtla/src/trace.c
> index 728f5029d5335..74ed2f6208baa 100644
> --- a/tools/tracing/rtla/src/trace.c
> +++ b/tools/tracing/rtla/src/trace.c
> @@ -75,12 +75,16 @@ int save_trace_to_file(struct tracefs_instance *inst, const char *filename)
>         int out_fd, in_fd;
>         int retval = -1;
>
> +       if (!filename)
> +               return 0;
> +
>         in_fd = tracefs_instance_file_open(inst, file, O_RDONLY);
>         if (in_fd < 0) {
>                 err_msg("Failed to open trace file\n");
>                 return -1;
>         }
>
> +       printf("  Saving trace to %s\n", filename);
>         out_fd = creat(filename, mode);
>         if (out_fd < 0) {
>                 err_msg("Failed to create output file %s\n", filename);
> --
> 2.48.1
>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ