Skip to content

Commit caf3fc0

Browse files
makelinuxlenticularis39
authored andcommitted
tools/rtla: Remove unneeded nr_cpus members
nr_cpus does not change at runtime, so keeping it in struct members is unnecessary. Use the global nr_cpus instead of struct members. Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Link: https://lore.kernel.org/r/20260306194953.2511960-4-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
1 parent ea06305 commit caf3fc0

5 files changed

Lines changed: 38 additions & 50 deletions

File tree

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ struct osnoise_hist_data {
2929
struct osnoise_hist_cpu *hist;
3030
int entries;
3131
int bucket_size;
32-
int nr_cpus;
3332
};
3433

3534
/*
@@ -41,7 +40,7 @@ osnoise_free_histogram(struct osnoise_hist_data *data)
4140
int cpu;
4241

4342
/* one histogram for IRQ and one for thread, per CPU */
44-
for (cpu = 0; cpu < data->nr_cpus; cpu++) {
43+
for (cpu = 0; cpu < nr_cpus; cpu++) {
4544
if (data->hist[cpu].samples)
4645
free(data->hist[cpu].samples);
4746
}
@@ -73,7 +72,6 @@ static struct osnoise_hist_data
7372

7473
data->entries = entries;
7574
data->bucket_size = bucket_size;
76-
data->nr_cpus = nr_cpus;
7775

7876
data->hist = calloc(1, sizeof(*data->hist) * nr_cpus);
7977
if (!data->hist)
@@ -246,7 +244,7 @@ static void osnoise_hist_header(struct osnoise_tool *tool)
246244
if (!params->common.hist.no_index)
247245
trace_seq_printf(s, "Index");
248246

249-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
247+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
250248

251249
if (!data->hist[cpu].count)
252250
continue;
@@ -275,7 +273,7 @@ osnoise_print_summary(struct osnoise_params *params,
275273
if (!params->common.hist.no_index)
276274
trace_seq_printf(trace->seq, "count:");
277275

278-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
276+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
279277

280278
if (!data->hist[cpu].count)
281279
continue;
@@ -287,7 +285,7 @@ osnoise_print_summary(struct osnoise_params *params,
287285
if (!params->common.hist.no_index)
288286
trace_seq_printf(trace->seq, "min: ");
289287

290-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
288+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
291289

292290
if (!data->hist[cpu].count)
293291
continue;
@@ -300,7 +298,7 @@ osnoise_print_summary(struct osnoise_params *params,
300298
if (!params->common.hist.no_index)
301299
trace_seq_printf(trace->seq, "avg: ");
302300

303-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
301+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
304302

305303
if (!data->hist[cpu].count)
306304
continue;
@@ -316,7 +314,7 @@ osnoise_print_summary(struct osnoise_params *params,
316314
if (!params->common.hist.no_index)
317315
trace_seq_printf(trace->seq, "max: ");
318316

319-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
317+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
320318

321319
if (!data->hist[cpu].count)
322320
continue;
@@ -351,7 +349,7 @@ osnoise_print_stats(struct osnoise_tool *tool)
351349
trace_seq_printf(trace->seq, "%-6d",
352350
bucket * data->bucket_size);
353351

354-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
352+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
355353

356354
if (!data->hist[cpu].count)
357355
continue;
@@ -387,7 +385,7 @@ osnoise_print_stats(struct osnoise_tool *tool)
387385
if (!params->common.hist.no_index)
388386
trace_seq_printf(trace->seq, "over: ");
389387

390-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
388+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
391389

392390
if (!data->hist[cpu].count)
393391
continue;

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ struct osnoise_top_cpu {
3131

3232
struct osnoise_top_data {
3333
struct osnoise_top_cpu *cpu_data;
34-
int nr_cpus;
3534
};
3635

3736
/*
@@ -59,8 +58,6 @@ static struct osnoise_top_data *osnoise_alloc_top(void)
5958
if (!data)
6059
return NULL;
6160

62-
data->nr_cpus = nr_cpus;
63-
6461
/* one set of histograms per CPU */
6562
data->cpu_data = calloc(1, sizeof(*data->cpu_data) * nr_cpus);
6663
if (!data->cpu_data)

tools/tracing/rtla/src/timerlat_aa.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ struct timerlat_aa_data {
102102
* The analysis context and system wide view
103103
*/
104104
struct timerlat_aa_context {
105-
int nr_cpus;
106105
int dump_tasks;
107106
enum stack_format stack_format;
108107

@@ -759,7 +758,7 @@ void timerlat_auto_analysis(int irq_thresh, int thread_thresh)
759758
irq_thresh = irq_thresh * 1000;
760759
thread_thresh = thread_thresh * 1000;
761760

762-
for (cpu = 0; cpu < taa_ctx->nr_cpus; cpu++) {
761+
for (cpu = 0; cpu < nr_cpus; cpu++) {
763762
taa_data = timerlat_aa_get_data(taa_ctx, cpu);
764763

765764
if (irq_thresh && taa_data->tlat_irq_latency >= irq_thresh) {
@@ -787,7 +786,7 @@ void timerlat_auto_analysis(int irq_thresh, int thread_thresh)
787786

788787
printf("\n");
789788
printf("Printing CPU tasks:\n");
790-
for (cpu = 0; cpu < taa_ctx->nr_cpus; cpu++) {
789+
for (cpu = 0; cpu < nr_cpus; cpu++) {
791790
taa_data = timerlat_aa_get_data(taa_ctx, cpu);
792791
tep = taa_ctx->tool->trace.tep;
793792

@@ -813,7 +812,7 @@ static void timerlat_aa_destroy_seqs(struct timerlat_aa_context *taa_ctx)
813812
if (!taa_ctx->taa_data)
814813
return;
815814

816-
for (i = 0; i < taa_ctx->nr_cpus; i++) {
815+
for (i = 0; i < nr_cpus; i++) {
817816
taa_data = timerlat_aa_get_data(taa_ctx, i);
818817

819818
if (taa_data->prev_irqs_seq) {
@@ -863,7 +862,7 @@ static int timerlat_aa_init_seqs(struct timerlat_aa_context *taa_ctx)
863862
struct timerlat_aa_data *taa_data;
864863
int i;
865864

866-
for (i = 0; i < taa_ctx->nr_cpus; i++) {
865+
for (i = 0; i < nr_cpus; i++) {
867866

868867
taa_data = timerlat_aa_get_data(taa_ctx, i);
869868

@@ -1052,7 +1051,6 @@ int timerlat_aa_init(struct osnoise_tool *tool, int dump_tasks, enum stack_forma
10521051

10531052
__timerlat_aa_ctx = taa_ctx;
10541053

1055-
taa_ctx->nr_cpus = nr_cpus;
10561054
taa_ctx->tool = tool;
10571055
taa_ctx->dump_tasks = dump_tasks;
10581056
taa_ctx->stack_format = stack_format;

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ struct timerlat_hist_data {
4444
struct timerlat_hist_cpu *hist;
4545
int entries;
4646
int bucket_size;
47-
int nr_cpus;
4847
};
4948

5049
/*
@@ -56,7 +55,7 @@ timerlat_free_histogram(struct timerlat_hist_data *data)
5655
int cpu;
5756

5857
/* one histogram for IRQ and one for thread, per CPU */
59-
for (cpu = 0; cpu < data->nr_cpus; cpu++) {
58+
for (cpu = 0; cpu < nr_cpus; cpu++) {
6059
if (data->hist[cpu].irq)
6160
free(data->hist[cpu].irq);
6261

@@ -94,7 +93,6 @@ static struct timerlat_hist_data
9493

9594
data->entries = entries;
9695
data->bucket_size = bucket_size;
97-
data->nr_cpus = nr_cpus;
9896

9997
/* one set of histograms per CPU */
10098
data->hist = calloc(1, sizeof(*data->hist) * nr_cpus);
@@ -204,17 +202,17 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
204202
{
205203
struct timerlat_hist_data *data = tool->data;
206204
int i, j, err;
207-
long long value_irq[data->nr_cpus],
208-
value_thread[data->nr_cpus],
209-
value_user[data->nr_cpus];
205+
long long value_irq[nr_cpus],
206+
value_thread[nr_cpus],
207+
value_user[nr_cpus];
210208

211209
/* Pull histogram */
212210
for (i = 0; i < data->entries; i++) {
213211
err = timerlat_bpf_get_hist_value(i, value_irq, value_thread,
214212
value_user);
215213
if (err)
216214
return err;
217-
for (j = 0; j < data->nr_cpus; j++) {
215+
for (j = 0; j < nr_cpus; j++) {
218216
data->hist[j].irq[i] = value_irq[j];
219217
data->hist[j].thread[i] = value_thread[j];
220218
data->hist[j].user[i] = value_user[j];
@@ -226,7 +224,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
226224
value_irq, value_thread, value_user);
227225
if (err)
228226
return err;
229-
for (i = 0; i < data->nr_cpus; i++) {
227+
for (i = 0; i < nr_cpus; i++) {
230228
data->hist[i].irq_count = value_irq[i];
231229
data->hist[i].thread_count = value_thread[i];
232230
data->hist[i].user_count = value_user[i];
@@ -236,7 +234,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
236234
value_irq, value_thread, value_user);
237235
if (err)
238236
return err;
239-
for (i = 0; i < data->nr_cpus; i++) {
237+
for (i = 0; i < nr_cpus; i++) {
240238
data->hist[i].min_irq = value_irq[i];
241239
data->hist[i].min_thread = value_thread[i];
242240
data->hist[i].min_user = value_user[i];
@@ -246,7 +244,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
246244
value_irq, value_thread, value_user);
247245
if (err)
248246
return err;
249-
for (i = 0; i < data->nr_cpus; i++) {
247+
for (i = 0; i < nr_cpus; i++) {
250248
data->hist[i].max_irq = value_irq[i];
251249
data->hist[i].max_thread = value_thread[i];
252250
data->hist[i].max_user = value_user[i];
@@ -256,7 +254,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
256254
value_irq, value_thread, value_user);
257255
if (err)
258256
return err;
259-
for (i = 0; i < data->nr_cpus; i++) {
257+
for (i = 0; i < nr_cpus; i++) {
260258
data->hist[i].sum_irq = value_irq[i];
261259
data->hist[i].sum_thread = value_thread[i];
262260
data->hist[i].sum_user = value_user[i];
@@ -266,7 +264,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
266264
value_irq, value_thread, value_user);
267265
if (err)
268266
return err;
269-
for (i = 0; i < data->nr_cpus; i++) {
267+
for (i = 0; i < nr_cpus; i++) {
270268
data->hist[i].irq[data->entries] = value_irq[i];
271269
data->hist[i].thread[data->entries] = value_thread[i];
272270
data->hist[i].user[data->entries] = value_user[i];
@@ -300,7 +298,7 @@ static void timerlat_hist_header(struct osnoise_tool *tool)
300298
if (!params->common.hist.no_index)
301299
trace_seq_printf(s, "Index");
302300

303-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
301+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
304302

305303
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
306304
continue;
@@ -352,7 +350,7 @@ timerlat_print_summary(struct timerlat_params *params,
352350
if (!params->common.hist.no_index)
353351
trace_seq_printf(trace->seq, "count:");
354352

355-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
353+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
356354

357355
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
358356
continue;
@@ -374,7 +372,7 @@ timerlat_print_summary(struct timerlat_params *params,
374372
if (!params->common.hist.no_index)
375373
trace_seq_printf(trace->seq, "min: ");
376374

377-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
375+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
378376

379377
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
380378
continue;
@@ -402,7 +400,7 @@ timerlat_print_summary(struct timerlat_params *params,
402400
if (!params->common.hist.no_index)
403401
trace_seq_printf(trace->seq, "avg: ");
404402

405-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
403+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
406404

407405
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
408406
continue;
@@ -430,7 +428,7 @@ timerlat_print_summary(struct timerlat_params *params,
430428
if (!params->common.hist.no_index)
431429
trace_seq_printf(trace->seq, "max: ");
432430

433-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
431+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
434432

435433
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
436434
continue;
@@ -475,7 +473,7 @@ timerlat_print_stats_all(struct timerlat_params *params,
475473
sum.min_thread = ~0;
476474
sum.min_user = ~0;
477475

478-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
476+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
479477

480478
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
481479
continue;
@@ -622,7 +620,7 @@ timerlat_print_stats(struct osnoise_tool *tool)
622620
trace_seq_printf(trace->seq, "%-6d",
623621
bucket * data->bucket_size);
624622

625-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
623+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
626624

627625
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
628626
continue;
@@ -660,7 +658,7 @@ timerlat_print_stats(struct osnoise_tool *tool)
660658
if (!params->common.hist.no_index)
661659
trace_seq_printf(trace->seq, "over: ");
662660

663-
for_each_monitored_cpu(cpu, data->nr_cpus, &params->common) {
661+
for_each_monitored_cpu(cpu, nr_cpus, &params->common) {
664662

665663
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
666664
continue;

tools/tracing/rtla/src/timerlat_top.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ struct timerlat_top_cpu {
4141

4242
struct timerlat_top_data {
4343
struct timerlat_top_cpu *cpu_data;
44-
int nr_cpus;
4544
};
4645

4746
/*
@@ -71,8 +70,6 @@ static struct timerlat_top_data *timerlat_alloc_top(void)
7170
if (!data)
7271
return NULL;
7372

74-
data->nr_cpus = nr_cpus;
75-
7673
/* one set of histograms per CPU */
7774
data->cpu_data = calloc(1, sizeof(*data->cpu_data) * nr_cpus);
7875
if (!data->cpu_data)
@@ -190,16 +187,16 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
190187
{
191188
struct timerlat_top_data *data = tool->data;
192189
int i, err;
193-
long long value_irq[data->nr_cpus],
194-
value_thread[data->nr_cpus],
195-
value_user[data->nr_cpus];
190+
long long value_irq[nr_cpus],
191+
value_thread[nr_cpus],
192+
value_user[nr_cpus];
196193

197194
/* Pull summary */
198195
err = timerlat_bpf_get_summary_value(SUMMARY_CURRENT,
199196
value_irq, value_thread, value_user);
200197
if (err)
201198
return err;
202-
for (i = 0; i < data->nr_cpus; i++) {
199+
for (i = 0; i < nr_cpus; i++) {
203200
data->cpu_data[i].cur_irq = value_irq[i];
204201
data->cpu_data[i].cur_thread = value_thread[i];
205202
data->cpu_data[i].cur_user = value_user[i];
@@ -209,7 +206,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
209206
value_irq, value_thread, value_user);
210207
if (err)
211208
return err;
212-
for (i = 0; i < data->nr_cpus; i++) {
209+
for (i = 0; i < nr_cpus; i++) {
213210
data->cpu_data[i].irq_count = value_irq[i];
214211
data->cpu_data[i].thread_count = value_thread[i];
215212
data->cpu_data[i].user_count = value_user[i];
@@ -219,7 +216,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
219216
value_irq, value_thread, value_user);
220217
if (err)
221218
return err;
222-
for (i = 0; i < data->nr_cpus; i++) {
219+
for (i = 0; i < nr_cpus; i++) {
223220
data->cpu_data[i].min_irq = value_irq[i];
224221
data->cpu_data[i].min_thread = value_thread[i];
225222
data->cpu_data[i].min_user = value_user[i];
@@ -229,7 +226,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
229226
value_irq, value_thread, value_user);
230227
if (err)
231228
return err;
232-
for (i = 0; i < data->nr_cpus; i++) {
229+
for (i = 0; i < nr_cpus; i++) {
233230
data->cpu_data[i].max_irq = value_irq[i];
234231
data->cpu_data[i].max_thread = value_thread[i];
235232
data->cpu_data[i].max_user = value_user[i];
@@ -239,7 +236,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
239236
value_irq, value_thread, value_user);
240237
if (err)
241238
return err;
242-
for (i = 0; i < data->nr_cpus; i++) {
239+
for (i = 0; i < nr_cpus; i++) {
243240
data->cpu_data[i].sum_irq = value_irq[i];
244241
data->cpu_data[i].sum_thread = value_thread[i];
245242
data->cpu_data[i].sum_user = value_user[i];

0 commit comments

Comments
 (0)