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

perf thread_map: Reduce exposure of libperf internal API

Remove unnecessary include of internal threadmap.h and refcount.h in
thread_map.h. Switch to using public APIs when possible or including
the internal header file in the C file. Fix a transitive dependency in
openat-syscall.c broken by the clean up.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Nicolas Schier <nicolas@fjasle.eu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221109184914.1357295-13-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
fd3f518f bd560973

+12 -9
+1
tools/perf/builtin-stat.c
··· 93 93 94 94 #include <linux/ctype.h> 95 95 #include <perf/evlist.h> 96 + #include <internal/threadmap.h> 96 97 97 98 #define DEFAULT_SEPARATOR " " 98 99 #define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi"
+2 -2
tools/perf/builtin-trace.c
··· 4095 4095 } 4096 4096 4097 4097 trace->multiple_threads = perf_thread_map__pid(evlist->core.threads, 0) == -1 || 4098 - evlist->core.threads->nr > 1 || 4099 - evlist__first(evlist)->core.attr.inherit; 4098 + perf_thread_map__nr(evlist->core.threads) > 1 || 4099 + evlist__first(evlist)->core.attr.inherit; 4100 4100 4101 4101 /* 4102 4102 * Now that we already used evsel->core.attr to ask the kernel to setup the
+1
tools/perf/tests/openat-syscall.c
··· 7 7 #include <sys/types.h> 8 8 #include <sys/stat.h> 9 9 #include <fcntl.h> 10 + #include <unistd.h> 10 11 #include "thread_map.h" 11 12 #include "evsel.h" 12 13 #include "debug.h"
+1
tools/perf/tests/thread-map.c
··· 11 11 #include "util/synthetic-events.h" 12 12 #include <linux/zalloc.h> 13 13 #include <perf/event.h> 14 + #include <internal/threadmap.h> 14 15 15 16 struct perf_sample; 16 17 struct perf_tool;
+1 -1
tools/perf/util/bpf_counter.c
··· 561 561 562 562 if (filter_type == BPERF_FILTER_PID || 563 563 filter_type == BPERF_FILTER_TGID) 564 - key = evsel->core.threads->map[i].pid; 564 + key = perf_thread_map__pid(evsel->core.threads, i); 565 565 else if (filter_type == BPERF_FILTER_CPU) 566 566 key = evsel->core.cpus->map[i].cpu; 567 567 else
+1
tools/perf/util/evsel.c
··· 53 53 #include "util/parse-branch-options.h" 54 54 #include <internal/xyarray.h> 55 55 #include <internal/lib.h> 56 + #include <internal/threadmap.h> 56 57 57 58 #include <linux/ctype.h> 58 59
+3 -3
tools/perf/util/python.c
··· 718 718 { 719 719 struct pyrf_thread_map *pthreads = (void *)obj; 720 720 721 - return pthreads->threads->nr; 721 + return perf_thread_map__nr(pthreads->threads); 722 722 } 723 723 724 724 static PyObject *pyrf_thread_map__item(PyObject *obj, Py_ssize_t i) 725 725 { 726 726 struct pyrf_thread_map *pthreads = (void *)obj; 727 727 728 - if (i >= pthreads->threads->nr) 728 + if (i >= perf_thread_map__nr(pthreads->threads)) 729 729 return NULL; 730 730 731 - return Py_BuildValue("i", pthreads->threads->map[i]); 731 + return Py_BuildValue("i", perf_thread_map__pid(pthreads->threads, i)); 732 732 } 733 733 734 734 static PySequenceMethods pyrf_thread_map__sequence_methods = {
+1 -1
tools/perf/util/scripting-engines/trace-event-python.c
··· 1654 1654 struct perf_cpu_map *cpus = counter->core.cpus; 1655 1655 int cpu, thread; 1656 1656 1657 - for (thread = 0; thread < threads->nr; thread++) { 1657 + for (thread = 0; thread < perf_thread_map__nr(threads); thread++) { 1658 1658 for (cpu = 0; cpu < perf_cpu_map__nr(cpus); cpu++) { 1659 1659 process_stat(counter, perf_cpu_map__cpu(cpus, cpu), 1660 1660 perf_thread_map__pid(threads, thread), tstamp,
+1
tools/perf/util/thread_map.c
··· 18 18 #include "thread_map.h" 19 19 #include "debug.h" 20 20 #include "event.h" 21 + #include <internal/threadmap.h> 21 22 22 23 /* Skip "." and ".." directories */ 23 24 static int filter(const struct dirent *dir)
-2
tools/perf/util/thread_map.h
··· 4 4 5 5 #include <sys/types.h> 6 6 #include <stdio.h> 7 - #include <linux/refcount.h> 8 - #include <internal/threadmap.h> 9 7 #include <perf/threadmap.h> 10 8 11 9 struct perf_record_thread_map;