linux/tools/perf
Ian Rogers 8d9f5146f5 perf pmus: Sort pmus by name then suffix
Sort PMUs by name. If two PMUs have the same name but differ by
suffix, sort the suffixes numerically.

For example, "breakpoint" comes before "cpu",
"uncore_imc_free_running_0" comes before "uncore_imc_free_running_1".

Suffixes need to be treated specially as otherwise they will be ordered
like 0, 1, 10, 11, .., 2, 20, 21, .., etc. Only PMUs starting 'uncore_'
are considered to have a potential suffix.

Sorting of PMUs is done so that later patches can skip duplicate uncore
PMUs that differ only by there suffix.

Committer notes:

Used the more compact, intention revealing strstarts() function we got
from the kernel sources:

-       if (strncmp(str, "uncore_", 7))
+       if (!strstarts(str, "uncore_"))

Also in pmus_cmp() the lhs_num and rhs_num variables may end up not
being set for non "uncore_" prefixed PMUs in pmu_name_len_no_suffix(),
or at least gcc 7.5 in some distros (opensuse 15.5, to be EOLed in
Dec/2024) thins so, so initialize both to zero.

Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Link: https://lore.kernel.org/r/20230825135237.921058-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2023-08-29 14:16:14 -03:00
..
arch perf pmu: Remove logic for PMU name being NULL 2023-08-25 10:22:16 -03:00
bench perf pmu: Abstract alias/event struct 2023-08-24 10:42:46 -03:00
dlfilters perf dlfilter: Add al_cleanup() 2023-08-15 16:41:49 -03:00
Documentation perf docs: Fix format of unordered lists 2023-08-16 08:37:49 -03:00
include/perf perf dlfilter: Add al_cleanup() 2023-08-15 16:41:49 -03:00
jvmti
pmu-events perf jevents: Don't append Unit to desc 2023-08-24 19:21:27 -03:00
python
scripts perf scripts python gecko: Launch the profiler UI on the default browser with the appropriate URL 2023-08-24 14:41:49 -03:00
tests perf pmu: Make id const and add missing free 2023-08-25 10:23:34 -03:00
trace perf beauty mmap_flags: Use "test -f" instead of "[-f FILE]" 2023-08-29 14:15:21 -03:00
ui perf tui slang: Tidy casts 2023-08-25 10:24:55 -03:00
util perf pmus: Sort pmus by name then suffix 2023-08-29 14:16:14 -03:00
.gitignore
Build
builtin-annotate.c
builtin-bench.c perf bench uprobe trace_printk: Add entry attaching an BPF program that does a trace_printk 2023-07-20 11:33:24 -03:00
builtin-buildid-cache.c
builtin-buildid-list.c
builtin-c2c.c perf callchain: Use pthread keys for tls callchain_cursor 2023-06-12 15:57:54 -03:00
builtin-config.c
builtin-daemon.c perf tools: Add missing else to cmd_daemon subcommand condition 2023-06-27 12:09:44 -07:00
builtin-data.c
builtin-diff.c perf diff: Replaces some ',' as separator with the more usual ';' 2023-07-20 11:43:45 -03:00
builtin-evlist.c
builtin-ftrace.c
builtin-help.c
builtin-inject.c perf inject: Lazily allocate guest_event event_buf 2023-06-12 18:18:14 -03:00
builtin-kallsyms.c perf symbol: Remove now unused symbol_conf.sort_by_name 2023-06-23 21:48:49 -07:00
builtin-kmem.c perf callchain: Use pthread keys for tls callchain_cursor 2023-06-12 15:57:54 -03:00
builtin-kvm.c
builtin-kwork.c perf callchain: Use pthread keys for tls callchain_cursor 2023-06-12 15:57:54 -03:00
builtin-list.c perf pmu: Remove logic for PMU name being NULL 2023-08-25 10:22:16 -03:00
builtin-lock.c perf lock contention: Fix typo in max-stack option description 2023-08-25 10:27:07 -03:00
builtin-mem.c
builtin-probe.c
builtin-record.c perf parse-events: Remove BPF event support 2023-08-15 16:41:48 -03:00
builtin-report.c perf symbol: Remove now unused symbol_conf.sort_by_name 2023-06-23 21:48:49 -07:00
builtin-sched.c perf sched: Avoid large stack allocations 2023-06-12 18:18:14 -03:00
builtin-script.c perf script: Print "cgroup" field on the same line as "comm" 2023-08-08 11:21:11 -03:00
builtin-stat.c perf stat: Add missing newline in pr_err messages 2023-06-20 15:55:13 -07:00
builtin-timechart.c
builtin-top.c perf top: Don't pass an ERR_PTR() directly to perf_session__delete() 2023-08-17 14:13:04 -03:00
builtin-trace.c perf trace: Use heuristic when deciding if a syscall tracepoint "const char *" field is really a string 2023-08-18 16:33:28 -03:00
builtin-version.c
builtin.h
check-headers.sh perf build: Fix shellcheck issue about quotes for check-headers.sh 2023-08-03 17:01:26 -03:00
command-list.txt
CREDITS
design.txt
Makefile
Makefile.config perf parse-events: Remove BPF event support 2023-08-15 16:41:48 -03:00
Makefile.perf perf build: Allow customization of clang options for BPF target 2023-08-23 15:33:18 -03:00
MANIFEST
perf-archive.sh
perf-completion.sh
perf-iostat.sh
perf-read-vdso.c
perf-sys.h
perf.c perf parse-events: Remove BPF event support 2023-08-15 16:41:48 -03:00
perf.h