diff options
author | Ingo Molnar <mingo@kernel.org> | 2019-08-23 12:29:17 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2019-08-23 12:29:17 +0200 |
commit | 49c46457caadb8c170fd841bd8051e03062d9b8b (patch) | |
tree | e3ee50fdf080ed6fb1c48c835cff27aee85b9e03 /tools | |
parent | 4e92b18e5b0b61211f4511cdbc5803300eeead40 (diff) | |
parent | d9c5c083416500e95da098c01be092b937def7fa (diff) | |
download | linux-next-49c46457caadb8c170fd841bd8051e03062d9b8b.tar.gz |
Merge tag 'perf-core-for-mingo-5.4-20190822' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
perf c2c:
Ravi Bangoria:
- Fix report with offline CPUs.
libperf:
Gerald BAEZA:
- Fix alignment trap with xyarray contents in 'perf stat', noticed on ARMv7.
Jiri Olsa:
- Move some more cpu_map and thread_map methods from tools/perf/util/ to libperf.
headers:
Arnaldo Carvalho de Melo:
- Do some house cleaning on the headers, removing needless includes in some places,
providing forward declarations when those are the only thing needed, and fixing
up the fallout from that for cases where we were using stuff and not adding the
necessary headers. Should speed up the build and avoid needless rebuilds when
something unrelated gets touched.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools')
47 files changed, 155 insertions, 113 deletions
diff --git a/tools/include/linux/ring_buffer.h b/tools/include/linux/ring_buffer.h index 9a083ae60473..6c02617377c2 100644 --- a/tools/include/linux/ring_buffer.h +++ b/tools/include/linux/ring_buffer.h @@ -2,6 +2,7 @@ #define _TOOLS_LINUX_RING_BUFFER_H_ #include <asm/barrier.h> +#include <linux/perf_event.h> /* * Contract with kernel for walking the perf ring buffer from diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 5cb07e8cb296..c73da3245b67 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -396,7 +396,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, * AUX event. We also need the contextID in order to be notified * when a context switch happened. */ - if (!cpu_map__empty(cpus)) { + if (!perf_cpu_map__empty(cpus)) { perf_evsel__set_sample_bit(cs_etm_evsel, CPU); err = cs_etm_set_option(itr, cs_etm_evsel, @@ -420,7 +420,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, tracking_evsel->core.attr.sample_period = 1; /* In per-cpu case, always need the time of mmap events etc */ - if (!cpu_map__empty(cpus)) + if (!perf_cpu_map__empty(cpus)) perf_evsel__set_sample_bit(tracking_evsel, TIME); } @@ -493,7 +493,7 @@ cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused, struct perf_cpu_map *online_cpus = perf_cpu_map__new(NULL); /* cpu map is not empty, we have specific CPUs to work with */ - if (!cpu_map__empty(event_cpus)) { + if (!perf_cpu_map__empty(event_cpus)) { for (i = 0; i < cpu__max_cpu(); i++) { if (!cpu_map__has(event_cpus, i) || !cpu_map__has(online_cpus, i)) @@ -649,11 +649,11 @@ static int cs_etm_info_fill(struct auxtrace_record *itr, return -EINVAL; /* If the cpu_map is empty all online CPUs are involved */ - if (cpu_map__empty(event_cpus)) { + if (perf_cpu_map__empty(event_cpus)) { cpu_map = online_cpus; } else { /* Make sure all specified CPUs are online */ - for (i = 0; i < cpu_map__nr(event_cpus); i++) { + for (i = 0; i < perf_cpu_map__nr(event_cpus); i++) { if (cpu_map__has(event_cpus, i) && !cpu_map__has(online_cpus, i)) return -EINVAL; @@ -662,7 +662,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr, cpu_map = event_cpus; } - nr_cpu = cpu_map__nr(cpu_map); + nr_cpu = perf_cpu_map__nr(cpu_map); /* Get PMU type as dynamically assigned by the core */ type = cs_etm_pmu->type; diff --git a/tools/perf/arch/arm64/util/header.c b/tools/perf/arch/arm64/util/header.c index 602caf550e7f..e41defaaa2e6 100644 --- a/tools/perf/arch/arm64/util/header.c +++ b/tools/perf/arch/arm64/util/header.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <api/fs/fs.h> +#include "debug.h" #include "header.h" #define MIDR "/regs/identification/midr_el1" diff --git a/tools/perf/arch/s390/util/kvm-stat.c b/tools/perf/arch/s390/util/kvm-stat.c index dac78441338c..0fd4e9f49ed0 100644 --- a/tools/perf/arch/s390/util/kvm-stat.c +++ b/tools/perf/arch/s390/util/kvm-stat.c @@ -7,6 +7,7 @@ */ #include <errno.h> +#include <string.h> #include "../../util/kvm-stat.h" #include "../../util/evsel.h" #include <asm/sie.h> diff --git a/tools/perf/arch/x86/util/header.c b/tools/perf/arch/x86/util/header.c index af9a9f2600be..662ecf84a421 100644 --- a/tools/perf/arch/x86/util/header.c +++ b/tools/perf/arch/x86/util/header.c @@ -6,6 +6,7 @@ #include <string.h> #include <regex.h> +#include "../../util/debug.h" #include "../../util/header.h" static inline void diff --git a/tools/perf/arch/x86/util/intel-bts.c b/tools/perf/arch/x86/util/intel-bts.c index 7b23318ebd7b..2d5d8a12dd1f 100644 --- a/tools/perf/arch/x86/util/intel-bts.c +++ b/tools/perf/arch/x86/util/intel-bts.c @@ -133,7 +133,7 @@ static int intel_bts_recording_options(struct auxtrace_record *itr, if (!opts->full_auxtrace) return 0; - if (opts->full_auxtrace && !cpu_map__empty(cpus)) { + if (opts->full_auxtrace && !perf_cpu_map__empty(cpus)) { pr_err(INTEL_BTS_PMU_NAME " does not support per-cpu recording\n"); return -EINVAL; } @@ -214,7 +214,7 @@ static int intel_bts_recording_options(struct auxtrace_record *itr, * In the case of per-cpu mmaps, we need the CPU on the * AUX event. */ - if (!cpu_map__empty(cpus)) + if (!perf_cpu_map__empty(cpus)) perf_evsel__set_sample_bit(intel_bts_evsel, CPU); } diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c index a8e633aa278a..c72a77a82b39 100644 --- a/tools/perf/arch/x86/util/intel-pt.c +++ b/tools/perf/arch/x86/util/intel-pt.c @@ -365,7 +365,7 @@ static int intel_pt_info_fill(struct auxtrace_record *itr, ui__warning("Intel Processor Trace: TSC not available\n"); } - per_cpu_mmaps = !cpu_map__empty(session->evlist->core.cpus); + per_cpu_mmaps = !perf_cpu_map__empty(session->evlist->core.cpus); auxtrace_info->type = PERF_AUXTRACE_INTEL_PT; auxtrace_info->priv[INTEL_PT_PMU_TYPE] = intel_pt_pmu->type; @@ -702,7 +702,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, * Per-cpu recording needs sched_switch events to distinguish different * threads. */ - if (have_timing_info && !cpu_map__empty(cpus)) { + if (have_timing_info && !perf_cpu_map__empty(cpus)) { if (perf_can_record_switch_events()) { bool cpu_wide = !target__none(&opts->target) && !target__has_task(&opts->target); @@ -760,7 +760,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, * In the case of per-cpu mmaps, we need the CPU on the * AUX event. */ - if (!cpu_map__empty(cpus)) + if (!perf_cpu_map__empty(cpus)) perf_evsel__set_sample_bit(intel_pt_evsel, CPU); } @@ -784,7 +784,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, tracking_evsel->immediate = true; /* In per-cpu case, always need the time of mmap events etc */ - if (!cpu_map__empty(cpus)) { + if (!perf_cpu_map__empty(cpus)) { perf_evsel__set_sample_bit(tracking_evsel, TIME); /* And the CPU for switch events */ perf_evsel__set_sample_bit(tracking_evsel, CPU); @@ -796,7 +796,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, * Warn the user when we do not have enough information to decode i.e. * per-cpu with no sched_switch (except workload-only). */ - if (!ptr->have_sched_switch && !cpu_map__empty(cpus) && + if (!ptr->have_sched_switch && !perf_cpu_map__empty(cpus) && !target__none(&opts->target)) ui__warning("Intel Processor Trace decoding will not be possible except for kernel tracing!\n"); diff --git a/tools/perf/arch/x86/util/kvm-stat.c b/tools/perf/arch/x86/util/kvm-stat.c index 81b531a707bf..c0775c39227f 100644 --- a/tools/perf/arch/x86/util/kvm-stat.c +++ b/tools/perf/arch/x86/util/kvm-stat.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include <errno.h> +#include <string.h> #include "../../../util/kvm-stat.h" #include "../../../util/evsel.h" #include <asm/svm.h> diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index f0aae6e13a33..211143720078 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -2027,7 +2027,7 @@ static int setup_nodes(struct perf_session *session) c2c.node_info = 2; c2c.nodes_cnt = session->header.env.nr_numa_nodes; - c2c.cpus_cnt = session->header.env.nr_cpus_online; + c2c.cpus_cnt = session->header.env.nr_cpus_avail; n = session->header.env.numa_nodes; if (!n) @@ -2059,7 +2059,7 @@ static int setup_nodes(struct perf_session *session) nodes[node] = set; /* empty node, skip */ - if (cpu_map__empty(map)) + if (perf_cpu_map__empty(map)) continue; for (cpu = 0; cpu < map->nr; cpu++) { diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 1367bb5046a7..565db782c1b9 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -158,7 +158,7 @@ static int set_tracing_pid(struct perf_ftrace *ftrace) if (target__has_cpu(&ftrace->target)) return 0; - for (i = 0; i < thread_map__nr(ftrace->evlist->core.threads); i++) { + for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) { scnprintf(buf, sizeof(buf), "%d", ftrace->evlist->core.threads->map[i]); if (append_tracing_file("set_ftrace_pid", buf) < 0) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 1764efd16cd4..9b93ddeaeafa 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -3,6 +3,7 @@ #include "perf.h" #include "util/cache.h" +#include "util/counts.h" #include "util/debug.h" #include <subcmd/exec-cmd.h> #include "util/header.h" @@ -1905,7 +1906,7 @@ static struct scripting_ops *scripting_ops; static void __process_stat(struct evsel *counter, u64 tstamp) { - int nthreads = thread_map__nr(counter->core.threads); + int nthreads = perf_thread_map__nr(counter->core.threads); int ncpus = perf_evsel__nr_cpus(counter); int cpu, thread; static int header_printed; @@ -1927,7 +1928,7 @@ static void __process_stat(struct evsel *counter, u64 tstamp) printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n", counter->core.cpus->map[cpu], - thread_map__pid(counter->core.threads, thread), + perf_thread_map__pid(counter->core.threads, thread), counts->val, counts->ena, counts->run, diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index b19df671111e..8a4f1a7d0cba 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -264,7 +264,7 @@ static int read_single_counter(struct evsel *counter, int cpu, */ static int read_counter(struct evsel *counter, struct timespec *rs) { - int nthreads = thread_map__nr(evsel_list->core.threads); + int nthreads = perf_thread_map__nr(evsel_list->core.threads); int ncpus, cpu, thread; if (target__has_cpu(&target) && !target__has_per_thread(&target)) @@ -928,7 +928,7 @@ static int perf_stat_init_aggr_mode(void) * the aggregation translate cpumap. */ nr = cpu_map__get_max(evsel_list->core.cpus); - stat_config.cpus_aggr_map = cpu_map__empty_new(nr + 1); + stat_config.cpus_aggr_map = perf_cpu_map__empty_new(nr + 1); return stat_config.cpus_aggr_map ? 0 : -ENOMEM; } @@ -1493,7 +1493,7 @@ int process_stat_config_event(struct perf_session *session, perf_event__read_stat_config(&stat_config, &event->stat_config); - if (cpu_map__empty(st->cpus)) { + if (perf_cpu_map__empty(st->cpus)) { if (st->aggr_mode != AGGR_UNSET) pr_warning("warning: processing task data, aggregation mode not set\n"); return 0; @@ -1893,7 +1893,7 @@ int cmd_stat(int argc, const char **argv) thread_map__read_comms(evsel_list->core.threads); if (target.system_wide) { if (runtime_stat_new(&stat_config, - thread_map__nr(evsel_list->core.threads))) { + perf_thread_map__nr(evsel_list->core.threads))) { goto out; } } diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index bc44ed29e05a..de126258ca10 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -3188,7 +3188,7 @@ static int trace__set_filter_pids(struct trace *trace) err = bpf_map__set_filter_pids(trace->filter_pids.map, trace->filter_pids.nr, trace->filter_pids.entries); } - } else if (thread_map__pid(trace->evlist->core.threads, 0) == -1) { + } else if (perf_thread_map__pid(trace->evlist->core.threads, 0) == -1) { err = trace__set_filter_loop_pids(trace); } @@ -3417,7 +3417,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv) evlist__enable(evlist); } - trace->multiple_threads = thread_map__pid(evlist->core.threads, 0) == -1 || + trace->multiple_threads = perf_thread_map__pid(evlist->core.threads, 0) == -1 || evlist->core.threads->nr > 1 || perf_evlist__first(evlist)->core.attr.inherit; diff --git a/tools/perf/lib/cpumap.c b/tools/perf/lib/cpumap.c index 1ddb69e796e5..2834753576b2 100644 --- a/tools/perf/lib/cpumap.c +++ b/tools/perf/lib/cpumap.c @@ -237,3 +237,20 @@ int perf_cpu_map__nr(const struct perf_cpu_map *cpus) { return cpus ? cpus->nr : 1; } + +bool perf_cpu_map__empty(const struct perf_cpu_map *map) +{ + return map ? map->map[0] == -1 : true; +} + +int perf_cpu_map__idx(struct perf_cpu_map *cpus, int cpu) +{ + int i; + + for (i = 0; i < cpus->nr; ++i) { + if (cpus->map[i] == cpu) + return i; + } + + return -1; +} diff --git a/tools/perf/lib/include/internal/cpumap.h b/tools/perf/lib/include/internal/cpumap.h index 3306319f7df8..840d4032587b 100644 --- a/tools/perf/lib/include/internal/cpumap.h +++ b/tools/perf/lib/include/internal/cpumap.h @@ -14,4 +14,6 @@ struct perf_cpu_map { #define MAX_NR_CPUS 2048 #endif +int perf_cpu_map__idx(struct perf_cpu_map *cpus, int cpu); + #endif /* __LIBPERF_INTERNAL_CPUMAP_H */ diff --git a/tools/perf/lib/include/internal/xyarray.h b/tools/perf/lib/include/internal/xyarray.h index 3bf70e4d474c..51e35d6c8ec4 100644 --- a/tools/perf/lib/include/internal/xyarray.h +++ b/tools/perf/lib/include/internal/xyarray.h @@ -2,6 +2,7 @@ #ifndef __LIBPERF_INTERNAL_XYARRAY_H #define __LIBPERF_INTERNAL_XYARRAY_H +#include <linux/compiler.h> #include <sys/types.h> struct xyarray { @@ -10,7 +11,7 @@ struct xyarray { size_t entries; size_t max_x; size_t max_y; - char contents[]; + char contents[] __aligned(8); }; struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size); diff --git a/tools/perf/lib/include/perf/cpumap.h b/tools/perf/lib/include/perf/cpumap.h index 1b6e7db3fa2b..8aa995c59498 100644 --- a/tools/perf/lib/include/perf/cpumap.h +++ b/tools/perf/lib/include/perf/cpumap.h @@ -4,6 +4,7 @@ #include <perf/core.h> #include <stdio.h> +#include <stdbool.h> struct perf_cpu_map; @@ -14,6 +15,7 @@ LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map); LIBPERF_API void perf_cpu_map__put(struct perf_cpu_map *map); LIBPERF_API int perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx); LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus); +LIBPERF_API bool perf_cpu_map__empty(const struct perf_cpu_map *map); #define perf_cpu_map__for_each_cpu(cpu, idx, cpus) \ for ((idx) = 0, (cpu) = perf_cpu_map__cpu(cpus, idx); \ diff --git a/tools/perf/lib/include/perf/threadmap.h b/tools/perf/lib/include/perf/threadmap.h index 456295273daa..a7c50de8d010 100644 --- a/tools/perf/lib/include/perf/threadmap.h +++ b/tools/perf/lib/include/perf/threadmap.h @@ -11,6 +11,8 @@ LIBPERF_API struct perf_thread_map *perf_thread_map__new_dummy(void); LIBPERF_API void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid); LIBPERF_API char *perf_thread_map__comm(struct perf_thread_map *map, int thread); +LIBPERF_API int perf_thread_map__nr(struct perf_thread_map *threads); +LIBPERF_API pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread); LIBPERF_API struct perf_thread_map *perf_thread_map__get(struct perf_thread_map *map); LIBPERF_API void perf_thread_map__put(struct perf_thread_map *map); diff --git a/tools/perf/lib/libperf.map b/tools/perf/lib/libperf.map index e24d3cec01c1..dc4d66363bc4 100644 --- a/tools/perf/lib/libperf.map +++ b/tools/perf/lib/libperf.map @@ -8,9 +8,12 @@ LIBPERF_0.0.1 { perf_cpu_map__read; perf_cpu_map__nr; perf_cpu_map__cpu; + perf_cpu_map__empty; perf_thread_map__new_dummy; perf_thread_map__set_pid; perf_thread_map__comm; + perf_thread_map__nr; + perf_thread_map__pid; perf_thread_map__get; perf_thread_map__put; perf_evsel__new; diff --git a/tools/perf/lib/threadmap.c b/tools/perf/lib/threadmap.c index 4865b73e2586..e92c368b0a6c 100644 --- a/tools/perf/lib/threadmap.c +++ b/tools/perf/lib/threadmap.c @@ -79,3 +79,13 @@ void perf_thread_map__put(struct perf_thread_map *map) if (map && refcount_dec_and_test(&map->refcnt)) perf_thread_map__delete(map); } + +int perf_thread_map__nr(struct perf_thread_map *threads) +{ + return threads ? threads->nr : 1; +} + +pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread) +{ + return map->map[thread].pid; +} diff --git a/tools/perf/tests/mem2node.c b/tools/perf/tests/mem2node.c index 5ec193f7968d..73b2855acaf4 100644 --- a/tools/perf/tests/mem2node.c +++ b/tools/perf/tests/mem2node.c @@ -4,6 +4,7 @@ #include <linux/zalloc.h> #include <perf/cpumap.h> #include "cpumap.h" +#include "debug.h" #include "mem2node.h" #include "tests.h" diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c index 8322b6aa4047..4ae4dea07466 100644 --- a/tools/perf/tests/openat-syscall-all-cpus.c +++ b/tools/perf/tests/openat-syscall-all-cpus.c @@ -16,6 +16,7 @@ #include "cpumap.h" #include "debug.h" #include "stat.h" +#include "util/counts.h" int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, int subtest __maybe_unused) { diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c index f217972977e0..58df4bda5e12 100644 --- a/tools/perf/tests/openat-syscall.c +++ b/tools/perf/tests/openat-syscall.c @@ -10,6 +10,7 @@ #include "evsel.h" #include "debug.h" #include "tests.h" +#include "util/counts.h" int test__openat_syscall_event(struct test *test __maybe_unused, int subtest __maybe_unused) { diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c index d61773cacf0b..d803eafedc60 100644 --- a/tools/perf/tests/thread-map.c +++ b/tools/perf/tests/thread-map.c @@ -26,7 +26,7 @@ int test__thread_map(struct test *test __maybe_unused, int subtest __maybe_unuse TEST_ASSERT_VAL("wrong nr", map->nr == 1); TEST_ASSERT_VAL("wrong pid", - thread_map__pid(map, 0) == getpid()); + perf_thread_map__pid(map, 0) == getpid()); TEST_ASSERT_VAL("wrong comm", perf_thread_map__comm(map, 0) && !strcmp(perf_thread_map__comm(map, 0), NAME)); @@ -41,7 +41,7 @@ int test__thread_map(struct test *test __maybe_unused, int subtest __maybe_unuse thread_map__read_comms(map); TEST_ASSERT_VAL("wrong nr", map->nr == 1); - TEST_ASSERT_VAL("wrong pid", thread_map__pid(map, 0) == -1); + TEST_ASSERT_VAL("wrong pid", perf_thread_map__pid(map, 0) == -1); TEST_ASSERT_VAL("wrong comm", perf_thread_map__comm(map, 0) && !strcmp(perf_thread_map__comm(map, 0), "dummy")); @@ -68,7 +68,7 @@ static int process_event(struct perf_tool *tool __maybe_unused, TEST_ASSERT_VAL("wrong nr", threads->nr == 1); TEST_ASSERT_VAL("wrong pid", - thread_map__pid(threads, 0) == getpid()); + perf_thread_map__pid(threads, 0) == getpid()); TEST_ASSERT_VAL("wrong comm", perf_thread_map__comm(threads, 0) && !strcmp(perf_thread_map__comm(threads, 0), NAME)); diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 60428576426e..094e6ceb3cf2 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -132,12 +132,12 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, if (per_cpu) { mp->cpu = evlist->core.cpus->map[idx]; if (evlist->core.threads) - mp->tid = thread_map__pid(evlist->core.threads, 0); + mp->tid = perf_thread_map__pid(evlist->core.threads, 0); else mp->tid = -1; } else { mp->cpu = -1; - mp->tid = thread_map__pid(evlist->core.threads, idx); + mp->tid = perf_thread_map__pid(evlist->core.threads, idx); } } diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 9c219d413e57..e20d7c5e1925 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -26,6 +26,8 @@ #include "llvm-utils.h" #include "c++/clang-c.h" +#include <internal/xyarray.h> + static int libbpf_perf_print(enum libbpf_print_level level __attribute__((unused)), const char *fmt, va_list args) { diff --git a/tools/perf/util/counts.h b/tools/perf/util/counts.h index 13430f353c19..92196df4945f 100644 --- a/tools/perf/util/counts.h +++ b/tools/perf/util/counts.h @@ -2,8 +2,12 @@ #ifndef __PERF_COUNTS_H #define __PERF_COUNTS_H +#include <linux/types.h> #include <internal/xyarray.h> #include <perf/evsel.h> +#include <stdbool.h> + +struct evsel; struct perf_counts { s8 scaled; diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index beb3525e9e45..f5c21184e1fc 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -2,6 +2,8 @@ #include <api/fs/fs.h> #include "../perf.h" #include "cpumap.h" +#include "debug.h" +#include "event.h" #include <assert.h> #include <dirent.h> #include <stdio.h> @@ -21,7 +23,7 @@ static struct perf_cpu_map *cpu_map__from_entries(struct cpu_map_entries *cpus) { struct perf_cpu_map *map; - map = cpu_map__empty_new(cpus->nr); + map = perf_cpu_map__empty_new(cpus->nr); if (map) { unsigned i; @@ -48,7 +50,7 @@ static struct perf_cpu_map *cpu_map__from_mask(struct cpu_map_mask *mask) nr = bitmap_weight(mask->mask, nbits); - map = cpu_map__empty_new(nr); + map = perf_cpu_map__empty_new(nr); if (map) { int cpu, i = 0; @@ -77,7 +79,7 @@ size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp) #undef BUFSIZE } -struct perf_cpu_map *cpu_map__empty_new(int nr) +struct perf_cpu_map *perf_cpu_map__empty_new(int nr) { struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int) * nr); @@ -458,19 +460,7 @@ int cpu__setup_cpunode_map(void) bool cpu_map__has(struct perf_cpu_map *cpus, int cpu) { - return cpu_map__idx(cpus, cpu) != -1; -} - -int cpu_map__idx(struct perf_cpu_map *cpus, int cpu) -{ - int i; - - for (i = 0; i < cpus->nr; ++i) { - if (cpus->map[i] == cpu) - return i; - } - - return -1; + return perf_cpu_map__idx(cpus, cpu) != -1; } int cpu_map__cpu(struct perf_cpu_map *cpus, int idx) diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index a3d27f4131be..d0c5bbfd91af 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h @@ -4,14 +4,14 @@ #include <stdio.h> #include <stdbool.h> -#include <linux/refcount.h> #include <internal/cpumap.h> #include <perf/cpumap.h> #include "perf.h" -#include "util/debug.h" -struct perf_cpu_map *cpu_map__empty_new(int nr); +struct cpu_map_data; + +struct perf_cpu_map *perf_cpu_map__empty_new(int nr); struct perf_cpu_map *cpu_map__new_data(struct cpu_map_data *data); size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size); size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size); @@ -49,16 +49,6 @@ static inline int cpu_map__id_to_cpu(int id) return id & 0xffff; } -static inline int cpu_map__nr(const struct perf_cpu_map *map) -{ - return map ? map->nr : 1; -} - -static inline bool cpu_map__empty(const struct perf_cpu_map *map) -{ - return map ? map->map[0] == -1 : true; -} - int cpu__setup_cpunode_map(void); int cpu__max_node(void); @@ -72,5 +62,4 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct perf_cpu_map **res, int cpu_map__cpu(struct perf_cpu_map *cpus, int idx); bool cpu_map__has(struct perf_cpu_map *cpus, int cpu); -int cpu_map__idx(struct perf_cpu_map *cpus, int cpu); #endif /* __PERF_CPUMAP_H */ diff --git a/tools/perf/util/cputopo.c b/tools/perf/util/cputopo.c index 4f70155eaf83..1b52402a8923 100644 --- a/tools/perf/util/cputopo.c +++ b/tools/perf/util/cputopo.c @@ -3,12 +3,14 @@ #include <sys/utsname.h> #include <inttypes.h> #include <stdlib.h> +#include <string.h> #include <api/fs/fs.h> #include <linux/zalloc.h> #include <perf/cpumap.h> #include "cputopo.h" #include "cpumap.h" +#include "debug.h" #include "env.h" #define CORE_SIB_FMT \ diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index d77912b2b5e7..571efb4f0351 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "cpumap.h" +#include "debug.h" #include "env.h" #include <linux/ctype.h> #include <linux/zalloc.h> diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index f440fdc3e953..332edef8d394 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -647,7 +647,7 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool, for (thread = 0; thread < threads->nr; ++thread) { if (__event__synthesize_thread(comm_event, mmap_event, fork_event, namespaces_event, - thread_map__pid(threads, thread), 0, + perf_thread_map__pid(threads, thread), 0, process, tool, machine, mmap_data)) { err = -1; @@ -658,12 +658,12 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool, * comm.pid is set to thread group id by * perf_event__synthesize_comm */ - if ((int) comm_event->comm.pid != thread_map__pid(threads, thread)) { + if ((int) comm_event->comm.pid != perf_thread_map__pid(threads, thread)) { bool need_leader = true; /* is thread group leader in thread_map? */ for (j = 0; j < threads->nr; ++j) { - if ((int) comm_event->comm.pid == thread_map__pid(threads, j)) { + if ((int) comm_event->comm.pid == perf_thread_map__pid(threads, j)) { need_leader = false; break; } @@ -997,7 +997,7 @@ int perf_event__synthesize_thread_map2(struct perf_tool *tool, if (!comm) comm = (char *) ""; - entry->pid = thread_map__pid(threads, i); + entry->pid = perf_thread_map__pid(threads, i); strncpy((char *) &entry->comm, comm, sizeof(entry->comm)); } @@ -1055,7 +1055,7 @@ static size_t mask_size(struct perf_cpu_map *map, int *max) void *cpu_map_data__alloc(struct perf_cpu_map *map, size_t *size, u16 *type, int *max) { size_t size_cpus, size_mask; - bool is_dummy = cpu_map__empty(map); + bool is_dummy = perf_cpu_map__empty(map); /* * Both array and mask data have variable size based diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index c4489a1ad6bc..ff415680fe0a 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -37,6 +37,8 @@ #include <perf/evsel.h> #include <perf/cpumap.h> +#include <internal/xyarray.h> + #ifdef LACKS_SIGQUEUE_PROTOTYPE int sigqueue(pid_t pid, int sig, const union sigval value); #endif @@ -314,7 +316,7 @@ static int perf_evlist__nr_threads(struct evlist *evlist, if (evsel->system_wide) return 1; else - return thread_map__nr(evlist->core.threads); + return perf_thread_map__nr(evlist->core.threads); } void evlist__disable(struct evlist *evlist) @@ -370,7 +372,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist, int thread) { int cpu; - int nr_cpus = cpu_map__nr(evlist->core.cpus); + int nr_cpus = perf_cpu_map__nr(evlist->core.cpus); if (!evsel->core.fd) return -EINVAL; @@ -386,7 +388,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist, int perf_evlist__enable_event_idx(struct evlist *evlist, struct evsel *evsel, int idx) { - bool per_cpu_mmaps = !cpu_map__empty(evlist->core.cpus); + bool per_cpu_mmaps = !perf_cpu_map__empty(evlist->core.cpus); if (per_cpu_mmaps) return perf_evlist__enable_event_cpu(evlist, evsel, idx); @@ -396,8 +398,8 @@ int perf_evlist__enable_event_idx(struct evlist *evlist, int perf_evlist__alloc_pollfd(struct evlist *evlist) { - int nr_cpus = cpu_map__nr(evlist->core.cpus); - int nr_threads = thread_map__nr(evlist->core.threads); + int nr_cpus = perf_cpu_map__nr(evlist->core.cpus); + int nr_threads = perf_thread_map__nr(evlist->core.threads); int nfds = 0; struct evsel *evsel; @@ -529,7 +531,7 @@ static void perf_evlist__set_sid_idx(struct evlist *evlist, else sid->cpu = -1; if (!evsel->system_wide && evlist->core.threads && thread >= 0) - sid->tid = thread_map__pid(evlist->core.threads, thread); + sid->tid = perf_thread_map__pid(evlist->core.threads, thread); else sid->tid = -1; } @@ -692,9 +694,9 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct evlist *evlist, int i; struct perf_mmap *map; - evlist->nr_mmaps = cpu_map__nr(evlist->core.cpus); - if (cpu_map__empty(evlist->core.cpus)) - evlist->nr_mmaps = thread_map__nr(evlist->core.threads); + evlist->nr_mmaps = perf_cpu_map__nr(evlist->core.cpus); + if (perf_cpu_map__empty(evlist->core.cpus)) + evlist->nr_mmaps = perf_thread_map__nr(evlist->core.threads); map = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap)); if (!map) return NULL; @@ -758,7 +760,7 @@ static int perf_evlist__mmap_per_evsel(struct evlist *evlist, int idx, if (evsel->system_wide && thread) continue; - cpu = cpu_map__idx(evsel->core.cpus, evlist_cpu); + cpu = perf_cpu_map__idx(evsel->core.cpus, evlist_cpu); if (cpu == -1) continue; @@ -807,8 +809,8 @@ static int perf_evlist__mmap_per_cpu(struct evlist *evlist, struct mmap_params *mp) { int cpu, thread; - int nr_cpus = cpu_map__nr(evlist->core.cpus); - int nr_threads = thread_map__nr(evlist->core.threads); + int nr_cpus = perf_cpu_map__nr(evlist->core.cpus); + int nr_threads = perf_thread_map__nr(evlist->core.threads); pr_debug2("perf event ring buffer mmapped per cpu\n"); for (cpu = 0; cpu < nr_cpus; cpu++) { @@ -836,7 +838,7 @@ static int perf_evlist__mmap_per_thread(struct evlist *evlist, struct mmap_params *mp) { int thread; - int nr_threads = thread_map__nr(evlist->core.threads); + int nr_threads = perf_thread_map__nr(evlist->core.threads); pr_debug2("perf event ring buffer mmapped per thread\n"); for (thread = 0; thread < nr_threads; thread++) { @@ -1014,11 +1016,11 @@ int perf_evlist__mmap_ex(struct evlist *evlist, unsigned int pages, evlist__for_each_entry(evlist, evsel) { if ((evsel->core.attr.read_format & PERF_FORMAT_ID) && evsel->sample_id == NULL && - perf_evsel__alloc_id(evsel, cpu_map__nr(cpus), threads->nr) < 0) + perf_evsel__alloc_id(evsel, perf_cpu_map__nr(cpus), threads->nr) < 0) return -ENOMEM; } - if (cpu_map__empty(cpus)) + if (perf_cpu_map__empty(cpus)) return perf_evlist__mmap_per_thread(evlist, &mp); return perf_evlist__mmap_per_cpu(evlist, &mp); diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 0a33f7322ecc..e983e721beca 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -26,6 +26,7 @@ #include "asm/bug.h" #include "callchain.h" #include "cgroup.h" +#include "counts.h" #include "event.h" #include "evsel.h" #include "evlist.h" @@ -39,6 +40,7 @@ #include "string2.h" #include "memswap.h" #include "util/parse-branch-options.h" +#include <internal/xyarray.h> #include <linux/ctype.h> @@ -1651,7 +1653,7 @@ static bool ignore_missing_thread(struct evsel *evsel, struct perf_thread_map *threads, int thread, int err) { - pid_t ignore_pid = thread_map__pid(threads, thread); + pid_t ignore_pid = perf_thread_map__pid(threads, thread); if (!evsel->ignore_missing_thread) return false; @@ -1814,7 +1816,7 @@ retry_sample_id: int fd, group_fd; if (!evsel->cgrp && !evsel->system_wide) - pid = thread_map__pid(threads, thread); + pid = perf_thread_map__pid(threads, thread); group_fd = get_group_fd(evsel, cpu, thread); retry_open: diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index efe08065838f..5a351cae66df 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -4,16 +4,18 @@ #include <linux/list.h> #include <stdbool.h> -#include <stddef.h> +#include <stdio.h> +#include <sys/types.h> #include <linux/perf_event.h> #include <linux/types.h> #include <internal/evsel.h> -#include <internal/xyarray.h> +#include <perf/evsel.h> #include "symbol_conf.h" -#include "cpumap.h" -#include "counts.h" +#include <internal/cpumap.h> +struct addr_location; struct evsel; +union perf_event; /* * Per fd, to map back from PERF_SAMPLE_ID to evsel, only used when there are @@ -93,6 +95,8 @@ enum perf_tool_event { }; struct bpf_object; +struct perf_counts; +struct xyarray; /** struct evsel - event selector * diff --git a/tools/perf/util/mem2node.c b/tools/perf/util/mem2node.c index cacc2fc4dcbd..14fb9e72aeeb 100644 --- a/tools/perf/util/mem2node.c +++ b/tools/perf/util/mem2node.c @@ -2,6 +2,7 @@ #include <inttypes.h> #include <linux/bitmap.h> #include <linux/zalloc.h> +#include "debug.h" #include "mem2node.h" struct phys_entry { diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index fdb0d1c5c5cf..aaf55444f81b 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -7,18 +7,19 @@ #include "metricgroup.h" #include "evlist.h" +#include "evsel.h" #include "strbuf.h" #include "pmu.h" #include "expr.h" #include "rblist.h" #include <string.h> -#include <stdbool.h> #include <errno.h> #include "pmu-events/pmu-events.h" #include "strlist.h" #include <assert.h> #include <linux/ctype.h> #include <linux/zalloc.h> +#include <subcmd/parse-options.h> struct metric_event *metricgroup__lookup(struct rblist *metric_events, struct evsel *evsel, diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.h index 500e828533f8..e5092f6404ae 100644 --- a/tools/perf/util/metricgroup.h +++ b/tools/perf/util/metricgroup.h @@ -1,11 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0-only #ifndef METRICGROUP_H #define METRICGROUP_H 1 -#include "linux/list.h" -#include "rblist.h" -#include <subcmd/parse-options.h> -#include "evlist.h" -#include "strbuf.h" +#include <linux/list.h> +#include <linux/rbtree.h> +#include <stdbool.h> + +struct evsel; +struct option; +struct rblist; struct metric_event { struct rb_node nd; diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index 42a5971146ae..5f3532e51ec9 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -331,7 +331,7 @@ static void build_node_mask(int node, cpu_set_t *mask) if (!cpu_map) return; - nr_cpus = cpu_map__nr(cpu_map); + nr_cpus = perf_cpu_map__nr(cpu_map); for (c = 0; c < nr_cpus; c++) { cpu = cpu_map->map[c]; /* map c index to online cpu index */ if (cpu__get_node(cpu) == node) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index b7da21a7d627..9807be6f09bb 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -16,6 +16,7 @@ #include <locale.h> #include <regex.h> #include <perf/cpumap.h> +#include "debug.h" #include "pmu.h" #include "parse-events.h" #include "cpumap.h" diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index e59382d99196..51bbd0714e6d 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c @@ -275,7 +275,7 @@ bool perf_evlist__can_select_event(struct evlist *evlist, const char *str) evsel = perf_evlist__last(temp_evlist); - if (!evlist || cpu_map__empty(evlist->core.cpus)) { + if (!evlist || perf_cpu_map__empty(evlist->core.cpus)) { struct perf_cpu_map *cpus = perf_cpu_map__new(NULL); cpu = cpus ? cpus->map[0] : 0; diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index 32c17a727450..78c8bc9380bd 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -32,6 +32,7 @@ #include <linux/time64.h> #include "../../perf.h" +#include "../counts.h" #include "../debug.h" #include "../callchain.h" #include "../evsel.h" @@ -1405,7 +1406,7 @@ static void python_process_stat(struct perf_stat_config *config, for (thread = 0; thread < threads->nr; thread++) { for (cpu = 0; cpu < cpus->nr; cpu++) { process_stat(counter, cpus->map[cpu], - thread_map__pid(threads, thread), tstamp, + perf_thread_map__pid(threads, thread), tstamp, perf_counts(counter->counts, cpu, thread)); } } diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index f7b39f4bc51e..51d6781aa90d 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -4,6 +4,7 @@ #include <linux/time64.h> #include <math.h> #include "color.h" +#include "counts.h" #include "evlist.h" #include "evsel.h" #include "stat.h" @@ -118,7 +119,7 @@ static void aggr_printout(struct perf_stat_config *config, config->csv_output ? 0 : 16, perf_thread_map__comm(evsel->core.threads, id), config->csv_output ? 0 : -8, - thread_map__pid(evsel->core.threads, id), + perf_thread_map__pid(evsel->core.threads, id), config->csv_sep); break; case AGGR_GLOBAL: @@ -744,8 +745,8 @@ static void print_aggr_thread(struct perf_stat_config *config, struct evsel *counter, char *prefix) { FILE *output = config->output; - int nthreads = thread_map__nr(counter->core.threads); - int ncpus = cpu_map__nr(counter->core.cpus); + int nthreads = perf_thread_map__nr(counter->core.threads); + int ncpus = perf_cpu_map__nr(counter->core.cpus); int thread, sorted_threads, id; struct perf_aggr_thread_value *buf; diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index e4e4e3bf8b2b..0cbfd1eca1dd 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -2,6 +2,7 @@ #include <errno.h> #include <inttypes.h> #include <math.h> +#include "counts.h" #include "stat.h" #include "evlist.h" #include "evsel.h" @@ -158,7 +159,7 @@ static void perf_evsel__free_prev_raw_counts(struct evsel *evsel) static int perf_evsel__alloc_stats(struct evsel *evsel, bool alloc_raw) { int ncpus = perf_evsel__nr_cpus(evsel); - int nthreads = thread_map__nr(evsel->core.threads); + int nthreads = perf_thread_map__nr(evsel->core.threads); if (perf_evsel__alloc_stat_priv(evsel) < 0 || perf_evsel__alloc_counts(evsel, ncpus, nthreads) < 0 || @@ -223,7 +224,7 @@ static int check_per_pkg(struct evsel *counter, if (!counter->per_pkg) return 0; - if (cpu_map__empty(cpus)) + if (perf_cpu_map__empty(cpus)) return 0; if (!mask) { @@ -308,7 +309,7 @@ process_counter_values(struct perf_stat_config *config, struct evsel *evsel, static int process_counter_maps(struct perf_stat_config *config, struct evsel *counter) { - int nthreads = thread_map__nr(counter->core.threads); + int nthreads = perf_thread_map__nr(counter->core.threads); int ncpus = perf_evsel__nr_cpus(counter); int cpu, thread; diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c index ae6a534a7a80..bbdd87163285 100644 --- a/tools/perf/util/svghelper.c +++ b/tools/perf/util/svghelper.c @@ -14,6 +14,7 @@ #include <unistd.h> #include <string.h> #include <linux/bitmap.h> +#include <linux/string.h> #include <linux/time64.h> #include <linux/zalloc.h> #include <perf/cpumap.h> diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c index c58385ea05be..3e64525bf604 100644 --- a/tools/perf/util/thread_map.c +++ b/tools/perf/util/thread_map.c @@ -310,7 +310,7 @@ size_t thread_map__fprintf(struct perf_thread_map *threads, FILE *fp) size_t printed = fprintf(fp, "%d thread%s: ", threads->nr, threads->nr > 1 ? "s" : ""); for (i = 0; i < threads->nr; ++i) - printed += fprintf(fp, "%s%d", i ? ", " : "", thread_map__pid(threads, i)); + printed += fprintf(fp, "%s%d", i ? ", " : "", perf_thread_map__pid(threads, i)); return printed + fprintf(fp, "\n"); } @@ -341,7 +341,7 @@ static int get_comm(char **comm, pid_t pid) static void comm_init(struct perf_thread_map *map, int i) { - pid_t pid = thread_map__pid(map, i); + pid_t pid = perf_thread_map__pid(map, i); char *comm = NULL; /* dummy pid comm initialization */ diff --git a/tools/perf/util/thread_map.h b/tools/perf/util/thread_map.h index ba45c760be72..ca165fdf6cb0 100644 --- a/tools/perf/util/thread_map.h +++ b/tools/perf/util/thread_map.h @@ -25,16 +25,6 @@ struct perf_thread_map *thread_map__new_by_tid_str(const char *tid_str); size_t thread_map__fprintf(struct perf_thread_map *threads, FILE *fp); -static inline int thread_map__nr(struct perf_thread_map *threads) -{ - return threads ? threads->nr : 1; -} - -static inline pid_t thread_map__pid(struct perf_thread_map *map, int thread) -{ - return map->map[thread].pid; -} - void thread_map__read_comms(struct perf_thread_map *threads); bool thread_map__has(struct perf_thread_map *threads, pid_t pid); int thread_map__remove(struct perf_thread_map *threads, int idx); |