Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf evsel: Constify a few arrays

Remove public definition of evsel__tool_names(). Not used outside
util/evsel.c.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Florian Fischer <florian.fischer@muhq.space>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.garry@huawei.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Cc: Shunsuke Nakamura <nakamura.shun@fujitsu.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20220507053410.3798748-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
545a96c9 17b3867d

+14 -15
+1 -1
tools/perf/tests/evsel-roundtrip-name.c
··· 64 64 return ret; 65 65 } 66 66 67 - static int __perf_evsel__name_array_test(const char *names[], int nr_names, 67 + static int __perf_evsel__name_array_test(const char *const names[], int nr_names, 68 68 int distance) 69 69 { 70 70 int i, err;
+7 -7
tools/perf/util/evsel.c
··· 486 486 return ERR_PTR(err); 487 487 } 488 488 489 - const char *evsel__hw_names[PERF_COUNT_HW_MAX] = { 489 + const char *const evsel__hw_names[PERF_COUNT_HW_MAX] = { 490 490 "cycles", 491 491 "instructions", 492 492 "cache-references", ··· 571 571 return r + evsel__add_modifiers(evsel, bf + r, size - r); 572 572 } 573 573 574 - const char *evsel__sw_names[PERF_COUNT_SW_MAX] = { 574 + const char *const evsel__sw_names[PERF_COUNT_SW_MAX] = { 575 575 "cpu-clock", 576 576 "task-clock", 577 577 "page-faults", ··· 597 597 return r + evsel__add_modifiers(evsel, bf + r, size - r); 598 598 } 599 599 600 - const char *evsel__tool_names[PERF_TOOL_MAX] = { 600 + static const char *const evsel__tool_names[PERF_TOOL_MAX] = { 601 601 "duration_time", 602 602 "user_time", 603 603 "system_time", ··· 633 633 return r + evsel__add_modifiers(evsel, bf + r, size - r); 634 634 } 635 635 636 - const char *evsel__hw_cache[PERF_COUNT_HW_CACHE_MAX][EVSEL__MAX_ALIASES] = { 636 + const char *const evsel__hw_cache[PERF_COUNT_HW_CACHE_MAX][EVSEL__MAX_ALIASES] = { 637 637 { "L1-dcache", "l1-d", "l1d", "L1-data", }, 638 638 { "L1-icache", "l1-i", "l1i", "L1-instruction", }, 639 639 { "LLC", "L2", }, ··· 643 643 { "node", }, 644 644 }; 645 645 646 - const char *evsel__hw_cache_op[PERF_COUNT_HW_CACHE_OP_MAX][EVSEL__MAX_ALIASES] = { 646 + const char *const evsel__hw_cache_op[PERF_COUNT_HW_CACHE_OP_MAX][EVSEL__MAX_ALIASES] = { 647 647 { "load", "loads", "read", }, 648 648 { "store", "stores", "write", }, 649 649 { "prefetch", "prefetches", "speculative-read", "speculative-load", }, 650 650 }; 651 651 652 - const char *evsel__hw_cache_result[PERF_COUNT_HW_CACHE_RESULT_MAX][EVSEL__MAX_ALIASES] = { 652 + const char *const evsel__hw_cache_result[PERF_COUNT_HW_CACHE_RESULT_MAX][EVSEL__MAX_ALIASES] = { 653 653 { "refs", "Reference", "ops", "access", }, 654 654 { "misses", "miss", }, 655 655 }; ··· 665 665 * L1I : Read and prefetch only 666 666 * ITLB and BPU : Read-only 667 667 */ 668 - static unsigned long evsel__hw_cache_stat[C(MAX)] = { 668 + static const unsigned long evsel__hw_cache_stat[C(MAX)] = { 669 669 [C(L1D)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH), 670 670 [C(L1I)] = (CACHE_READ | CACHE_PREFETCH), 671 671 [C(LL)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
+5 -6
tools/perf/util/evsel.h
··· 257 257 258 258 #define EVSEL__MAX_ALIASES 8 259 259 260 - extern const char *evsel__hw_cache[PERF_COUNT_HW_CACHE_MAX][EVSEL__MAX_ALIASES]; 261 - extern const char *evsel__hw_cache_op[PERF_COUNT_HW_CACHE_OP_MAX][EVSEL__MAX_ALIASES]; 262 - extern const char *evsel__hw_cache_result[PERF_COUNT_HW_CACHE_RESULT_MAX][EVSEL__MAX_ALIASES]; 263 - extern const char *evsel__hw_names[PERF_COUNT_HW_MAX]; 264 - extern const char *evsel__sw_names[PERF_COUNT_SW_MAX]; 265 - extern const char *evsel__tool_names[PERF_TOOL_MAX]; 260 + extern const char *const evsel__hw_cache[PERF_COUNT_HW_CACHE_MAX][EVSEL__MAX_ALIASES]; 261 + extern const char *const evsel__hw_cache_op[PERF_COUNT_HW_CACHE_OP_MAX][EVSEL__MAX_ALIASES]; 262 + extern const char *const evsel__hw_cache_result[PERF_COUNT_HW_CACHE_RESULT_MAX][EVSEL__MAX_ALIASES]; 263 + extern const char *const evsel__hw_names[PERF_COUNT_HW_MAX]; 264 + extern const char *const evsel__sw_names[PERF_COUNT_SW_MAX]; 266 265 extern char *evsel__bpf_counter_events; 267 266 bool evsel__match_bpf_counter_events(const char *name); 268 267
+1 -1
tools/perf/util/parse-events.c
··· 426 426 return 0; 427 427 } 428 428 429 - static int parse_aliases(char *str, const char *names[][EVSEL__MAX_ALIASES], int size) 429 + static int parse_aliases(char *str, const char *const names[][EVSEL__MAX_ALIASES], int size) 430 430 { 431 431 int i, j; 432 432 int n, longest = -1;