Skip to content

Commit ea06305

Browse files
makelinuxlenticularis39
authored andcommitted
tools/rtla: Remove unneeded nr_cpus arguments
nr_cpus does not change at runtime, so passing it through function arguments is unnecessary. Use the global nr_cpus instead of propagating it via parameters. Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Link: https://lore.kernel.org/r/20260306194953.2511960-3-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
1 parent 115b06a commit ea06305

7 files changed

Lines changed: 34 additions & 51 deletions

File tree

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void osnoise_free_hist_tool(struct osnoise_tool *tool)
6262
* osnoise_alloc_histogram - alloc runtime data
6363
*/
6464
static struct osnoise_hist_data
65-
*osnoise_alloc_histogram(int nr_cpus, int entries, int bucket_size)
65+
*osnoise_alloc_histogram(int entries, int bucket_size)
6666
{
6767
struct osnoise_hist_data *data;
6868
int cpu;
@@ -651,7 +651,7 @@ static struct osnoise_tool
651651
if (!tool)
652652
return NULL;
653653

654-
tool->data = osnoise_alloc_histogram(nr_cpus, params->hist.entries,
654+
tool->data = osnoise_alloc_histogram(params->hist.entries,
655655
params->hist.bucket_size);
656656
if (!tool->data)
657657
goto out_err;

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static void osnoise_free_top_tool(struct osnoise_tool *tool)
5151
/*
5252
* osnoise_alloc_histogram - alloc runtime data
5353
*/
54-
static struct osnoise_top_data *osnoise_alloc_top(int nr_cpus)
54+
static struct osnoise_top_data *osnoise_alloc_top(void)
5555
{
5656
struct osnoise_top_data *data;
5757

@@ -495,7 +495,7 @@ struct osnoise_tool *osnoise_init_top(struct common_params *params)
495495
if (!tool)
496496
return NULL;
497497

498-
tool->data = osnoise_alloc_top(nr_cpus);
498+
tool->data = osnoise_alloc_top();
499499
if (!tool->data) {
500500
osnoise_destroy_tool(tool);
501501
return NULL;

tools/tracing/rtla/src/timerlat_bpf.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,24 +147,23 @@ static int get_value(struct bpf_map *map_irq,
147147
int key,
148148
long long *value_irq,
149149
long long *value_thread,
150-
long long *value_user,
151-
int cpus)
150+
long long *value_user)
152151
{
153152
int err;
154153

155154
err = bpf_map__lookup_elem(map_irq, &key,
156155
sizeof(unsigned int), value_irq,
157-
sizeof(long long) * cpus, 0);
156+
sizeof(long long) * nr_cpus, 0);
158157
if (err)
159158
return err;
160159
err = bpf_map__lookup_elem(map_thread, &key,
161160
sizeof(unsigned int), value_thread,
162-
sizeof(long long) * cpus, 0);
161+
sizeof(long long) * nr_cpus, 0);
163162
if (err)
164163
return err;
165164
err = bpf_map__lookup_elem(map_user, &key,
166165
sizeof(unsigned int), value_user,
167-
sizeof(long long) * cpus, 0);
166+
sizeof(long long) * nr_cpus, 0);
168167
if (err)
169168
return err;
170169
return 0;
@@ -176,13 +175,12 @@ static int get_value(struct bpf_map *map_irq,
176175
int timerlat_bpf_get_hist_value(int key,
177176
long long *value_irq,
178177
long long *value_thread,
179-
long long *value_user,
180-
int cpus)
178+
long long *value_user)
181179
{
182180
return get_value(bpf->maps.hist_irq,
183181
bpf->maps.hist_thread,
184182
bpf->maps.hist_user,
185-
key, value_irq, value_thread, value_user, cpus);
183+
key, value_irq, value_thread, value_user);
186184
}
187185

188186
/*
@@ -191,13 +189,12 @@ int timerlat_bpf_get_hist_value(int key,
191189
int timerlat_bpf_get_summary_value(enum summary_field key,
192190
long long *value_irq,
193191
long long *value_thread,
194-
long long *value_user,
195-
int cpus)
192+
long long *value_user)
196193
{
197194
return get_value(bpf->maps.summary_irq,
198195
bpf->maps.summary_thread,
199196
bpf->maps.summary_user,
200-
key, value_irq, value_thread, value_user, cpus);
197+
key, value_irq, value_thread, value_user);
201198
}
202199

203200
/*

tools/tracing/rtla/src/timerlat_bpf.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ int timerlat_bpf_restart_tracing(void);
2323
int timerlat_bpf_get_hist_value(int key,
2424
long long *value_irq,
2525
long long *value_thread,
26-
long long *value_user,
27-
int cpus);
26+
long long *value_user);
2827
int timerlat_bpf_get_summary_value(enum summary_field key,
2928
long long *value_irq,
3029
long long *value_thread,
31-
long long *value_user,
32-
int cpus);
30+
long long *value_user);
3331
int timerlat_load_bpf_action_program(const char *program_path);
3432
static inline int have_libbpf_support(void) { return 1; }
3533
#else
@@ -45,16 +43,14 @@ static inline int timerlat_bpf_restart_tracing(void) { return -1; };
4543
static inline int timerlat_bpf_get_hist_value(int key,
4644
long long *value_irq,
4745
long long *value_thread,
48-
long long *value_user,
49-
int cpus)
46+
long long *value_user)
5047
{
5148
return -1;
5249
}
5350
static inline int timerlat_bpf_get_summary_value(enum summary_field key,
5451
long long *value_irq,
5552
long long *value_thread,
56-
long long *value_user,
57-
int cpus)
53+
long long *value_user)
5854
{
5955
return -1;
6056
}

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void timerlat_free_histogram_tool(struct osnoise_tool *tool)
8383
* timerlat_alloc_histogram - alloc runtime data
8484
*/
8585
static struct timerlat_hist_data
86-
*timerlat_alloc_histogram(int nr_cpus, int entries, int bucket_size)
86+
*timerlat_alloc_histogram(int entries, int bucket_size)
8787
{
8888
struct timerlat_hist_data *data;
8989
int cpu;
@@ -211,7 +211,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
211211
/* Pull histogram */
212212
for (i = 0; i < data->entries; i++) {
213213
err = timerlat_bpf_get_hist_value(i, value_irq, value_thread,
214-
value_user, data->nr_cpus);
214+
value_user);
215215
if (err)
216216
return err;
217217
for (j = 0; j < data->nr_cpus; j++) {
@@ -223,8 +223,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
223223

224224
/* Pull summary */
225225
err = timerlat_bpf_get_summary_value(SUMMARY_COUNT,
226-
value_irq, value_thread, value_user,
227-
data->nr_cpus);
226+
value_irq, value_thread, value_user);
228227
if (err)
229228
return err;
230229
for (i = 0; i < data->nr_cpus; i++) {
@@ -234,8 +233,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
234233
}
235234

236235
err = timerlat_bpf_get_summary_value(SUMMARY_MIN,
237-
value_irq, value_thread, value_user,
238-
data->nr_cpus);
236+
value_irq, value_thread, value_user);
239237
if (err)
240238
return err;
241239
for (i = 0; i < data->nr_cpus; i++) {
@@ -245,8 +243,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
245243
}
246244

247245
err = timerlat_bpf_get_summary_value(SUMMARY_MAX,
248-
value_irq, value_thread, value_user,
249-
data->nr_cpus);
246+
value_irq, value_thread, value_user);
250247
if (err)
251248
return err;
252249
for (i = 0; i < data->nr_cpus; i++) {
@@ -256,8 +253,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
256253
}
257254

258255
err = timerlat_bpf_get_summary_value(SUMMARY_SUM,
259-
value_irq, value_thread, value_user,
260-
data->nr_cpus);
256+
value_irq, value_thread, value_user);
261257
if (err)
262258
return err;
263259
for (i = 0; i < data->nr_cpus; i++) {
@@ -267,8 +263,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
267263
}
268264

269265
err = timerlat_bpf_get_summary_value(SUMMARY_OVERFLOW,
270-
value_irq, value_thread, value_user,
271-
data->nr_cpus);
266+
value_irq, value_thread, value_user);
272267
if (err)
273268
return err;
274269
for (i = 0; i < data->nr_cpus; i++) {
@@ -1045,7 +1040,7 @@ static struct osnoise_tool
10451040
if (!tool)
10461041
return NULL;
10471042

1048-
tool->data = timerlat_alloc_histogram(nr_cpus, params->hist.entries,
1043+
tool->data = timerlat_alloc_histogram(params->hist.entries,
10491044
params->hist.bucket_size);
10501045
if (!tool->data)
10511046
goto out_err;

tools/tracing/rtla/src/timerlat_top.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void timerlat_free_top_tool(struct osnoise_tool *tool)
6262
/*
6363
* timerlat_alloc_histogram - alloc runtime data
6464
*/
65-
static struct timerlat_top_data *timerlat_alloc_top(int nr_cpus)
65+
static struct timerlat_top_data *timerlat_alloc_top(void)
6666
{
6767
struct timerlat_top_data *data;
6868
int cpu;
@@ -196,8 +196,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
196196

197197
/* Pull summary */
198198
err = timerlat_bpf_get_summary_value(SUMMARY_CURRENT,
199-
value_irq, value_thread, value_user,
200-
data->nr_cpus);
199+
value_irq, value_thread, value_user);
201200
if (err)
202201
return err;
203202
for (i = 0; i < data->nr_cpus; i++) {
@@ -207,8 +206,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
207206
}
208207

209208
err = timerlat_bpf_get_summary_value(SUMMARY_COUNT,
210-
value_irq, value_thread, value_user,
211-
data->nr_cpus);
209+
value_irq, value_thread, value_user);
212210
if (err)
213211
return err;
214212
for (i = 0; i < data->nr_cpus; i++) {
@@ -218,8 +216,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
218216
}
219217

220218
err = timerlat_bpf_get_summary_value(SUMMARY_MIN,
221-
value_irq, value_thread, value_user,
222-
data->nr_cpus);
219+
value_irq, value_thread, value_user);
223220
if (err)
224221
return err;
225222
for (i = 0; i < data->nr_cpus; i++) {
@@ -229,8 +226,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
229226
}
230227

231228
err = timerlat_bpf_get_summary_value(SUMMARY_MAX,
232-
value_irq, value_thread, value_user,
233-
data->nr_cpus);
229+
value_irq, value_thread, value_user);
234230
if (err)
235231
return err;
236232
for (i = 0; i < data->nr_cpus; i++) {
@@ -240,8 +236,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
240236
}
241237

242238
err = timerlat_bpf_get_summary_value(SUMMARY_SUM,
243-
value_irq, value_thread, value_user,
244-
data->nr_cpus);
239+
value_irq, value_thread, value_user);
245240
if (err)
246241
return err;
247242
for (i = 0; i < data->nr_cpus; i++) {
@@ -791,7 +786,7 @@ static struct osnoise_tool
791786
if (!top)
792787
return NULL;
793788

794-
top->data = timerlat_alloc_top(nr_cpus);
789+
top->data = timerlat_alloc_top();
795790
if (!top->data)
796791
goto out_err;
797792

tools/tracing/rtla/src/timerlat_u.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int timerlat_u_main(int cpu, struct timerlat_u_params *params)
9999
*
100100
* Return the number of processes that received the kill.
101101
*/
102-
static int timerlat_u_send_kill(pid_t *procs, int nr_cpus)
102+
static int timerlat_u_send_kill(pid_t *procs)
103103
{
104104
int killed = 0;
105105
int i, retval;
@@ -169,7 +169,7 @@ void *timerlat_u_dispatcher(void *data)
169169

170170
/* parent */
171171
if (pid == -1) {
172-
timerlat_u_send_kill(procs, nr_cpus);
172+
timerlat_u_send_kill(procs);
173173
debug_msg("Failed to create child processes");
174174
pthread_exit(&retval);
175175
}
@@ -196,7 +196,7 @@ void *timerlat_u_dispatcher(void *data)
196196
sleep(1);
197197
}
198198

199-
timerlat_u_send_kill(procs, nr_cpus);
199+
timerlat_u_send_kill(procs);
200200

201201
while (procs_count) {
202202
pid = waitpid(-1, &wstatus, 0);

0 commit comments

Comments
 (0)