Skip to content

Commit 6fa5e3a

Browse files
lenticularis39rostedt
authored andcommitted
rtla/timerlat: Unify params struct
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 <[email protected]> Cc: Luis Goncalves <[email protected]> Cc: Gabriele Monaco <[email protected]> Cc: Clark Williams <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Tomas Glozar <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent d082ecb commit 6fa5e3a

File tree

5 files changed

+78
-99
lines changed

5 files changed

+78
-99
lines changed

tools/tracing/rtla/src/osnoise.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
2+
#pragma once
3+
24
#include "trace.h"
35

46
/*

tools/tracing/rtla/src/timerlat.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,58 @@
11
// SPDX-License-Identifier: GPL-2.0
2+
#include "utils.h"
3+
#include "osnoise.h"
4+
5+
struct timerlat_params {
6+
/* Common params */
7+
char *cpus;
8+
cpu_set_t monitored_cpus;
9+
char *trace_output;
10+
char *cgroup_name;
11+
unsigned long long runtime;
12+
long long stop_us;
13+
long long stop_total_us;
14+
long long timerlat_period_us;
15+
long long print_stack;
16+
int sleep_time;
17+
int output_divisor;
18+
int duration;
19+
int quiet;
20+
int set_sched;
21+
int dma_latency;
22+
int no_aa;
23+
int aa_only;
24+
int dump_tasks;
25+
int cgroup;
26+
int hk_cpus;
27+
int user_workload;
28+
int kernel_workload;
29+
int pretty_output;
30+
int warmup;
31+
int buffer_size;
32+
int deepest_idle_state;
33+
cpu_set_t hk_cpu_set;
34+
struct sched_attr sched_param;
35+
struct trace_events *events;
36+
union {
37+
struct {
38+
/* top only */
39+
int user_top;
40+
};
41+
struct {
42+
/* hist only */
43+
int user_hist;
44+
char no_irq;
45+
char no_thread;
46+
char no_header;
47+
char no_summary;
48+
char no_index;
49+
char with_zeros;
50+
int bucket_size;
51+
int entries;
52+
};
53+
};
54+
};
55+
256
int timerlat_hist_main(int argc, char *argv[]);
357
int timerlat_top_main(int argc, char *argv[]);
458
int timerlat_main(int argc, char *argv[]);

tools/tracing/rtla/src/timerlat_aa.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
#include <stdlib.h>
77
#include <errno.h>
8-
#include "utils.h"
9-
#include "osnoise.h"
108
#include "timerlat.h"
119
#include <unistd.h>
1210

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 11 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,50 +14,10 @@
1414
#include <sched.h>
1515
#include <pthread.h>
1616

17-
#include "utils.h"
18-
#include "osnoise.h"
1917
#include "timerlat.h"
2018
#include "timerlat_aa.h"
2119
#include "timerlat_u.h"
2220

23-
struct timerlat_hist_params {
24-
char *cpus;
25-
cpu_set_t monitored_cpus;
26-
char *trace_output;
27-
char *cgroup_name;
28-
unsigned long long runtime;
29-
long long stop_us;
30-
long long stop_total_us;
31-
long long timerlat_period_us;
32-
long long print_stack;
33-
int sleep_time;
34-
int output_divisor;
35-
int duration;
36-
int set_sched;
37-
int dma_latency;
38-
int cgroup;
39-
int hk_cpus;
40-
int no_aa;
41-
int dump_tasks;
42-
int user_workload;
43-
int kernel_workload;
44-
int user_hist;
45-
cpu_set_t hk_cpu_set;
46-
struct sched_attr sched_param;
47-
struct trace_events *events;
48-
char no_irq;
49-
char no_thread;
50-
char no_header;
51-
char no_summary;
52-
char no_index;
53-
char with_zeros;
54-
int bucket_size;
55-
int entries;
56-
int warmup;
57-
int buffer_size;
58-
int deepest_idle_state;
59-
};
60-
6121
struct timerlat_hist_cpu {
6222
int *irq;
6323
int *thread;
@@ -174,7 +134,7 @@ timerlat_hist_update(struct osnoise_tool *tool, int cpu,
174134
unsigned long long context,
175135
unsigned long long latency)
176136
{
177-
struct timerlat_hist_params *params = tool->params;
137+
struct timerlat_params *params = tool->params;
178138
struct timerlat_hist_data *data = tool->data;
179139
int entries = data->entries;
180140
int bucket;
@@ -238,7 +198,7 @@ timerlat_hist_handler(struct trace_seq *s, struct tep_record *record,
238198
*/
239199
static void timerlat_hist_header(struct osnoise_tool *tool)
240200
{
241-
struct timerlat_hist_params *params = tool->params;
201+
struct timerlat_params *params = tool->params;
242202
struct timerlat_hist_data *data = tool->data;
243203
struct trace_seq *s = tool->trace.seq;
244204
char duration[26];
@@ -300,7 +260,7 @@ static void format_summary_value(struct trace_seq *seq,
300260
* timerlat_print_summary - print the summary of the hist data to the output
301261
*/
302262
static void
303-
timerlat_print_summary(struct timerlat_hist_params *params,
263+
timerlat_print_summary(struct timerlat_params *params,
304264
struct trace_instance *trace,
305265
struct timerlat_hist_data *data)
306266
{
@@ -427,7 +387,7 @@ timerlat_print_summary(struct timerlat_hist_params *params,
427387
}
428388

429389
static void
430-
timerlat_print_stats_all(struct timerlat_hist_params *params,
390+
timerlat_print_stats_all(struct timerlat_params *params,
431391
struct trace_instance *trace,
432392
struct timerlat_hist_data *data)
433393
{
@@ -575,7 +535,7 @@ timerlat_print_stats_all(struct timerlat_hist_params *params,
575535
* timerlat_print_stats - print data for each CPUs
576536
*/
577537
static void
578-
timerlat_print_stats(struct timerlat_hist_params *params, struct osnoise_tool *tool)
538+
timerlat_print_stats(struct timerlat_params *params, struct osnoise_tool *tool)
579539
{
580540
struct timerlat_hist_data *data = tool->data;
581541
struct trace_instance *trace = &tool->trace;
@@ -734,10 +694,10 @@ static void timerlat_hist_usage(char *usage)
734694
/*
735695
* timerlat_hist_parse_args - allocs, parse and fill the cmd line parameters
736696
*/
737-
static struct timerlat_hist_params
697+
static struct timerlat_params
738698
*timerlat_hist_parse_args(int argc, char *argv[])
739699
{
740-
struct timerlat_hist_params *params;
700+
struct timerlat_params *params;
741701
struct trace_events *tevent;
742702
int auto_thresh;
743703
int retval;
@@ -1017,7 +977,7 @@ static struct timerlat_hist_params
1017977
* timerlat_hist_apply_config - apply the hist configs to the initialized tool
1018978
*/
1019979
static int
1020-
timerlat_hist_apply_config(struct osnoise_tool *tool, struct timerlat_hist_params *params)
980+
timerlat_hist_apply_config(struct osnoise_tool *tool, struct timerlat_params *params)
1021981
{
1022982
int retval, i;
1023983

@@ -1122,7 +1082,7 @@ timerlat_hist_apply_config(struct osnoise_tool *tool, struct timerlat_hist_param
11221082
* timerlat_init_hist - initialize a timerlat hist tool with parameters
11231083
*/
11241084
static struct osnoise_tool
1125-
*timerlat_init_hist(struct timerlat_hist_params *params)
1085+
*timerlat_init_hist(struct timerlat_params *params)
11261086
{
11271087
struct osnoise_tool *tool;
11281088
int nr_cpus;
@@ -1170,7 +1130,7 @@ static void stop_hist(int sig)
11701130
* timerlat_hist_set_signals - handles the signal to stop the tool
11711131
*/
11721132
static void
1173-
timerlat_hist_set_signals(struct timerlat_hist_params *params)
1133+
timerlat_hist_set_signals(struct timerlat_params *params)
11741134
{
11751135
signal(SIGINT, stop_hist);
11761136
if (params->duration) {
@@ -1181,7 +1141,7 @@ timerlat_hist_set_signals(struct timerlat_hist_params *params)
11811141

11821142
int timerlat_hist_main(int argc, char *argv[])
11831143
{
1184-
struct timerlat_hist_params *params;
1144+
struct timerlat_params *params;
11851145
struct osnoise_tool *record = NULL;
11861146
struct timerlat_u_params params_u;
11871147
struct osnoise_tool *tool = NULL;

tools/tracing/rtla/src/timerlat_top.c

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,10 @@
1515
#include <sched.h>
1616
#include <pthread.h>
1717

18-
#include "utils.h"
19-
#include "osnoise.h"
2018
#include "timerlat.h"
2119
#include "timerlat_aa.h"
2220
#include "timerlat_u.h"
2321

24-
struct timerlat_top_params {
25-
char *cpus;
26-
cpu_set_t monitored_cpus;
27-
char *trace_output;
28-
char *cgroup_name;
29-
unsigned long long runtime;
30-
long long stop_us;
31-
long long stop_total_us;
32-
long long timerlat_period_us;
33-
long long print_stack;
34-
int sleep_time;
35-
int output_divisor;
36-
int duration;
37-
int quiet;
38-
int set_sched;
39-
int dma_latency;
40-
int no_aa;
41-
int aa_only;
42-
int dump_tasks;
43-
int cgroup;
44-
int hk_cpus;
45-
int user_top;
46-
int user_workload;
47-
int kernel_workload;
48-
int pretty_output;
49-
int warmup;
50-
int buffer_size;
51-
int deepest_idle_state;
52-
cpu_set_t hk_cpu_set;
53-
struct sched_attr sched_param;
54-
struct trace_events *events;
55-
};
56-
5722
struct timerlat_top_cpu {
5823
unsigned long long irq_count;
5924
unsigned long long thread_count;
@@ -194,7 +159,7 @@ timerlat_top_handler(struct trace_seq *s, struct tep_record *record,
194159
struct tep_event *event, void *context)
195160
{
196161
struct trace_instance *trace = context;
197-
struct timerlat_top_params *params;
162+
struct timerlat_params *params;
198163
unsigned long long latency, thread;
199164
struct osnoise_tool *top;
200165
int cpu = record->cpu;
@@ -215,7 +180,7 @@ timerlat_top_handler(struct trace_seq *s, struct tep_record *record,
215180
/*
216181
* timerlat_top_header - print the header of the tool output
217182
*/
218-
static void timerlat_top_header(struct timerlat_top_params *params, struct osnoise_tool *top)
183+
static void timerlat_top_header(struct timerlat_params *params, struct osnoise_tool *top)
219184
{
220185
struct trace_seq *s = top->trace.seq;
221186
char duration[26];
@@ -263,7 +228,7 @@ static const char *no_value = " -";
263228
static void timerlat_top_print(struct osnoise_tool *top, int cpu)
264229
{
265230

266-
struct timerlat_top_params *params = top->params;
231+
struct timerlat_params *params = top->params;
267232
struct timerlat_top_data *data = top->data;
268233
struct timerlat_top_cpu *cpu_data = &data->cpu_data[cpu];
269234
int divisor = params->output_divisor;
@@ -327,7 +292,7 @@ static void
327292
timerlat_top_print_sum(struct osnoise_tool *top, struct timerlat_top_cpu *summary)
328293
{
329294
const char *split = "----------------------------------------";
330-
struct timerlat_top_params *params = top->params;
295+
struct timerlat_params *params = top->params;
331296
unsigned long long count = summary->irq_count;
332297
int divisor = params->output_divisor;
333298
struct trace_seq *s = top->trace.seq;
@@ -404,7 +369,7 @@ static void clear_terminal(struct trace_seq *seq)
404369
* timerlat_print_stats - print data for all cpus
405370
*/
406371
static void
407-
timerlat_print_stats(struct timerlat_top_params *params, struct osnoise_tool *top)
372+
timerlat_print_stats(struct timerlat_params *params, struct osnoise_tool *top)
408373
{
409374
struct trace_instance *trace = &top->trace;
410375
struct timerlat_top_cpu summary;
@@ -505,10 +470,10 @@ static void timerlat_top_usage(char *usage)
505470
/*
506471
* timerlat_top_parse_args - allocs, parse and fill the cmd line parameters
507472
*/
508-
static struct timerlat_top_params
473+
static struct timerlat_params
509474
*timerlat_top_parse_args(int argc, char **argv)
510475
{
511-
struct timerlat_top_params *params;
476+
struct timerlat_params *params;
512477
struct trace_events *tevent;
513478
long long auto_thresh;
514479
int retval;
@@ -765,7 +730,7 @@ static struct timerlat_top_params
765730
* timerlat_top_apply_config - apply the top configs to the initialized tool
766731
*/
767732
static int
768-
timerlat_top_apply_config(struct osnoise_tool *top, struct timerlat_top_params *params)
733+
timerlat_top_apply_config(struct osnoise_tool *top, struct timerlat_params *params)
769734
{
770735
int retval;
771736
int i;
@@ -876,7 +841,7 @@ timerlat_top_apply_config(struct osnoise_tool *top, struct timerlat_top_params *
876841
* timerlat_init_top - initialize a timerlat top tool with parameters
877842
*/
878843
static struct osnoise_tool
879-
*timerlat_init_top(struct timerlat_top_params *params)
844+
*timerlat_init_top(struct timerlat_params *params)
880845
{
881846
struct osnoise_tool *top;
882847
int nr_cpus;
@@ -924,7 +889,7 @@ static void stop_top(int sig)
924889
* timerlat_top_set_signals - handles the signal to stop the tool
925890
*/
926891
static void
927-
timerlat_top_set_signals(struct timerlat_top_params *params)
892+
timerlat_top_set_signals(struct timerlat_params *params)
928893
{
929894
signal(SIGINT, stop_top);
930895
if (params->duration) {
@@ -935,7 +900,7 @@ timerlat_top_set_signals(struct timerlat_top_params *params)
935900

936901
int timerlat_top_main(int argc, char *argv[])
937902
{
938-
struct timerlat_top_params *params;
903+
struct timerlat_params *params;
939904
struct osnoise_tool *record = NULL;
940905
struct timerlat_u_params params_u;
941906
struct osnoise_tool *top = NULL;

0 commit comments

Comments
 (0)