Skip to content

Commit 025b217

Browse files
lenticularis39rostedt
authored andcommitted
rtla/osnoise: Unify params struct
Instead of having separate structs osnoise_top_params and osnoise_hist_params, use one struct osnoise_params for both. This allows code using the structs to be shared between osnoise-top and osnoise-hist. Cc: Luis Goncalves <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Tomas Glozar <[email protected]> Reviewed-by: John Kacur <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent c57c58a commit 025b217

File tree

5 files changed

+68
-87
lines changed

5 files changed

+68
-87
lines changed

tools/tracing/rtla/src/osnoise.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <stdio.h>
1515

1616
#include "osnoise.h"
17-
#include "utils.h"
1817

1918
/*
2019
* osnoise_get_cpus - return the original "osnoise/cpus" content

tools/tracing/rtla/src/osnoise.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,55 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#pragma once
33

4+
#include "utils.h"
45
#include "trace.h"
56

7+
enum osnoise_mode {
8+
MODE_OSNOISE = 0,
9+
MODE_HWNOISE
10+
};
11+
12+
struct osnoise_params {
13+
/* Common params */
14+
char *cpus;
15+
cpu_set_t monitored_cpus;
16+
char *trace_output;
17+
char *cgroup_name;
18+
unsigned long long runtime;
19+
unsigned long long period;
20+
long long threshold;
21+
long long stop_us;
22+
long long stop_total_us;
23+
int sleep_time;
24+
int duration;
25+
int set_sched;
26+
int cgroup;
27+
int hk_cpus;
28+
cpu_set_t hk_cpu_set;
29+
struct sched_attr sched_param;
30+
struct trace_events *events;
31+
int warmup;
32+
int buffer_size;
33+
union {
34+
struct {
35+
/* top only */
36+
int quiet;
37+
int pretty_output;
38+
enum osnoise_mode mode;
39+
};
40+
struct {
41+
/* hist only */
42+
int output_divisor;
43+
char no_header;
44+
char no_summary;
45+
char no_index;
46+
char with_zeros;
47+
int bucket_size;
48+
int entries;
49+
};
50+
};
51+
};
52+
653
/*
754
* osnoise_context - read, store, write, restore osnoise configs.
855
*/

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,8 @@
1414
#include <time.h>
1515
#include <sched.h>
1616

17-
#include "utils.h"
1817
#include "osnoise.h"
1918

20-
struct osnoise_hist_params {
21-
char *cpus;
22-
cpu_set_t monitored_cpus;
23-
char *trace_output;
24-
char *cgroup_name;
25-
unsigned long long runtime;
26-
unsigned long long period;
27-
long long threshold;
28-
long long stop_us;
29-
long long stop_total_us;
30-
int sleep_time;
31-
int duration;
32-
int set_sched;
33-
int output_divisor;
34-
int cgroup;
35-
int hk_cpus;
36-
cpu_set_t hk_cpu_set;
37-
struct sched_attr sched_param;
38-
struct trace_events *events;
39-
char no_header;
40-
char no_summary;
41-
char no_index;
42-
char with_zeros;
43-
int bucket_size;
44-
int entries;
45-
int warmup;
46-
int buffer_size;
47-
};
48-
4919
struct osnoise_hist_cpu {
5020
int *samples;
5121
int count;
@@ -126,7 +96,7 @@ static struct osnoise_hist_data
12696
static void osnoise_hist_update_multiple(struct osnoise_tool *tool, int cpu,
12797
unsigned long long duration, int count)
12898
{
129-
struct osnoise_hist_params *params = tool->params;
99+
struct osnoise_params *params = tool->params;
130100
struct osnoise_hist_data *data = tool->data;
131101
unsigned long long total_duration;
132102
int entries = data->entries;
@@ -168,7 +138,7 @@ static void osnoise_destroy_trace_hist(struct osnoise_tool *tool)
168138
*/
169139
static int osnoise_init_trace_hist(struct osnoise_tool *tool)
170140
{
171-
struct osnoise_hist_params *params = tool->params;
141+
struct osnoise_params *params = tool->params;
172142
struct osnoise_hist_data *data = tool->data;
173143
int bucket_size;
174144
char buff[128];
@@ -253,7 +223,7 @@ static void osnoise_read_trace_hist(struct osnoise_tool *tool)
253223
*/
254224
static void osnoise_hist_header(struct osnoise_tool *tool)
255225
{
256-
struct osnoise_hist_params *params = tool->params;
226+
struct osnoise_params *params = tool->params;
257227
struct osnoise_hist_data *data = tool->data;
258228
struct trace_seq *s = tool->trace.seq;
259229
char duration[26];
@@ -292,7 +262,7 @@ static void osnoise_hist_header(struct osnoise_tool *tool)
292262
* osnoise_print_summary - print the summary of the hist data to the output
293263
*/
294264
static void
295-
osnoise_print_summary(struct osnoise_hist_params *params,
265+
osnoise_print_summary(struct osnoise_params *params,
296266
struct trace_instance *trace,
297267
struct osnoise_hist_data *data)
298268
{
@@ -370,7 +340,7 @@ osnoise_print_summary(struct osnoise_hist_params *params,
370340
* osnoise_print_stats - print data for all CPUs
371341
*/
372342
static void
373-
osnoise_print_stats(struct osnoise_hist_params *params, struct osnoise_tool *tool)
343+
osnoise_print_stats(struct osnoise_params *params, struct osnoise_tool *tool)
374344
{
375345
struct osnoise_hist_data *data = tool->data;
376346
struct trace_instance *trace = &tool->trace;
@@ -508,10 +478,10 @@ static void osnoise_hist_usage(char *usage)
508478
/*
509479
* osnoise_hist_parse_args - allocs, parse and fill the cmd line parameters
510480
*/
511-
static struct osnoise_hist_params
481+
static struct osnoise_params
512482
*osnoise_hist_parse_args(int argc, char *argv[])
513483
{
514-
struct osnoise_hist_params *params;
484+
struct osnoise_params *params;
515485
struct trace_events *tevent;
516486
int retval;
517487
int c;
@@ -731,7 +701,7 @@ static struct osnoise_hist_params
731701
* osnoise_hist_apply_config - apply the hist configs to the initialized tool
732702
*/
733703
static int
734-
osnoise_hist_apply_config(struct osnoise_tool *tool, struct osnoise_hist_params *params)
704+
osnoise_hist_apply_config(struct osnoise_tool *tool, struct osnoise_params *params)
735705
{
736706
int retval;
737707

@@ -808,7 +778,7 @@ osnoise_hist_apply_config(struct osnoise_tool *tool, struct osnoise_hist_params
808778
* osnoise_init_hist - initialize a osnoise hist tool with parameters
809779
*/
810780
static struct osnoise_tool
811-
*osnoise_init_hist(struct osnoise_hist_params *params)
781+
*osnoise_init_hist(struct osnoise_params *params)
812782
{
813783
struct osnoise_tool *tool;
814784
int nr_cpus;
@@ -842,7 +812,7 @@ static void stop_hist(int sig)
842812
* osnoise_hist_set_signals - handles the signal to stop the tool
843813
*/
844814
static void
845-
osnoise_hist_set_signals(struct osnoise_hist_params *params)
815+
osnoise_hist_set_signals(struct osnoise_params *params)
846816
{
847817
signal(SIGINT, stop_hist);
848818
if (params->duration) {
@@ -853,7 +823,7 @@ osnoise_hist_set_signals(struct osnoise_hist_params *params)
853823

854824
int osnoise_hist_main(int argc, char *argv[])
855825
{
856-
struct osnoise_hist_params *params;
826+
struct osnoise_params *params;
857827
struct osnoise_tool *record = NULL;
858828
struct osnoise_tool *tool = NULL;
859829
struct trace_instance *trace;

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,6 @@
1414
#include <sched.h>
1515

1616
#include "osnoise.h"
17-
#include "utils.h"
18-
19-
enum osnoise_mode {
20-
MODE_OSNOISE = 0,
21-
MODE_HWNOISE
22-
};
23-
24-
/*
25-
* osnoise top parameters
26-
*/
27-
struct osnoise_top_params {
28-
char *cpus;
29-
cpu_set_t monitored_cpus;
30-
char *trace_output;
31-
char *cgroup_name;
32-
unsigned long long runtime;
33-
unsigned long long period;
34-
long long threshold;
35-
long long stop_us;
36-
long long stop_total_us;
37-
int sleep_time;
38-
int duration;
39-
int quiet;
40-
int set_sched;
41-
int cgroup;
42-
int hk_cpus;
43-
int warmup;
44-
int buffer_size;
45-
int pretty_output;
46-
cpu_set_t hk_cpu_set;
47-
struct sched_attr sched_param;
48-
struct trace_events *events;
49-
enum osnoise_mode mode;
50-
};
5117

5218
struct osnoise_top_cpu {
5319
unsigned long long sum_runtime;
@@ -158,7 +124,7 @@ osnoise_top_handler(struct trace_seq *s, struct tep_record *record,
158124
*/
159125
static void osnoise_top_header(struct osnoise_tool *top)
160126
{
161-
struct osnoise_top_params *params = top->params;
127+
struct osnoise_params *params = top->params;
162128
struct trace_seq *s = top->trace.seq;
163129
char duration[26];
164130

@@ -218,7 +184,7 @@ static void clear_terminal(struct trace_seq *seq)
218184
*/
219185
static void osnoise_top_print(struct osnoise_tool *tool, int cpu)
220186
{
221-
struct osnoise_top_params *params = tool->params;
187+
struct osnoise_params *params = tool->params;
222188
struct trace_seq *s = tool->trace.seq;
223189
struct osnoise_top_cpu *cpu_data;
224190
struct osnoise_top_data *data;
@@ -258,7 +224,7 @@ static void osnoise_top_print(struct osnoise_tool *tool, int cpu)
258224
* osnoise_print_stats - print data for all cpus
259225
*/
260226
static void
261-
osnoise_print_stats(struct osnoise_top_params *params, struct osnoise_tool *top)
227+
osnoise_print_stats(struct osnoise_params *params, struct osnoise_tool *top)
262228
{
263229
struct trace_instance *trace = &top->trace;
264230
static int nr_cpus = -1;
@@ -286,7 +252,7 @@ osnoise_print_stats(struct osnoise_top_params *params, struct osnoise_tool *top)
286252
/*
287253
* osnoise_top_usage - prints osnoise top usage message
288254
*/
289-
static void osnoise_top_usage(struct osnoise_top_params *params, char *usage)
255+
static void osnoise_top_usage(struct osnoise_params *params, char *usage)
290256
{
291257
int i;
292258

@@ -354,9 +320,9 @@ static void osnoise_top_usage(struct osnoise_top_params *params, char *usage)
354320
/*
355321
* osnoise_top_parse_args - allocs, parse and fill the cmd line parameters
356322
*/
357-
struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
323+
struct osnoise_params *osnoise_top_parse_args(int argc, char **argv)
358324
{
359-
struct osnoise_top_params *params;
325+
struct osnoise_params *params;
360326
struct trace_events *tevent;
361327
int retval;
362328
int c;
@@ -553,7 +519,7 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
553519
* osnoise_top_apply_config - apply the top configs to the initialized tool
554520
*/
555521
static int
556-
osnoise_top_apply_config(struct osnoise_tool *tool, struct osnoise_top_params *params)
522+
osnoise_top_apply_config(struct osnoise_tool *tool, struct osnoise_params *params)
557523
{
558524
int retval;
559525

@@ -640,7 +606,7 @@ osnoise_top_apply_config(struct osnoise_tool *tool, struct osnoise_top_params *p
640606
/*
641607
* osnoise_init_top - initialize a osnoise top tool with parameters
642608
*/
643-
struct osnoise_tool *osnoise_init_top(struct osnoise_top_params *params)
609+
struct osnoise_tool *osnoise_init_top(struct osnoise_params *params)
644610
{
645611
struct osnoise_tool *tool;
646612
int nr_cpus;
@@ -674,7 +640,7 @@ static void stop_top(int sig)
674640
/*
675641
* osnoise_top_set_signals - handles the signal to stop the tool
676642
*/
677-
static void osnoise_top_set_signals(struct osnoise_top_params *params)
643+
static void osnoise_top_set_signals(struct osnoise_params *params)
678644
{
679645
signal(SIGINT, stop_top);
680646
if (params->duration) {
@@ -685,7 +651,7 @@ static void osnoise_top_set_signals(struct osnoise_top_params *params)
685651

686652
int osnoise_top_main(int argc, char **argv)
687653
{
688-
struct osnoise_top_params *params;
654+
struct osnoise_params *params;
689655
struct osnoise_tool *record = NULL;
690656
struct osnoise_tool *tool = NULL;
691657
struct trace_instance *trace;

tools/tracing/rtla/src/timerlat.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// SPDX-License-Identifier: GPL-2.0
2-
#include "utils.h"
32
#include "osnoise.h"
43

54
struct timerlat_params {

0 commit comments

Comments
 (0)