Skip to content

Commit 3448238

Browse files
makelinuxrostedt
authored andcommitted
tools/rtla: Consolidate common parameters into shared structure
timerlat_params and osnoise_params structures contain 15 identical fields. Introduce a new header common.h and define a common_params structure to consolidate shared fields, reduce code duplication, and enhance maintainability. Cc: John Kacur <[email protected]> Link: https://lore.kernel.org/[email protected] Reviewed-by: Tomas Glozar <[email protected]> Signed-off-by: Costa Shulyupin <[email protected]> Signed-off-by: Crystal Wood <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 76eeb9b commit 3448238

File tree

10 files changed

+253
-252
lines changed

10 files changed

+253
-252
lines changed

tools/tracing/rtla/src/common.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#pragma once
3+
4+
#include "utils.h"
5+
6+
/*
7+
* common_params - Parameters shared between timerlat_params and osnoise_params
8+
*/
9+
struct common_params {
10+
/* trace configuration */
11+
char *cpus;
12+
cpu_set_t monitored_cpus;
13+
struct trace_events *events;
14+
int buffer_size;
15+
16+
/* Timing parameters */
17+
int warmup;
18+
long long stop_us;
19+
long long stop_total_us;
20+
int sleep_time;
21+
int duration;
22+
23+
/* Scheduling parameters */
24+
int set_sched;
25+
struct sched_attr sched_param;
26+
int cgroup;
27+
char *cgroup_name;
28+
int hk_cpus;
29+
cpu_set_t hk_cpu_set;
30+
};

tools/tracing/rtla/src/osnoise.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,10 +1127,10 @@ osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params)
11271127
{
11281128
int retval;
11291129

1130-
if (!params->sleep_time)
1131-
params->sleep_time = 1;
1130+
if (!params->common.sleep_time)
1131+
params->common.sleep_time = 1;
11321132

1133-
retval = osnoise_set_cpus(tool->context, params->cpus ? params->cpus : "all");
1133+
retval = osnoise_set_cpus(tool->context, params->common.cpus ? params->common.cpus : "all");
11341134
if (retval) {
11351135
err_msg("Failed to apply CPUs config\n");
11361136
goto out_err;
@@ -1151,13 +1151,13 @@ osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params)
11511151
goto out_err;
11521152
}
11531153

1154-
retval = osnoise_set_stop_us(tool->context, params->stop_us);
1154+
retval = osnoise_set_stop_us(tool->context, params->common.stop_us);
11551155
if (retval) {
11561156
err_msg("Failed to set stop us\n");
11571157
goto out_err;
11581158
}
11591159

1160-
retval = osnoise_set_stop_total_us(tool->context, params->stop_total_us);
1160+
retval = osnoise_set_stop_total_us(tool->context, params->common.stop_total_us);
11611161
if (retval) {
11621162
err_msg("Failed to set stop total us\n");
11631163
goto out_err;
@@ -1169,22 +1169,22 @@ osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params)
11691169
goto out_err;
11701170
}
11711171

1172-
if (params->hk_cpus) {
1173-
retval = sched_setaffinity(getpid(), sizeof(params->hk_cpu_set),
1174-
&params->hk_cpu_set);
1172+
if (params->common.hk_cpus) {
1173+
retval = sched_setaffinity(getpid(), sizeof(params->common.hk_cpu_set),
1174+
&params->common.hk_cpu_set);
11751175
if (retval == -1) {
11761176
err_msg("Failed to set rtla to the house keeping CPUs\n");
11771177
goto out_err;
11781178
}
1179-
} else if (params->cpus) {
1179+
} else if (params->common.cpus) {
11801180
/*
11811181
* Even if the user do not set a house-keeping CPU, try to
11821182
* move rtla to a CPU set different to the one where the user
11831183
* set the workload to run.
11841184
*
11851185
* No need to check results as this is an automatic attempt.
11861186
*/
1187-
auto_house_keeping(&params->monitored_cpus);
1187+
auto_house_keeping(&params->common.monitored_cpus);
11881188
}
11891189

11901190
retval = osnoise_set_workload(tool->context, true);

tools/tracing/rtla/src/osnoise.h

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

4-
#include "utils.h"
4+
#include "common.h"
55
#include "trace.h"
66

77
enum osnoise_mode {
@@ -10,26 +10,11 @@ enum osnoise_mode {
1010
};
1111

1212
struct osnoise_params {
13-
/* Common params */
14-
char *cpus;
15-
cpu_set_t monitored_cpus;
13+
struct common_params common;
1614
char *trace_output;
17-
char *cgroup_name;
1815
unsigned long long runtime;
1916
unsigned long long period;
2017
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;
3318
union {
3419
struct {
3520
/* top only */

0 commit comments

Comments
 (0)