* [PATCH v1 2/4] tools/rtla: Remove unneeded nr_cpus arguments
2025-12-05 15:19 [PATCH v1 1/4] tools/rtla: Consolidate nr_cpus usage across all tools Costa Shulyupin
@ 2025-12-05 15:19 ` Costa Shulyupin
2025-12-05 15:19 ` [PATCH v1 3/4] tools/rtla: Remove unneeded nr_cpus members Costa Shulyupin
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Costa Shulyupin @ 2025-12-05 15:19 UTC (permalink / raw)
To: Steven Rostedt, Tomas Glozar, Crystal Wood, Wander Lairson Costa,
Costa Shulyupin, Ivan Pravdin, John Kacur, Tiezhu Yang,
linux-trace-kernel, linux-kernel, bpf
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>
---
tools/tracing/rtla/src/osnoise_hist.c | 4 ++--
tools/tracing/rtla/src/osnoise_top.c | 4 ++--
tools/tracing/rtla/src/timerlat_bpf.c | 5 ++---
tools/tracing/rtla/src/timerlat_bpf.h | 6 ++----
tools/tracing/rtla/src/timerlat_hist.c | 19 +++++++------------
tools/tracing/rtla/src/timerlat_top.c | 19 +++++++------------
tools/tracing/rtla/src/timerlat_u.c | 6 +++---
7 files changed, 25 insertions(+), 38 deletions(-)
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index 0bed9717cef6..ae773334e700 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -63,7 +63,7 @@ static void osnoise_free_hist_tool(struct osnoise_tool *tool)
* osnoise_alloc_histogram - alloc runtime data
*/
static struct osnoise_hist_data
-*osnoise_alloc_histogram(int nr_cpus, int entries, int bucket_size)
+*osnoise_alloc_histogram(int entries, int bucket_size)
{
struct osnoise_hist_data *data;
int cpu;
@@ -704,7 +704,7 @@ static struct osnoise_tool
if (!tool)
return NULL;
- tool->data = osnoise_alloc_histogram(nr_cpus, params->hist.entries,
+ tool->data = osnoise_alloc_histogram(params->hist.entries,
params->hist.bucket_size);
if (!tool->data)
goto out_err;
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 8fa0046f0136..367a765387c8 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -51,7 +51,7 @@ static void osnoise_free_top_tool(struct osnoise_tool *tool)
/*
* osnoise_alloc_histogram - alloc runtime data
*/
-static struct osnoise_top_data *osnoise_alloc_top(int nr_cpus)
+static struct osnoise_top_data *osnoise_alloc_top(void)
{
struct osnoise_top_data *data;
@@ -548,7 +548,7 @@ struct osnoise_tool *osnoise_init_top(struct common_params *params)
if (!tool)
return NULL;
- tool->data = osnoise_alloc_top(nr_cpus);
+ tool->data = osnoise_alloc_top();
if (!tool->data) {
osnoise_destroy_tool(tool);
return NULL;
diff --git a/tools/tracing/rtla/src/timerlat_bpf.c b/tools/tracing/rtla/src/timerlat_bpf.c
index e97d16646bcd..4b623a904802 100644
--- a/tools/tracing/rtla/src/timerlat_bpf.c
+++ b/tools/tracing/rtla/src/timerlat_bpf.c
@@ -169,12 +169,11 @@ int timerlat_bpf_get_hist_value(int key,
int timerlat_bpf_get_summary_value(enum summary_field key,
long long *value_irq,
long long *value_thread,
- long long *value_user,
- int cpus)
+ long long *value_user)
{
return get_value(bpf->maps.summary_irq,
bpf->maps.summary_thread,
bpf->maps.summary_user,
- key, value_irq, value_thread, value_user, cpus);
+ key, value_irq, value_thread, value_user, nr_cpus);
}
#endif /* HAVE_BPF_SKEL */
diff --git a/tools/tracing/rtla/src/timerlat_bpf.h b/tools/tracing/rtla/src/timerlat_bpf.h
index 118487436d30..2b18f3061c32 100644
--- a/tools/tracing/rtla/src/timerlat_bpf.h
+++ b/tools/tracing/rtla/src/timerlat_bpf.h
@@ -27,8 +27,7 @@ int timerlat_bpf_get_hist_value(int key,
int timerlat_bpf_get_summary_value(enum summary_field key,
long long *value_irq,
long long *value_thread,
- long long *value_user,
- int cpus);
+ long long *value_user);
static inline int have_libbpf_support(void) { return 1; }
#else
@@ -52,8 +51,7 @@ static inline int timerlat_bpf_get_hist_value(int key,
static inline int timerlat_bpf_get_summary_value(enum summary_field key,
long long *value_irq,
long long *value_thread,
- long long *value_user,
- int cpus)
+ long long *value_user)
{
return -1;
}
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index 37bb9b931c8c..d4a9dcd67d48 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -83,7 +83,7 @@ static void timerlat_free_histogram_tool(struct osnoise_tool *tool)
* timerlat_alloc_histogram - alloc runtime data
*/
static struct timerlat_hist_data
-*timerlat_alloc_histogram(int nr_cpus, int entries, int bucket_size)
+*timerlat_alloc_histogram(int entries, int bucket_size)
{
struct timerlat_hist_data *data;
int cpu;
@@ -223,8 +223,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
/* Pull summary */
err = timerlat_bpf_get_summary_value(SUMMARY_COUNT,
- value_irq, value_thread, value_user,
- data->nr_cpus);
+ value_irq, value_thread, value_user);
if (err)
return err;
for (i = 0; i < data->nr_cpus; i++) {
@@ -234,8 +233,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
}
err = timerlat_bpf_get_summary_value(SUMMARY_MIN,
- value_irq, value_thread, value_user,
- data->nr_cpus);
+ value_irq, value_thread, value_user);
if (err)
return err;
for (i = 0; i < data->nr_cpus; i++) {
@@ -245,8 +243,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
}
err = timerlat_bpf_get_summary_value(SUMMARY_MAX,
- value_irq, value_thread, value_user,
- data->nr_cpus);
+ value_irq, value_thread, value_user);
if (err)
return err;
for (i = 0; i < data->nr_cpus; i++) {
@@ -256,8 +253,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
}
err = timerlat_bpf_get_summary_value(SUMMARY_SUM,
- value_irq, value_thread, value_user,
- data->nr_cpus);
+ value_irq, value_thread, value_user);
if (err)
return err;
for (i = 0; i < data->nr_cpus; i++) {
@@ -267,8 +263,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
}
err = timerlat_bpf_get_summary_value(SUMMARY_OVERFLOW,
- value_irq, value_thread, value_user,
- data->nr_cpus);
+ value_irq, value_thread, value_user);
if (err)
return err;
for (i = 0; i < data->nr_cpus; i++) {
@@ -1082,7 +1077,7 @@ static struct osnoise_tool
if (!tool)
return NULL;
- tool->data = timerlat_alloc_histogram(nr_cpus, params->hist.entries,
+ tool->data = timerlat_alloc_histogram(params->hist.entries,
params->hist.bucket_size);
if (!tool->data)
goto out_err;
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 8b15f4439c6c..7b62549f69e3 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -63,7 +63,7 @@ static void timerlat_free_top_tool(struct osnoise_tool *tool)
/*
* timerlat_alloc_histogram - alloc runtime data
*/
-static struct timerlat_top_data *timerlat_alloc_top(int nr_cpus)
+static struct timerlat_top_data *timerlat_alloc_top(void)
{
struct timerlat_top_data *data;
int cpu;
@@ -197,8 +197,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
/* Pull summary */
err = timerlat_bpf_get_summary_value(SUMMARY_CURRENT,
- value_irq, value_thread, value_user,
- data->nr_cpus);
+ value_irq, value_thread, value_user);
if (err)
return err;
for (i = 0; i < data->nr_cpus; i++) {
@@ -208,8 +207,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
}
err = timerlat_bpf_get_summary_value(SUMMARY_COUNT,
- value_irq, value_thread, value_user,
- data->nr_cpus);
+ value_irq, value_thread, value_user);
if (err)
return err;
for (i = 0; i < data->nr_cpus; i++) {
@@ -219,8 +217,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
}
err = timerlat_bpf_get_summary_value(SUMMARY_MIN,
- value_irq, value_thread, value_user,
- data->nr_cpus);
+ value_irq, value_thread, value_user);
if (err)
return err;
for (i = 0; i < data->nr_cpus; i++) {
@@ -230,8 +227,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
}
err = timerlat_bpf_get_summary_value(SUMMARY_MAX,
- value_irq, value_thread, value_user,
- data->nr_cpus);
+ value_irq, value_thread, value_user);
if (err)
return err;
for (i = 0; i < data->nr_cpus; i++) {
@@ -241,8 +237,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
}
err = timerlat_bpf_get_summary_value(SUMMARY_SUM,
- value_irq, value_thread, value_user,
- data->nr_cpus);
+ value_irq, value_thread, value_user);
if (err)
return err;
for (i = 0; i < data->nr_cpus; i++) {
@@ -828,7 +823,7 @@ static struct osnoise_tool
if (!top)
return NULL;
- top->data = timerlat_alloc_top(nr_cpus);
+ top->data = timerlat_alloc_top();
if (!top->data)
goto out_err;
diff --git a/tools/tracing/rtla/src/timerlat_u.c b/tools/tracing/rtla/src/timerlat_u.c
index a569fe7f93aa..03b4e68e8b1e 100644
--- a/tools/tracing/rtla/src/timerlat_u.c
+++ b/tools/tracing/rtla/src/timerlat_u.c
@@ -99,7 +99,7 @@ static int timerlat_u_main(int cpu, struct timerlat_u_params *params)
*
* Return the number of processes that received the kill.
*/
-static int timerlat_u_send_kill(pid_t *procs, int nr_cpus)
+static int timerlat_u_send_kill(pid_t *procs)
{
int killed = 0;
int i, retval;
@@ -169,7 +169,7 @@ void *timerlat_u_dispatcher(void *data)
/* parent */
if (pid == -1) {
- timerlat_u_send_kill(procs, nr_cpus);
+ timerlat_u_send_kill(procs);
debug_msg("Failed to create child processes");
pthread_exit(&retval);
}
@@ -196,7 +196,7 @@ void *timerlat_u_dispatcher(void *data)
sleep(1);
}
- timerlat_u_send_kill(procs, nr_cpus);
+ timerlat_u_send_kill(procs);
while (procs_count) {
pid = waitpid(-1, &wstatus, 0);
--
2.52.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v1 3/4] tools/rtla: Remove unneeded nr_cpus members
2025-12-05 15:19 [PATCH v1 1/4] tools/rtla: Consolidate nr_cpus usage across all tools Costa Shulyupin
2025-12-05 15:19 ` [PATCH v1 2/4] tools/rtla: Remove unneeded nr_cpus arguments Costa Shulyupin
@ 2025-12-05 15:19 ` Costa Shulyupin
2025-12-05 15:19 ` [PATCH v1 4/4] tools/rtla: Remove unneeded nr_cpus from for_each_monitored_cpu Costa Shulyupin
2025-12-16 14:41 ` [PATCH v1 1/4] tools/rtla: Consolidate nr_cpus usage across all tools Tomas Glozar
3 siblings, 0 replies; 7+ messages in thread
From: Costa Shulyupin @ 2025-12-05 15:19 UTC (permalink / raw)
To: Steven Rostedt, Tomas Glozar, Crystal Wood, Wander Lairson Costa,
Costa Shulyupin, Ivan Pravdin, John Kacur, Tiezhu Yang,
linux-trace-kernel, linux-kernel, bpf
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>
---
tools/tracing/rtla/src/osnoise_hist.c | 18 ++++++------
tools/tracing/rtla/src/osnoise_top.c | 3 --
tools/tracing/rtla/src/timerlat_aa.c | 10 +++----
tools/tracing/rtla/src/timerlat_hist.c | 40 ++++++++++++--------------
tools/tracing/rtla/src/timerlat_top.c | 19 ++++++------
5 files changed, 39 insertions(+), 51 deletions(-)
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index ae773334e700..7514b29ec559 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -30,7 +30,6 @@ struct osnoise_hist_data {
struct osnoise_hist_cpu *hist;
int entries;
int bucket_size;
- int nr_cpus;
};
/*
@@ -42,7 +41,7 @@ osnoise_free_histogram(struct osnoise_hist_data *data)
int cpu;
/* one histogram for IRQ and one for thread, per CPU */
- for (cpu = 0; cpu < data->nr_cpus; cpu++) {
+ for (cpu = 0; cpu < nr_cpus; cpu++) {
if (data->hist[cpu].samples)
free(data->hist[cpu].samples);
}
@@ -74,7 +73,6 @@ static struct osnoise_hist_data
data->entries = entries;
data->bucket_size = bucket_size;
- data->nr_cpus = nr_cpus;
data->hist = calloc(1, sizeof(*data->hist) * nr_cpus);
if (!data->hist)
@@ -247,7 +245,7 @@ static void osnoise_hist_header(struct osnoise_tool *tool)
if (!params->common.hist.no_index)
trace_seq_printf(s, "Index");
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
@@ -276,7 +274,7 @@ osnoise_print_summary(struct osnoise_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "count:");
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
@@ -288,7 +286,7 @@ osnoise_print_summary(struct osnoise_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "min: ");
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
@@ -301,7 +299,7 @@ osnoise_print_summary(struct osnoise_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "avg: ");
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
@@ -317,7 +315,7 @@ osnoise_print_summary(struct osnoise_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "max: ");
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
@@ -352,7 +350,7 @@ osnoise_print_stats(struct osnoise_tool *tool)
trace_seq_printf(trace->seq, "%-6d",
bucket * data->bucket_size);
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
@@ -388,7 +386,7 @@ osnoise_print_stats(struct osnoise_tool *tool)
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "over: ");
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 367a765387c8..e5a13f1bdfb6 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -31,7 +31,6 @@ struct osnoise_top_cpu {
struct osnoise_top_data {
struct osnoise_top_cpu *cpu_data;
- int nr_cpus;
};
/*
@@ -59,8 +58,6 @@ static struct osnoise_top_data *osnoise_alloc_top(void)
if (!data)
return NULL;
- data->nr_cpus = nr_cpus;
-
/* one set of histograms per CPU */
data->cpu_data = calloc(1, sizeof(*data->cpu_data) * nr_cpus);
if (!data->cpu_data)
diff --git a/tools/tracing/rtla/src/timerlat_aa.c b/tools/tracing/rtla/src/timerlat_aa.c
index 5766d58709eb..59b219a1503e 100644
--- a/tools/tracing/rtla/src/timerlat_aa.c
+++ b/tools/tracing/rtla/src/timerlat_aa.c
@@ -102,7 +102,6 @@ struct timerlat_aa_data {
* The analysis context and system wide view
*/
struct timerlat_aa_context {
- int nr_cpus;
int dump_tasks;
/* per CPU data */
@@ -738,7 +737,7 @@ void timerlat_auto_analysis(int irq_thresh, int thread_thresh)
irq_thresh = irq_thresh * 1000;
thread_thresh = thread_thresh * 1000;
- for (cpu = 0; cpu < taa_ctx->nr_cpus; cpu++) {
+ for (cpu = 0; cpu < nr_cpus; cpu++) {
taa_data = timerlat_aa_get_data(taa_ctx, cpu);
if (irq_thresh && taa_data->tlat_irq_latency >= irq_thresh) {
@@ -766,7 +765,7 @@ void timerlat_auto_analysis(int irq_thresh, int thread_thresh)
printf("\n");
printf("Printing CPU tasks:\n");
- for (cpu = 0; cpu < taa_ctx->nr_cpus; cpu++) {
+ for (cpu = 0; cpu < nr_cpus; cpu++) {
taa_data = timerlat_aa_get_data(taa_ctx, cpu);
tep = taa_ctx->tool->trace.tep;
@@ -792,7 +791,7 @@ static void timerlat_aa_destroy_seqs(struct timerlat_aa_context *taa_ctx)
if (!taa_ctx->taa_data)
return;
- for (i = 0; i < taa_ctx->nr_cpus; i++) {
+ for (i = 0; i < nr_cpus; i++) {
taa_data = timerlat_aa_get_data(taa_ctx, i);
if (taa_data->prev_irqs_seq) {
@@ -842,7 +841,7 @@ static int timerlat_aa_init_seqs(struct timerlat_aa_context *taa_ctx)
struct timerlat_aa_data *taa_data;
int i;
- for (i = 0; i < taa_ctx->nr_cpus; i++) {
+ for (i = 0; i < nr_cpus; i++) {
taa_data = timerlat_aa_get_data(taa_ctx, i);
@@ -1031,7 +1030,6 @@ int timerlat_aa_init(struct osnoise_tool *tool, int dump_tasks)
__timerlat_aa_ctx = taa_ctx;
- taa_ctx->nr_cpus = nr_cpus;
taa_ctx->tool = tool;
taa_ctx->dump_tasks = dump_tasks;
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index d4a9dcd67d48..207359f1cec4 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -44,7 +44,6 @@ struct timerlat_hist_data {
struct timerlat_hist_cpu *hist;
int entries;
int bucket_size;
- int nr_cpus;
};
/*
@@ -56,7 +55,7 @@ timerlat_free_histogram(struct timerlat_hist_data *data)
int cpu;
/* one histogram for IRQ and one for thread, per CPU */
- for (cpu = 0; cpu < data->nr_cpus; cpu++) {
+ for (cpu = 0; cpu < nr_cpus; cpu++) {
if (data->hist[cpu].irq)
free(data->hist[cpu].irq);
@@ -94,7 +93,6 @@ static struct timerlat_hist_data
data->entries = entries;
data->bucket_size = bucket_size;
- data->nr_cpus = nr_cpus;
/* one set of histograms per CPU */
data->hist = calloc(1, sizeof(*data->hist) * nr_cpus);
@@ -204,17 +202,17 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
{
struct timerlat_hist_data *data = tool->data;
int i, j, err;
- long long value_irq[data->nr_cpus],
- value_thread[data->nr_cpus],
- value_user[data->nr_cpus];
+ long long value_irq[nr_cpus],
+ value_thread[nr_cpus],
+ value_user[nr_cpus];
/* Pull histogram */
for (i = 0; i < data->entries; i++) {
err = timerlat_bpf_get_hist_value(i, value_irq, value_thread,
- value_user, data->nr_cpus);
+ value_user, nr_cpus);
if (err)
return err;
- for (j = 0; j < data->nr_cpus; j++) {
+ for (j = 0; j < nr_cpus; j++) {
data->hist[j].irq[i] = value_irq[j];
data->hist[j].thread[i] = value_thread[j];
data->hist[j].user[i] = value_user[j];
@@ -226,7 +224,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
value_irq, value_thread, value_user);
if (err)
return err;
- for (i = 0; i < data->nr_cpus; i++) {
+ for (i = 0; i < nr_cpus; i++) {
data->hist[i].irq_count = value_irq[i];
data->hist[i].thread_count = value_thread[i];
data->hist[i].user_count = value_user[i];
@@ -236,7 +234,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
value_irq, value_thread, value_user);
if (err)
return err;
- for (i = 0; i < data->nr_cpus; i++) {
+ for (i = 0; i < nr_cpus; i++) {
data->hist[i].min_irq = value_irq[i];
data->hist[i].min_thread = value_thread[i];
data->hist[i].min_user = value_user[i];
@@ -246,7 +244,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
value_irq, value_thread, value_user);
if (err)
return err;
- for (i = 0; i < data->nr_cpus; i++) {
+ for (i = 0; i < nr_cpus; i++) {
data->hist[i].max_irq = value_irq[i];
data->hist[i].max_thread = value_thread[i];
data->hist[i].max_user = value_user[i];
@@ -256,7 +254,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
value_irq, value_thread, value_user);
if (err)
return err;
- for (i = 0; i < data->nr_cpus; i++) {
+ for (i = 0; i < nr_cpus; i++) {
data->hist[i].sum_irq = value_irq[i];
data->hist[i].sum_thread = value_thread[i];
data->hist[i].sum_user = value_user[i];
@@ -266,7 +264,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
value_irq, value_thread, value_user);
if (err)
return err;
- for (i = 0; i < data->nr_cpus; i++) {
+ for (i = 0; i < nr_cpus; i++) {
data->hist[i].irq[data->entries] = value_irq[i];
data->hist[i].thread[data->entries] = value_thread[i];
data->hist[i].user[data->entries] = value_user[i];
@@ -300,7 +298,7 @@ static void timerlat_hist_header(struct osnoise_tool *tool)
if (!params->common.hist.no_index)
trace_seq_printf(s, "Index");
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -352,7 +350,7 @@ timerlat_print_summary(struct timerlat_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "count:");
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -374,7 +372,7 @@ timerlat_print_summary(struct timerlat_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "min: ");
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -402,7 +400,7 @@ timerlat_print_summary(struct timerlat_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "avg: ");
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -430,7 +428,7 @@ timerlat_print_summary(struct timerlat_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "max: ");
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -475,7 +473,7 @@ timerlat_print_stats_all(struct timerlat_params *params,
sum.min_thread = ~0;
sum.min_user = ~0;
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -622,7 +620,7 @@ timerlat_print_stats(struct osnoise_tool *tool)
trace_seq_printf(trace->seq, "%-6d",
bucket * data->bucket_size);
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -660,7 +658,7 @@ timerlat_print_stats(struct osnoise_tool *tool)
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "over: ");
- for_each_monitored_cpu(cpu, data->nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 7b62549f69e3..34c8a0010828 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -42,7 +42,6 @@ struct timerlat_top_cpu {
struct timerlat_top_data {
struct timerlat_top_cpu *cpu_data;
- int nr_cpus;
};
/*
@@ -72,8 +71,6 @@ static struct timerlat_top_data *timerlat_alloc_top(void)
if (!data)
return NULL;
- data->nr_cpus = nr_cpus;
-
/* one set of histograms per CPU */
data->cpu_data = calloc(1, sizeof(*data->cpu_data) * nr_cpus);
if (!data->cpu_data)
@@ -191,16 +188,16 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
{
struct timerlat_top_data *data = tool->data;
int i, err;
- long long value_irq[data->nr_cpus],
- value_thread[data->nr_cpus],
- value_user[data->nr_cpus];
+ long long value_irq[nr_cpus],
+ value_thread[nr_cpus],
+ value_user[nr_cpus];
/* Pull summary */
err = timerlat_bpf_get_summary_value(SUMMARY_CURRENT,
value_irq, value_thread, value_user);
if (err)
return err;
- for (i = 0; i < data->nr_cpus; i++) {
+ for (i = 0; i < nr_cpus; i++) {
data->cpu_data[i].cur_irq = value_irq[i];
data->cpu_data[i].cur_thread = value_thread[i];
data->cpu_data[i].cur_user = value_user[i];
@@ -210,7 +207,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
value_irq, value_thread, value_user);
if (err)
return err;
- for (i = 0; i < data->nr_cpus; i++) {
+ for (i = 0; i < nr_cpus; i++) {
data->cpu_data[i].irq_count = value_irq[i];
data->cpu_data[i].thread_count = value_thread[i];
data->cpu_data[i].user_count = value_user[i];
@@ -220,7 +217,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
value_irq, value_thread, value_user);
if (err)
return err;
- for (i = 0; i < data->nr_cpus; i++) {
+ for (i = 0; i < nr_cpus; i++) {
data->cpu_data[i].min_irq = value_irq[i];
data->cpu_data[i].min_thread = value_thread[i];
data->cpu_data[i].min_user = value_user[i];
@@ -230,7 +227,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
value_irq, value_thread, value_user);
if (err)
return err;
- for (i = 0; i < data->nr_cpus; i++) {
+ for (i = 0; i < nr_cpus; i++) {
data->cpu_data[i].max_irq = value_irq[i];
data->cpu_data[i].max_thread = value_thread[i];
data->cpu_data[i].max_user = value_user[i];
@@ -240,7 +237,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
value_irq, value_thread, value_user);
if (err)
return err;
- for (i = 0; i < data->nr_cpus; i++) {
+ for (i = 0; i < nr_cpus; i++) {
data->cpu_data[i].sum_irq = value_irq[i];
data->cpu_data[i].sum_thread = value_thread[i];
data->cpu_data[i].sum_user = value_user[i];
--
2.52.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v1 4/4] tools/rtla: Remove unneeded nr_cpus from for_each_monitored_cpu
2025-12-05 15:19 [PATCH v1 1/4] tools/rtla: Consolidate nr_cpus usage across all tools Costa Shulyupin
2025-12-05 15:19 ` [PATCH v1 2/4] tools/rtla: Remove unneeded nr_cpus arguments Costa Shulyupin
2025-12-05 15:19 ` [PATCH v1 3/4] tools/rtla: Remove unneeded nr_cpus members Costa Shulyupin
@ 2025-12-05 15:19 ` Costa Shulyupin
2025-12-16 14:41 ` [PATCH v1 1/4] tools/rtla: Consolidate nr_cpus usage across all tools Tomas Glozar
3 siblings, 0 replies; 7+ messages in thread
From: Costa Shulyupin @ 2025-12-05 15:19 UTC (permalink / raw)
To: Steven Rostedt, Tomas Glozar, Crystal Wood, Wander Lairson Costa,
Costa Shulyupin, Ivan Pravdin, John Kacur, Tiezhu Yang,
linux-trace-kernel, linux-kernel, bpf
nr_cpus does not change at runtime, so passing it through the macro
argument is unnecessary.
Remove the argument and use the global nr_cpus instead.
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
tools/tracing/rtla/src/common.h | 2 +-
tools/tracing/rtla/src/osnoise_hist.c | 15 +++++++--------
tools/tracing/rtla/src/osnoise_top.c | 2 +-
tools/tracing/rtla/src/timerlat.c | 4 ++--
tools/tracing/rtla/src/timerlat_hist.c | 16 ++++++++--------
tools/tracing/rtla/src/timerlat_top.c | 2 +-
6 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/tools/tracing/rtla/src/common.h b/tools/tracing/rtla/src/common.h
index 2765e2a9f85f..a597e7591e20 100644
--- a/tools/tracing/rtla/src/common.h
+++ b/tools/tracing/rtla/src/common.h
@@ -109,7 +109,7 @@ struct common_params {
extern int nr_cpus;
-#define for_each_monitored_cpu(cpu, nr_cpus, common) \
+#define for_each_monitored_cpu(cpu, common) \
for (cpu = 0; cpu < nr_cpus; cpu++) \
if (!(common)->cpus || CPU_ISSET(cpu, &(common)->monitored_cpus))
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index 7514b29ec559..56bca13b991f 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -245,7 +245,7 @@ static void osnoise_hist_header(struct osnoise_tool *tool)
if (!params->common.hist.no_index)
trace_seq_printf(s, "Index");
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
@@ -274,8 +274,7 @@ osnoise_print_summary(struct osnoise_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "count:");
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
-
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
@@ -286,7 +285,7 @@ osnoise_print_summary(struct osnoise_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "min: ");
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
@@ -299,7 +298,7 @@ osnoise_print_summary(struct osnoise_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "avg: ");
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
@@ -315,7 +314,7 @@ osnoise_print_summary(struct osnoise_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "max: ");
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
@@ -350,7 +349,7 @@ osnoise_print_stats(struct osnoise_tool *tool)
trace_seq_printf(trace->seq, "%-6d",
bucket * data->bucket_size);
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
@@ -386,7 +385,7 @@ osnoise_print_stats(struct osnoise_tool *tool)
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "over: ");
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].count)
continue;
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index e5a13f1bdfb6..0f5b86f11486 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -236,7 +236,7 @@ osnoise_print_stats(struct osnoise_tool *top)
osnoise_top_header(top);
- for_each_monitored_cpu(i, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(i, ¶ms->common) {
osnoise_top_print(top, i);
}
diff --git a/tools/tracing/rtla/src/timerlat.c b/tools/tracing/rtla/src/timerlat.c
index 7503e18b905c..181d72de3197 100644
--- a/tools/tracing/rtla/src/timerlat.c
+++ b/tools/tracing/rtla/src/timerlat.c
@@ -124,7 +124,7 @@ int timerlat_enable(struct osnoise_tool *tool)
return -1;
}
- for_each_monitored_cpu(i, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(i, ¶ms->common) {
if (save_cpu_idle_disable_state(i) < 0) {
err_msg("Could not save cpu idle state.\n");
return -1;
@@ -217,7 +217,7 @@ void timerlat_free(struct osnoise_tool *tool)
if (dma_latency_fd >= 0)
close(dma_latency_fd);
if (params->deepest_idle_state >= -1) {
- for_each_monitored_cpu(i, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(i, ¶ms->common) {
restore_cpu_idle_disable_state(i);
}
}
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index 207359f1cec4..e93476e18ad8 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -298,7 +298,7 @@ static void timerlat_hist_header(struct osnoise_tool *tool)
if (!params->common.hist.no_index)
trace_seq_printf(s, "Index");
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -350,7 +350,7 @@ timerlat_print_summary(struct timerlat_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "count:");
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -372,7 +372,7 @@ timerlat_print_summary(struct timerlat_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "min: ");
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -400,7 +400,7 @@ timerlat_print_summary(struct timerlat_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "avg: ");
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -428,7 +428,7 @@ timerlat_print_summary(struct timerlat_params *params,
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "max: ");
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -473,7 +473,7 @@ timerlat_print_stats_all(struct timerlat_params *params,
sum.min_thread = ~0;
sum.min_user = ~0;
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -620,7 +620,7 @@ timerlat_print_stats(struct osnoise_tool *tool)
trace_seq_printf(trace->seq, "%-6d",
bucket * data->bucket_size);
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
@@ -658,7 +658,7 @@ timerlat_print_stats(struct osnoise_tool *tool)
if (!params->common.hist.no_index)
trace_seq_printf(trace->seq, "over: ");
- for_each_monitored_cpu(cpu, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(cpu, ¶ms->common) {
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
continue;
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 34c8a0010828..c48f02075197 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -447,7 +447,7 @@ timerlat_print_stats(struct osnoise_tool *top)
timerlat_top_header(params, top);
- for_each_monitored_cpu(i, nr_cpus, ¶ms->common) {
+ for_each_monitored_cpu(i, ¶ms->common) {
timerlat_top_print(top, i);
timerlat_top_update_sum(top, i, &summary);
}
--
2.52.0
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v1 1/4] tools/rtla: Consolidate nr_cpus usage across all tools
2025-12-05 15:19 [PATCH v1 1/4] tools/rtla: Consolidate nr_cpus usage across all tools Costa Shulyupin
` (2 preceding siblings ...)
2025-12-05 15:19 ` [PATCH v1 4/4] tools/rtla: Remove unneeded nr_cpus from for_each_monitored_cpu Costa Shulyupin
@ 2025-12-16 14:41 ` Tomas Glozar
2025-12-17 9:06 ` Tomas Glozar
3 siblings, 1 reply; 7+ messages in thread
From: Tomas Glozar @ 2025-12-16 14:41 UTC (permalink / raw)
To: Costa Shulyupin
Cc: Steven Rostedt, Crystal Wood, Wander Lairson Costa, Ivan Pravdin,
John Kacur, Tiezhu Yang, linux-trace-kernel, linux-kernel, bpf
pá 5. 12. 2025 v 16:19 odesílatel Costa Shulyupin
<costa.shul@redhat.com> napsal:
> diff --git a/tools/tracing/rtla/src/timerlat_u.c b/tools/tracing/rtla/src/timerlat_u.c
> index ce68e39d25fd..a569fe7f93aa 100644
> --- a/tools/tracing/rtla/src/timerlat_u.c
> +++ b/tools/tracing/rtla/src/timerlat_u.c
> @@ -16,7 +16,7 @@
> #include <sys/wait.h>
> #include <sys/prctl.h>
>
> -#include "utils.h"
> +#include "common.h"
> #include "timerlat_u.h"
>
Since commit 2f3172f9dd58c ("tools/rtla: Consolidate code between
osnoise/timerlat and hist/top") that was merged into 6.18, common.h
includes timerlat_u.h. Your change thus causes a double include of
timerlat_u.h, leading to a build error:
In file included from src/timerlat_u.c:20:
src/timerlat_u.h:6:8: error: redefinition of ‘struct timerlat_u_params’
6 | struct timerlat_u_params {
| ^~~~~~~~~~~~~~~~~
In file included from src/common.h:5,
from src/timerlat_u.c:19:
src/timerlat_u.h:6:8: note: originally defined here
6 | struct timerlat_u_params {
| ^~~~~~~~~~~~~~~~~
Please rebase your patchset and fix this so that timerlat_u.h is only
included once.
Tomas
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v1 1/4] tools/rtla: Consolidate nr_cpus usage across all tools
2025-12-16 14:41 ` [PATCH v1 1/4] tools/rtla: Consolidate nr_cpus usage across all tools Tomas Glozar
@ 2025-12-17 9:06 ` Tomas Glozar
2026-01-05 22:24 ` Crystal Wood
0 siblings, 1 reply; 7+ messages in thread
From: Tomas Glozar @ 2025-12-17 9:06 UTC (permalink / raw)
To: Costa Shulyupin
Cc: Steven Rostedt, Crystal Wood, Wander Lairson Costa, Ivan Pravdin,
John Kacur, Tiezhu Yang, linux-trace-kernel, linux-kernel, bpf
út 16. 12. 2025 v 15:41 odesílatel Tomas Glozar <tglozar@redhat.com> napsal:
> Since commit 2f3172f9dd58c ("tools/rtla: Consolidate code between
> osnoise/timerlat and hist/top") that was merged into 6.18, common.h
> includes timerlat_u.h. Your change thus causes a double include of
> timerlat_u.h, leading to a build error:
>
> In file included from src/timerlat_u.c:20:
> src/timerlat_u.h:6:8: error: redefinition of ‘struct timerlat_u_params’
> 6 | struct timerlat_u_params {
> | ^~~~~~~~~~~~~~~~~
> In file included from src/common.h:5,
> from src/timerlat_u.c:19:
> src/timerlat_u.h:6:8: note: originally defined here
> 6 | struct timerlat_u_params {
> | ^~~~~~~~~~~~~~~~~
>
> Please rebase your patchset and fix this so that timerlat_u.h is only
> included once.
>
Correction: the base of the patchset has nothing to do with this. It
is the C standard, from C23 (default in GCC 15), redefinition of
structs is allowed [1], so this error doesn't exist. In earlier
standards, this is not allowed.
[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2863.pdf
Tomas
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v1 1/4] tools/rtla: Consolidate nr_cpus usage across all tools
2025-12-17 9:06 ` Tomas Glozar
@ 2026-01-05 22:24 ` Crystal Wood
0 siblings, 0 replies; 7+ messages in thread
From: Crystal Wood @ 2026-01-05 22:24 UTC (permalink / raw)
To: Tomas Glozar, Costa Shulyupin
Cc: Steven Rostedt, Wander Lairson Costa, Ivan Pravdin, John Kacur,
Tiezhu Yang, linux-trace-kernel, linux-kernel, bpf
On Wed, 2025-12-17 at 10:06 +0100, Tomas Glozar wrote:
> út 16. 12. 2025 v 15:41 odesílatel Tomas Glozar <tglozar@redhat.com> napsal:
> > Since commit 2f3172f9dd58c ("tools/rtla: Consolidate code between
> > osnoise/timerlat and hist/top") that was merged into 6.18, common.h
> > includes timerlat_u.h. Your change thus causes a double include of
> > timerlat_u.h, leading to a build error:
> >
> > In file included from src/timerlat_u.c:20:
> > src/timerlat_u.h:6:8: error: redefinition of ‘struct timerlat_u_params’
> > 6 | struct timerlat_u_params {
> > | ^~~~~~~~~~~~~~~~~
> > In file included from src/common.h:5,
> > from src/timerlat_u.c:19:
> > src/timerlat_u.h:6:8: note: originally defined here
> > 6 | struct timerlat_u_params {
> > | ^~~~~~~~~~~~~~~~~
> >
> > Please rebase your patchset and fix this so that timerlat_u.h is only
> > included once.
> >
>
> Correction: the base of the patchset has nothing to do with this. It
> is the C standard, from C23 (default in GCC 15), redefinition of
> structs is allowed [1], so this error doesn't exist. In earlier
> standards, this is not allowed.
>
> [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2863.pdf
Regardless of how permissive the language might be getting in this case,
we should have #pragma once on all of the headers to avoid this sort of
problem.
-Crystal
^ permalink raw reply [flat|nested] 7+ messages in thread