]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rtla/timerlat: Unify params struct
authorTomas Glozar <tglozar@redhat.com>
Tue, 18 Feb 2025 14:58:52 +0000 (15:58 +0100)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 4 Mar 2025 17:35:17 +0000 (12:35 -0500)
Instead of having separate structs timerlat_top_params and
timerlat_hist_params, use one struct timerlat_params for both.

This allows code using the structs to be shared between timerlat-top and
timerlat-hist.

Cc: John Kacur <jkacur@redhat.com>
Cc: Luis Goncalves <lgoncalv@redhat.com>
Cc: Gabriele Monaco <gmonaco@redhat.com>
Cc: Clark Williams <williams@redhat.com>
Link: https://lore.kernel.org/20250218145859.27762-2-tglozar@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
tools/tracing/rtla/src/osnoise.h
tools/tracing/rtla/src/timerlat.h
tools/tracing/rtla/src/timerlat_aa.c
tools/tracing/rtla/src/timerlat_hist.c
tools/tracing/rtla/src/timerlat_top.c

index 91835a7d8c2b2b40ffafda6dab7d6053c25e1d02..056c8b113dee6798815580c70083bf78f51f64f5 100644 (file)
@@ -1,4 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
+#pragma once
+
 #include "trace.h"
 
 /*
index 88561bfd14f3a7534eb165287c1c90ce4237daf6..e452d385cb0f445bc3ceb51a1f2518c965211c79 100644 (file)
@@ -1,4 +1,58 @@
 // SPDX-License-Identifier: GPL-2.0
+#include "utils.h"
+#include "osnoise.h"
+
+struct timerlat_params {
+       /* Common params */
+       char                    *cpus;
+       cpu_set_t               monitored_cpus;
+       char                    *trace_output;
+       char                    *cgroup_name;
+       unsigned long long      runtime;
+       long long               stop_us;
+       long long               stop_total_us;
+       long long               timerlat_period_us;
+       long long               print_stack;
+       int                     sleep_time;
+       int                     output_divisor;
+       int                     duration;
+       int                     quiet;
+       int                     set_sched;
+       int                     dma_latency;
+       int                     no_aa;
+       int                     aa_only;
+       int                     dump_tasks;
+       int                     cgroup;
+       int                     hk_cpus;
+       int                     user_workload;
+       int                     kernel_workload;
+       int                     pretty_output;
+       int                     warmup;
+       int                     buffer_size;
+       int                     deepest_idle_state;
+       cpu_set_t               hk_cpu_set;
+       struct sched_attr       sched_param;
+       struct trace_events     *events;
+       union {
+               struct {
+                       /* top only */
+                       int                     user_top;
+               };
+               struct {
+                       /* hist only */
+                       int                     user_hist;
+                       char                    no_irq;
+                       char                    no_thread;
+                       char                    no_header;
+                       char                    no_summary;
+                       char                    no_index;
+                       char                    with_zeros;
+                       int                     bucket_size;
+                       int                     entries;
+               };
+       };
+};
+
 int timerlat_hist_main(int argc, char *argv[]);
 int timerlat_top_main(int argc, char *argv[]);
 int timerlat_main(int argc, char *argv[]);
index 7bd80ee2a5b48dbc1d1e0fc5a66a2d37a6f8df8e..31e66ea2b144c24168c475b1eb39cb14aa6c9466 100644 (file)
@@ -5,8 +5,6 @@
 
 #include <stdlib.h>
 #include <errno.h>
-#include "utils.h"
-#include "osnoise.h"
 #include "timerlat.h"
 #include <unistd.h>
 
index 6d7d0a2d45b47363325d1d75f1b3ca83e560c5ab..fe683a20b0e202e1068e9ce76444e158bc23d96b 100644 (file)
 #include <sched.h>
 #include <pthread.h>
 
-#include "utils.h"
-#include "osnoise.h"
 #include "timerlat.h"
 #include "timerlat_aa.h"
 #include "timerlat_u.h"
 
-struct timerlat_hist_params {
-       char                    *cpus;
-       cpu_set_t               monitored_cpus;
-       char                    *trace_output;
-       char                    *cgroup_name;
-       unsigned long long      runtime;
-       long long               stop_us;
-       long long               stop_total_us;
-       long long               timerlat_period_us;
-       long long               print_stack;
-       int                     sleep_time;
-       int                     output_divisor;
-       int                     duration;
-       int                     set_sched;
-       int                     dma_latency;
-       int                     cgroup;
-       int                     hk_cpus;
-       int                     no_aa;
-       int                     dump_tasks;
-       int                     user_workload;
-       int                     kernel_workload;
-       int                     user_hist;
-       cpu_set_t               hk_cpu_set;
-       struct sched_attr       sched_param;
-       struct trace_events     *events;
-       char                    no_irq;
-       char                    no_thread;
-       char                    no_header;
-       char                    no_summary;
-       char                    no_index;
-       char                    with_zeros;
-       int                     bucket_size;
-       int                     entries;
-       int                     warmup;
-       int                     buffer_size;
-       int                     deepest_idle_state;
-};
-
 struct timerlat_hist_cpu {
        int                     *irq;
        int                     *thread;
@@ -174,7 +134,7 @@ timerlat_hist_update(struct osnoise_tool *tool, int cpu,
                     unsigned long long context,
                     unsigned long long latency)
 {
-       struct timerlat_hist_params *params = tool->params;
+       struct timerlat_params *params = tool->params;
        struct timerlat_hist_data *data = tool->data;
        int entries = data->entries;
        int bucket;
@@ -238,7 +198,7 @@ timerlat_hist_handler(struct trace_seq *s, struct tep_record *record,
  */
 static void timerlat_hist_header(struct osnoise_tool *tool)
 {
-       struct timerlat_hist_params *params = tool->params;
+       struct timerlat_params *params = tool->params;
        struct timerlat_hist_data *data = tool->data;
        struct trace_seq *s = tool->trace.seq;
        char duration[26];
@@ -300,7 +260,7 @@ static void format_summary_value(struct trace_seq *seq,
  * timerlat_print_summary - print the summary of the hist data to the output
  */
 static void
-timerlat_print_summary(struct timerlat_hist_params *params,
+timerlat_print_summary(struct timerlat_params *params,
                       struct trace_instance *trace,
                       struct timerlat_hist_data *data)
 {
@@ -427,7 +387,7 @@ timerlat_print_summary(struct timerlat_hist_params *params,
 }
 
 static void
-timerlat_print_stats_all(struct timerlat_hist_params *params,
+timerlat_print_stats_all(struct timerlat_params *params,
                         struct trace_instance *trace,
                         struct timerlat_hist_data *data)
 {
@@ -575,7 +535,7 @@ timerlat_print_stats_all(struct timerlat_hist_params *params,
  * timerlat_print_stats - print data for each CPUs
  */
 static void
-timerlat_print_stats(struct timerlat_hist_params *params, struct osnoise_tool *tool)
+timerlat_print_stats(struct timerlat_params *params, struct osnoise_tool *tool)
 {
        struct timerlat_hist_data *data = tool->data;
        struct trace_instance *trace = &tool->trace;
@@ -734,10 +694,10 @@ static void timerlat_hist_usage(char *usage)
 /*
  * timerlat_hist_parse_args - allocs, parse and fill the cmd line parameters
  */
-static struct timerlat_hist_params
+static struct timerlat_params
 *timerlat_hist_parse_args(int argc, char *argv[])
 {
-       struct timerlat_hist_params *params;
+       struct timerlat_params *params;
        struct trace_events *tevent;
        int auto_thresh;
        int retval;
@@ -1017,7 +977,7 @@ static struct timerlat_hist_params
  * timerlat_hist_apply_config - apply the hist configs to the initialized tool
  */
 static int
-timerlat_hist_apply_config(struct osnoise_tool *tool, struct timerlat_hist_params *params)
+timerlat_hist_apply_config(struct osnoise_tool *tool, struct timerlat_params *params)
 {
        int retval, i;
 
@@ -1122,7 +1082,7 @@ out_err:
  * timerlat_init_hist - initialize a timerlat hist tool with parameters
  */
 static struct osnoise_tool
-*timerlat_init_hist(struct timerlat_hist_params *params)
+*timerlat_init_hist(struct timerlat_params *params)
 {
        struct osnoise_tool *tool;
        int nr_cpus;
@@ -1170,7 +1130,7 @@ static void stop_hist(int sig)
  * timerlat_hist_set_signals - handles the signal to stop the tool
  */
 static void
-timerlat_hist_set_signals(struct timerlat_hist_params *params)
+timerlat_hist_set_signals(struct timerlat_params *params)
 {
        signal(SIGINT, stop_hist);
        if (params->duration) {
@@ -1181,7 +1141,7 @@ timerlat_hist_set_signals(struct timerlat_hist_params *params)
 
 int timerlat_hist_main(int argc, char *argv[])
 {
-       struct timerlat_hist_params *params;
+       struct timerlat_params *params;
        struct osnoise_tool *record = NULL;
        struct timerlat_u_params params_u;
        struct osnoise_tool *tool = NULL;
index 05a9403b01d26155e205881daf5a79c7f3b49e84..97eead91deccdf38689ed3dcc1bef5be2dc172bf 100644 (file)
 #include <sched.h>
 #include <pthread.h>
 
-#include "utils.h"
-#include "osnoise.h"
 #include "timerlat.h"
 #include "timerlat_aa.h"
 #include "timerlat_u.h"
 
-struct timerlat_top_params {
-       char                    *cpus;
-       cpu_set_t               monitored_cpus;
-       char                    *trace_output;
-       char                    *cgroup_name;
-       unsigned long long      runtime;
-       long long               stop_us;
-       long long               stop_total_us;
-       long long               timerlat_period_us;
-       long long               print_stack;
-       int                     sleep_time;
-       int                     output_divisor;
-       int                     duration;
-       int                     quiet;
-       int                     set_sched;
-       int                     dma_latency;
-       int                     no_aa;
-       int                     aa_only;
-       int                     dump_tasks;
-       int                     cgroup;
-       int                     hk_cpus;
-       int                     user_top;
-       int                     user_workload;
-       int                     kernel_workload;
-       int                     pretty_output;
-       int                     warmup;
-       int                     buffer_size;
-       int                     deepest_idle_state;
-       cpu_set_t               hk_cpu_set;
-       struct sched_attr       sched_param;
-       struct trace_events     *events;
-};
-
 struct timerlat_top_cpu {
        unsigned long long      irq_count;
        unsigned long long      thread_count;
@@ -194,7 +159,7 @@ timerlat_top_handler(struct trace_seq *s, struct tep_record *record,
                     struct tep_event *event, void *context)
 {
        struct trace_instance *trace = context;
-       struct timerlat_top_params *params;
+       struct timerlat_params *params;
        unsigned long long latency, thread;
        struct osnoise_tool *top;
        int cpu = record->cpu;
@@ -215,7 +180,7 @@ timerlat_top_handler(struct trace_seq *s, struct tep_record *record,
 /*
  * timerlat_top_header - print the header of the tool output
  */
-static void timerlat_top_header(struct timerlat_top_params *params, struct osnoise_tool *top)
+static void timerlat_top_header(struct timerlat_params *params, struct osnoise_tool *top)
 {
        struct trace_seq *s = top->trace.seq;
        char duration[26];
@@ -263,7 +228,7 @@ static const char *no_value = "        -";
 static void timerlat_top_print(struct osnoise_tool *top, int cpu)
 {
 
-       struct timerlat_top_params *params = top->params;
+       struct timerlat_params *params = top->params;
        struct timerlat_top_data *data = top->data;
        struct timerlat_top_cpu *cpu_data = &data->cpu_data[cpu];
        int divisor = params->output_divisor;
@@ -327,7 +292,7 @@ static void
 timerlat_top_print_sum(struct osnoise_tool *top, struct timerlat_top_cpu *summary)
 {
        const char *split = "----------------------------------------";
-       struct timerlat_top_params *params = top->params;
+       struct timerlat_params *params = top->params;
        unsigned long long count = summary->irq_count;
        int divisor = params->output_divisor;
        struct trace_seq *s = top->trace.seq;
@@ -404,7 +369,7 @@ static void clear_terminal(struct trace_seq *seq)
  * timerlat_print_stats - print data for all cpus
  */
 static void
-timerlat_print_stats(struct timerlat_top_params *params, struct osnoise_tool *top)
+timerlat_print_stats(struct timerlat_params *params, struct osnoise_tool *top)
 {
        struct trace_instance *trace = &top->trace;
        struct timerlat_top_cpu summary;
@@ -505,10 +470,10 @@ static void timerlat_top_usage(char *usage)
 /*
  * timerlat_top_parse_args - allocs, parse and fill the cmd line parameters
  */
-static struct timerlat_top_params
+static struct timerlat_params
 *timerlat_top_parse_args(int argc, char **argv)
 {
-       struct timerlat_top_params *params;
+       struct timerlat_params *params;
        struct trace_events *tevent;
        long long auto_thresh;
        int retval;
@@ -765,7 +730,7 @@ static struct timerlat_top_params
  * timerlat_top_apply_config - apply the top configs to the initialized tool
  */
 static int
-timerlat_top_apply_config(struct osnoise_tool *top, struct timerlat_top_params *params)
+timerlat_top_apply_config(struct osnoise_tool *top, struct timerlat_params *params)
 {
        int retval;
        int i;
@@ -876,7 +841,7 @@ out_err:
  * timerlat_init_top - initialize a timerlat top tool with parameters
  */
 static struct osnoise_tool
-*timerlat_init_top(struct timerlat_top_params *params)
+*timerlat_init_top(struct timerlat_params *params)
 {
        struct osnoise_tool *top;
        int nr_cpus;
@@ -924,7 +889,7 @@ static void stop_top(int sig)
  * timerlat_top_set_signals - handles the signal to stop the tool
  */
 static void
-timerlat_top_set_signals(struct timerlat_top_params *params)
+timerlat_top_set_signals(struct timerlat_params *params)
 {
        signal(SIGINT, stop_top);
        if (params->duration) {
@@ -935,7 +900,7 @@ timerlat_top_set_signals(struct timerlat_top_params *params)
 
 int timerlat_top_main(int argc, char *argv[])
 {
-       struct timerlat_top_params *params;
+       struct timerlat_params *params;
        struct osnoise_tool *record = NULL;
        struct timerlat_u_params params_u;
        struct osnoise_tool *top = NULL;