Re: [PATCH v2 03/21] perf pmu: Make pmu_sys_event_tables const.

From: kajoljain
Date: Tue Oct 26 2021 - 01:26:56 EST




On 10/15/21 10:51 PM, Ian Rogers wrote:
> Make lookup nature of data structures clearer through their type.
>
> Acked-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> tools/perf/pmu-events/jevents.c | 2 +-
> tools/perf/pmu-events/pmu-events.h | 2 +-
> tools/perf/tests/pmu-events.c | 2 +-
> tools/perf/util/pmu.c | 2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)

Patch looks good to me.

Reviewed-by: Kajol Jain<kjain@xxxxxxxxxxxxx>

Thanks,
Kajol Jain

>
> diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
> index 5624a37d6f93..a31de0f77097 100644
> --- a/tools/perf/pmu-events/jevents.c
> +++ b/tools/perf/pmu-events/jevents.c
> @@ -832,7 +832,7 @@ static void print_mapping_test_table(FILE *outfp)
>
> static void print_system_event_mapping_table_prefix(FILE *outfp)
> {
> - fprintf(outfp, "\nstruct pmu_sys_events pmu_sys_event_tables[] = {");
> + fprintf(outfp, "\nconst struct pmu_sys_events pmu_sys_event_tables[] = {");
> }
>
> static void print_system_event_mapping_table_suffix(FILE *outfp)
> diff --git a/tools/perf/pmu-events/pmu-events.h b/tools/perf/pmu-events/pmu-events.h
> index 42c6db6bedec..f6c9c9fc4ab2 100644
> --- a/tools/perf/pmu-events/pmu-events.h
> +++ b/tools/perf/pmu-events/pmu-events.h
> @@ -54,6 +54,6 @@ struct pmu_sys_events {
> * table of PMU events.
> */
> extern const struct pmu_events_map pmu_events_map[];
> -extern struct pmu_sys_events pmu_sys_event_tables[];
> +extern const struct pmu_sys_events pmu_sys_event_tables[];
>
> #endif
> diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
> index 8a1fdcd072f5..c0f8b61871c8 100644
> --- a/tools/perf/tests/pmu-events.c
> +++ b/tools/perf/tests/pmu-events.c
> @@ -258,7 +258,7 @@ static const struct pmu_events_map *__test_pmu_get_events_map(void)
>
> static struct pmu_event *__test_pmu_get_sys_events_table(void)
> {
> - struct pmu_sys_events *tables = &pmu_sys_event_tables[0];
> + const struct pmu_sys_events *tables = &pmu_sys_event_tables[0];
>
> for ( ; tables->name; tables++) {
> if (!strcmp("pme_test_soc_sys", tables->name))
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 4bcdc595ce5e..c04a89cc7cef 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -873,7 +873,7 @@ void pmu_for_each_sys_event(pmu_sys_event_iter_fn fn, void *data)
> int i = 0;
>
> while (1) {
> - struct pmu_sys_events *event_table;
> + const struct pmu_sys_events *event_table;
> int j = 0;
>
> event_table = &pmu_sys_event_tables[i++];
>