From 67260e8c0e681a9bb9ed861514b4c80c2d0eb2e5 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Tue, 20 Aug 2019 16:02:19 +0200 Subject: [PATCH 01/47] perf c2c: Display proper cpu count in nodes column There's wrong bitmap considered when checking for cpu count of specific node. We do the needed computation for 'set' variable, but at the end we use the 'c2c_he->cpuset' weight, which shows misleading numbers. Fixes: 1e181b92a2da ("perf c2c report: Add 'node' sort key") Reported-by: Joe Mario Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20190820140219.28338-1-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-c2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 73782d99ee5a..8335a4076a5a 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -1107,7 +1107,7 @@ node_entry(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp *hpp, break; case 1: { - int num = bitmap_weight(c2c_he->cpuset, c2c.cpus_cnt); + int num = bitmap_weight(set, c2c.cpus_cnt); struct c2c_stats *stats = &c2c_he->node_stats[node]; ret = scnprintf(hpp->buf, hpp->size, "%2d{%2d ", node, num); From 0ac1dd5b4a70cfc8591dd9426f800b484765badb Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 27 Aug 2019 16:43:46 -0500 Subject: [PATCH 02/47] perf timechart: Refactor svg_build_topology_map() Exchange the parameters of svg_build_topology_map() with 'struct perf_env *env' and adjust the function accordingly. This patch should not change any behavior, it is merely refactoring for the following patch. Committer notes: No need to include env.h from svghelper.h, all it needs is a forward declaration for 'struct perf_env', so move the include directive to svghelper.c, where it is really needed. Signed-off-by: Kyle Meyer Reviewed-by: Jiri Olsa Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Russ Anderson Link: http://lore.kernel.org/lkml/20190827214352.94272-2-meyerk@stormcage.eag.rdlabs.hpecorp.net Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-timechart.c | 5 +---- tools/perf/util/svghelper.c | 20 ++++++++++++-------- tools/perf/util/svghelper.h | 4 +++- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 7d6a6ecf4e02..1ff81a790931 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -1518,10 +1518,7 @@ static int process_header(struct perf_file_section *section __maybe_unused, if (!tchart->topology) break; - if (svg_build_topology_map(ph->env.sibling_cores, - ph->env.nr_sibling_cores, - ph->env.sibling_threads, - ph->env.nr_sibling_threads)) + if (svg_build_topology_map(&ph->env)) fprintf(stderr, "problem building topology\n"); break; diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c index bbdd87163285..2e9971590590 100644 --- a/tools/perf/util/svghelper.c +++ b/tools/perf/util/svghelper.c @@ -19,6 +19,7 @@ #include #include +#include "env.h" #include "perf.h" #include "svghelper.h" #include "cpumap.h" @@ -752,23 +753,26 @@ static int str_to_bitmap(char *s, cpumask_t *b) return ret; } -int svg_build_topology_map(char *sib_core, int sib_core_nr, - char *sib_thr, int sib_thr_nr) +int svg_build_topology_map(struct perf_env *env) { int i; struct topology t; + char *sib_core, *sib_thr; - t.sib_core_nr = sib_core_nr; - t.sib_thr_nr = sib_thr_nr; - t.sib_core = calloc(sib_core_nr, sizeof(cpumask_t)); - t.sib_thr = calloc(sib_thr_nr, sizeof(cpumask_t)); + t.sib_core_nr = env->nr_sibling_cores; + t.sib_thr_nr = env->nr_sibling_threads; + t.sib_core = calloc(env->nr_sibling_cores, sizeof(cpumask_t)); + t.sib_thr = calloc(env->nr_sibling_threads, sizeof(cpumask_t)); + + sib_core = env->sibling_cores; + sib_thr = env->sibling_threads; if (!t.sib_core || !t.sib_thr) { fprintf(stderr, "topology: no memory\n"); goto exit; } - for (i = 0; i < sib_core_nr; i++) { + for (i = 0; i < env->nr_sibling_cores; i++) { if (str_to_bitmap(sib_core, &t.sib_core[i])) { fprintf(stderr, "topology: can't parse siblings map\n"); goto exit; @@ -777,7 +781,7 @@ int svg_build_topology_map(char *sib_core, int sib_core_nr, sib_core += strlen(sib_core) + 1; } - for (i = 0; i < sib_thr_nr; i++) { + for (i = 0; i < env->nr_sibling_threads; i++) { if (str_to_bitmap(sib_thr, &t.sib_thr[i])) { fprintf(stderr, "topology: can't parse siblings map\n"); goto exit; diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h index e55338d5c3bd..81823e8bae3e 100644 --- a/tools/perf/util/svghelper.h +++ b/tools/perf/util/svghelper.h @@ -4,6 +4,8 @@ #include +struct perf_env; + void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end); void svg_ubox(int Yslot, u64 start, u64 end, double height, const char *type, int fd, int err, int merges); void svg_lbox(int Yslot, u64 start, u64 end, double height, const char *type, int fd, int err, int merges); @@ -28,7 +30,7 @@ void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc void svg_interrupt(u64 start, int row, const char *backtrace); void svg_text(int Yslot, u64 start, const char *text); void svg_close(void); -int svg_build_topology_map(char *sib_core, int sib_core_nr, char *sib_thr, int sib_thr_nr); +int svg_build_topology_map(struct perf_env *env); extern int svg_page_width; extern u64 svg_highlight; From f78f96676a256d7fa171a54b271a2ad2c6555c9c Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 27 Aug 2019 16:43:47 -0500 Subject: [PATCH 03/47] perf svghelper: Replace MAX_NR_CPUS with perf_env::nr_cpus_online 'nr_cpus', the number of CPUs online during a record session bound by MAX_NR_CPUS, can be used as a dynamic alternative for MAX_NR_CPUS in svg_build_topology_map(). The value of nr_cpus can be passed into str_to_bitmap(), scan_core_topology(), and svg_build_topology_map() to replace MAX_NR_CPUS as well. Signed-off-by: Kyle Meyer Reviewed-by: Jiri Olsa Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Russ Anderson Link: http://lore.kernel.org/lkml/20190827214352.94272-3-meyerk@stormcage.eag.rdlabs.hpecorp.net Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/svghelper.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c index 2e9971590590..fef0f8a40e2f 100644 --- a/tools/perf/util/svghelper.c +++ b/tools/perf/util/svghelper.c @@ -697,7 +697,8 @@ struct topology { int sib_thr_nr; }; -static void scan_thread_topology(int *map, struct topology *t, int cpu, int *pos) +static void scan_thread_topology(int *map, struct topology *t, int cpu, + int *pos, int nr_cpus) { int i; int thr; @@ -706,28 +707,24 @@ static void scan_thread_topology(int *map, struct topology *t, int cpu, int *pos if (!test_bit(cpu, cpumask_bits(&t->sib_thr[i]))) continue; - for_each_set_bit(thr, - cpumask_bits(&t->sib_thr[i]), - MAX_NR_CPUS) + for_each_set_bit(thr, cpumask_bits(&t->sib_thr[i]), nr_cpus) if (map[thr] == -1) map[thr] = (*pos)++; } } -static void scan_core_topology(int *map, struct topology *t) +static void scan_core_topology(int *map, struct topology *t, int nr_cpus) { int pos = 0; int i; int cpu; for (i = 0; i < t->sib_core_nr; i++) - for_each_set_bit(cpu, - cpumask_bits(&t->sib_core[i]), - MAX_NR_CPUS) - scan_thread_topology(map, t, cpu, &pos); + for_each_set_bit(cpu, cpumask_bits(&t->sib_core[i]), nr_cpus) + scan_thread_topology(map, t, cpu, &pos, nr_cpus); } -static int str_to_bitmap(char *s, cpumask_t *b) +static int str_to_bitmap(char *s, cpumask_t *b, int nr_cpus) { int i; int ret = 0; @@ -740,7 +737,7 @@ static int str_to_bitmap(char *s, cpumask_t *b) for (i = 0; i < m->nr; i++) { c = m->map[i]; - if (c >= MAX_NR_CPUS) { + if (c >= nr_cpus) { ret = -1; break; } @@ -755,10 +752,12 @@ static int str_to_bitmap(char *s, cpumask_t *b) int svg_build_topology_map(struct perf_env *env) { - int i; + int i, nr_cpus; struct topology t; char *sib_core, *sib_thr; + nr_cpus = min(env->nr_cpus_online, MAX_NR_CPUS); + t.sib_core_nr = env->nr_sibling_cores; t.sib_thr_nr = env->nr_sibling_threads; t.sib_core = calloc(env->nr_sibling_cores, sizeof(cpumask_t)); @@ -773,7 +772,7 @@ int svg_build_topology_map(struct perf_env *env) } for (i = 0; i < env->nr_sibling_cores; i++) { - if (str_to_bitmap(sib_core, &t.sib_core[i])) { + if (str_to_bitmap(sib_core, &t.sib_core[i], nr_cpus)) { fprintf(stderr, "topology: can't parse siblings map\n"); goto exit; } @@ -782,7 +781,7 @@ int svg_build_topology_map(struct perf_env *env) } for (i = 0; i < env->nr_sibling_threads; i++) { - if (str_to_bitmap(sib_thr, &t.sib_thr[i])) { + if (str_to_bitmap(sib_thr, &t.sib_thr[i], nr_cpus)) { fprintf(stderr, "topology: can't parse siblings map\n"); goto exit; } @@ -790,16 +789,16 @@ int svg_build_topology_map(struct perf_env *env) sib_thr += strlen(sib_thr) + 1; } - topology_map = malloc(sizeof(int) * MAX_NR_CPUS); + topology_map = malloc(sizeof(int) * nr_cpus); if (!topology_map) { fprintf(stderr, "topology: no memory\n"); goto exit; } - for (i = 0; i < MAX_NR_CPUS; i++) + for (i = 0; i < nr_cpus; i++) topology_map[i] = -1; - scan_core_topology(topology_map, &t); + scan_core_topology(topology_map, &t, nr_cpus); return 0; From 92b5a1545ad51e8225e691e9a29ba33cc9fe37bc Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 27 Aug 2019 16:43:48 -0500 Subject: [PATCH 04/47] perf stat: Replace MAX_NR_CPUS with cpu__max_cpu() The function cpu__max_cpu() returns the possible number of CPUs as defined in the sysfs and can be used as an alternative for MAX_NR_CPUS in zero_per_pkg() and check_per_pkg(). Signed-off-by: Kyle Meyer Reviewed-by: Jiri Olsa Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Russ Anderson Link: http://lore.kernel.org/lkml/20190827214352.94272-4-meyerk@stormcage.eag.rdlabs.hpecorp.net Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/stat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 66f8808e57d3..f6eb6af5f151 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -210,7 +210,7 @@ void perf_evlist__reset_stats(struct evlist *evlist) static void zero_per_pkg(struct evsel *counter) { if (counter->per_pkg_mask) - memset(counter->per_pkg_mask, 0, MAX_NR_CPUS); + memset(counter->per_pkg_mask, 0, cpu__max_cpu()); } static int check_per_pkg(struct evsel *counter, @@ -229,7 +229,7 @@ static int check_per_pkg(struct evsel *counter, return 0; if (!mask) { - mask = zalloc(MAX_NR_CPUS); + mask = zalloc(cpu__max_cpu()); if (!mask) return -ENOMEM; From 7df4e36a4785618f0c63f3dc2bacb164780ab0f6 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 27 Aug 2019 16:43:49 -0500 Subject: [PATCH 05/47] perf session: Replace MAX_NR_CPUS with perf_env::nr_cpus_online nr_cpus, the number of CPUs online during a record session bound by MAX_NR_CPUS, can be used as a dynamic alternative for MAX_NR_CPUS in perf_session__cpu_bitmap. Signed-off-by: Kyle Meyer Reviewed-by: Jiri Olsa Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Russ Anderson Link: http://lore.kernel.org/lkml/20190827214352.94272-5-meyerk@stormcage.eag.rdlabs.hpecorp.net Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/session.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 7350b0dfbc1e..13486bcf74a0 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2292,6 +2292,7 @@ int perf_session__cpu_bitmap(struct perf_session *session, { int i, err = -1; struct perf_cpu_map *map; + int nr_cpus = min(session->header.env.nr_cpus_online, MAX_NR_CPUS); for (i = 0; i < PERF_TYPE_MAX; ++i) { struct evsel *evsel; @@ -2316,7 +2317,7 @@ int perf_session__cpu_bitmap(struct perf_session *session, for (i = 0; i < map->nr; i++) { int cpu = map->map[i]; - if (cpu >= MAX_NR_CPUS) { + if (cpu >= nr_cpus) { pr_err("Requested CPU %d too large. " "Consider raising MAX_NR_CPUS\n", cpu); goto out_delete_map; From 8c7274691f0de5fb56f3b9fe9208ce7e515a2d2c Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 27 Aug 2019 16:43:50 -0500 Subject: [PATCH 06/47] perf machine: Replace MAX_NR_CPUS with perf_env::nr_cpus_online nr_cpus, the number of CPUs online during a record session bound by MAX_NR_CPUS, can be used as a dynamic alternative for MAX_NR_CPUS in __machine__synthesize_threads and machine__set_current_tid. Signed-off-by: Kyle Meyer Reviewed-by: Jiri Olsa Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Russ Anderson Link: http://lore.kernel.org/lkml/20190827214352.94272-6-meyerk@stormcage.eag.rdlabs.hpecorp.net Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 93483f1764d3..a1542b4c047b 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2619,7 +2619,9 @@ int __machine__synthesize_threads(struct machine *machine, struct perf_tool *too pid_t machine__get_current_tid(struct machine *machine, int cpu) { - if (cpu < 0 || cpu >= MAX_NR_CPUS || !machine->current_tid) + int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS); + + if (cpu < 0 || cpu >= nr_cpus || !machine->current_tid) return -1; return machine->current_tid[cpu]; @@ -2629,6 +2631,7 @@ int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid, pid_t tid) { struct thread *thread; + int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS); if (cpu < 0) return -EINVAL; @@ -2636,14 +2639,14 @@ int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid, if (!machine->current_tid) { int i; - machine->current_tid = calloc(MAX_NR_CPUS, sizeof(pid_t)); + machine->current_tid = calloc(nr_cpus, sizeof(pid_t)); if (!machine->current_tid) return -ENOMEM; - for (i = 0; i < MAX_NR_CPUS; i++) + for (i = 0; i < nr_cpus; i++) machine->current_tid[i] = -1; } - if (cpu >= MAX_NR_CPUS) { + if (cpu >= nr_cpus) { pr_err("Requested CPU %d too large. ", cpu); pr_err("Consider raising MAX_NR_CPUS\n"); return -EINVAL; From dc84187f32a3e8eb86bd97f3b10494e1f1fe5e7f Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 27 Aug 2019 16:43:51 -0500 Subject: [PATCH 07/47] perf header: Replace MAX_NR_CPUS with cpu__max_cpu() The function cpu__max_cpu() returns the possible number of CPUs as defined in the sysfs and can be used as an alternative for MAX_NR_CPUS in write_cache. MAX_CACHES is replaced by cpu__max_cpu() * MAX_CACHE_LVL. Signed-off-by: Kyle Meyer Reviewed-by: Jiri Olsa Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Russ Anderson Link: http://lore.kernel.org/lkml/20190827214352.94272-7-meyerk@stormcage.eag.rdlabs.hpecorp.net Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/header.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 0a842d9eff22..dd2bb0861ab1 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -1122,16 +1122,17 @@ static int build_caches(struct cpu_cache_level caches[], u32 size, u32 *cntp) return 0; } -#define MAX_CACHES (MAX_NR_CPUS * 4) +#define MAX_CACHE_LVL 4 static int write_cache(struct feat_fd *ff, struct evlist *evlist __maybe_unused) { - struct cpu_cache_level caches[MAX_CACHES]; + u32 max_caches = cpu__max_cpu() * MAX_CACHE_LVL; + struct cpu_cache_level caches[max_caches]; u32 cnt = 0, i, version = 1; int ret; - ret = build_caches(caches, MAX_CACHES, &cnt); + ret = build_caches(caches, max_caches, &cnt); if (ret) goto out; From df552793493ff83b2b7289389d29d417b3ef6d6d Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 27 Aug 2019 16:43:52 -0500 Subject: [PATCH 08/47] libperf: Warn when exceeding MAX_NR_CPUS in cpumap Display a warning when attempting to profile more than MAX_NR_CPU CPUs. This patch should not change any behavior. Signed-off-by: Kyle Meyer Reviewed-by: Jiri Olsa Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Russ Anderson Link: http://lore.kernel.org/lkml/20190827214352.94272-8-meyerk@stormcage.eag.rdlabs.hpecorp.net Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/cpumap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/perf/lib/cpumap.c b/tools/perf/lib/cpumap.c index 2834753576b2..1f0e6f334237 100644 --- a/tools/perf/lib/cpumap.c +++ b/tools/perf/lib/cpumap.c @@ -100,6 +100,9 @@ struct perf_cpu_map *perf_cpu_map__read(FILE *file) if (prev >= 0) { int new_max = nr_cpus + cpu - prev - 1; + WARN_ONCE(new_max >= MAX_NR_CPUS, "Perf can support %d CPUs. " + "Consider raising MAX_NR_CPUS\n", MAX_NR_CPUS); + if (new_max >= max_entries) { max_entries = new_max + MAX_NR_CPUS / 2; tmp = realloc(tmp_cpus, max_entries * sizeof(int)); @@ -192,6 +195,9 @@ struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list) end_cpu = start_cpu; } + WARN_ONCE(end_cpu >= MAX_NR_CPUS, "Perf can support %d CPUs. " + "Consider raising MAX_NR_CPUS\n", MAX_NR_CPUS); + for (; start_cpu <= end_cpu; start_cpu++) { /* check for duplicates */ for (i = 0; i < nr_cpus; i++) From 108a1bb9d1d88bff47d5eccd2cf18dc09a04fb9f Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 29 Aug 2019 13:00:28 -0300 Subject: [PATCH 09/47] perf tools: Remove needless libtraceevent include directives Remove traceevent/event-parse.h and traceevent/trace-seq.h from places where it is not needed. Should avoid rebuilding those files when these traceevent headers get changed. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Steven Rostedt (VMware) Cc: Tzvetomir Stoyanov Link: https://lkml.kernel.org/n/tip-26hn75jn9rdealn4uqtzend6@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-timechart.c | 1 - tools/perf/util/session.c | 1 - tools/perf/util/trace-event.h | 1 - 3 files changed, 3 deletions(-) diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 1ff81a790931..1a74499f3311 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -10,7 +10,6 @@ #include #include -#include #include "builtin.h" #include "util/color.h" diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 13486bcf74a0..9eb843e5e6f0 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h index 258d79071d81..2e158387b3d7 100644 --- a/tools/perf/util/trace-event.h +++ b/tools/perf/util/trace-event.h @@ -3,7 +3,6 @@ #define _PERF_UTIL_TRACE_EVENT_H #include -#include #include "parse-events.h" struct machine; From a77494026309711a5f1e4b078e353cd46c2dad9f Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 29 Aug 2019 14:40:28 -0300 Subject: [PATCH 10/47] perf header: Move CPUINFO_PROC to the only file where it is used To reduce perf-sys.h and eventually nuke it. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-ars2j5m3if3gypsvkbbijucq@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/perf-sys.h | 44 ---------------------------------------- tools/perf/util/header.c | 18 ++++++++++++++++ 2 files changed, 18 insertions(+), 44 deletions(-) diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h index 3eb7a39169f6..6ffb0fbd6237 100644 --- a/tools/perf/perf-sys.h +++ b/tools/perf/perf-sys.h @@ -10,50 +10,6 @@ #include #include -#ifdef __powerpc__ -#define CPUINFO_PROC {"cpu"} -#endif - -#ifdef __s390__ -#define CPUINFO_PROC {"vendor_id"} -#endif - -#ifdef __sh__ -#define CPUINFO_PROC {"cpu type"} -#endif - -#ifdef __hppa__ -#define CPUINFO_PROC {"cpu"} -#endif - -#ifdef __sparc__ -#define CPUINFO_PROC {"cpu"} -#endif - -#ifdef __alpha__ -#define CPUINFO_PROC {"cpu model"} -#endif - -#ifdef __arm__ -#define CPUINFO_PROC {"model name", "Processor"} -#endif - -#ifdef __mips__ -#define CPUINFO_PROC {"cpu model"} -#endif - -#ifdef __arc__ -#define CPUINFO_PROC {"Processor"} -#endif - -#ifdef __xtensa__ -#define CPUINFO_PROC {"core ID"} -#endif - -#ifndef CPUINFO_PROC -#define CPUINFO_PROC { "model name", } -#endif - static inline int sys_perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu, int group_fd, diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index dd2bb0861ab1..d252124f926d 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -436,7 +436,25 @@ done: static int write_cpudesc(struct feat_fd *ff, struct evlist *evlist __maybe_unused) { +#if defined(__powerpc__) || defined(__hppa__) || defined(__sparc__) +#define CPUINFO_PROC { "cpu", } +#elif defined(__s390__) +#define CPUINFO_PROC { "vendor_id", } +#elif defined(__sh__) +#define CPUINFO_PROC { "cpu type", } +#elif defined(__alpha__) || defined(__mips__) +#define CPUINFO_PROC { "cpu model", } +#elif defined(__arm__) +#define CPUINFO_PROC { "model name", "Processor", } +#elif defined(__arc__) +#define CPUINFO_PROC { "Processor", } +#elif defined(__xtensa__) +#define CPUINFO_PROC { "core ID", } +#else +#define CPUINFO_PROC { "model name", } +#endif const char *cpuinfo_procs[] = CPUINFO_PROC; +#undef CPUINFO_PROC unsigned int i; for (i = 0; i < ARRAY_SIZE(cpuinfo_procs); i++) { From 91854f9a077e18e43ed30ebe9c61f8089bec9166 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 29 Aug 2019 14:59:50 -0300 Subject: [PATCH 11/47] perf tools: Move everything related to sys_perf_event_open() to perf-sys.h And remove unneeded include directives from perf-sys.h to prune the header dependency tree. Fixup the fallout in places where definitions were being used without the needed include directives that were being satisfied because they were in perf-sys.h. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-7b1zvugiwak4ibfa3j6ott7f@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/common.c | 1 + tools/perf/arch/x86/tests/rdpmc.c | 2 +- tools/perf/arch/x86/util/perf_regs.c | 2 +- tools/perf/arch/x86/util/tsc.c | 1 + tools/perf/bench/epoll-ctl.c | 1 + tools/perf/bench/epoll-wait.c | 1 + tools/perf/bench/mem-functions.c | 3 ++- tools/perf/builtin-sched.c | 1 + tools/perf/perf-sys.h | 13 ++++++++++--- tools/perf/perf.c | 1 + tools/perf/perf.h | 12 ------------ tools/perf/tests/attr.c | 2 +- tools/perf/tests/bp_account.c | 2 +- tools/perf/tests/bp_signal.c | 2 +- tools/perf/tests/bp_signal_overflow.c | 2 +- tools/perf/tests/wp.c | 2 ++ tools/perf/util/auxtrace.h | 1 + tools/perf/util/cloexec.c | 2 +- tools/perf/util/evsel.c | 1 + tools/perf/util/genelf.c | 2 ++ tools/perf/util/python.c | 1 + tools/perf/util/record.c | 1 + tools/perf/util/strbuf.c | 1 + 23 files changed, 34 insertions(+), 23 deletions(-) diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c index 1a9e22f78c22..a769382fb644 100644 --- a/tools/perf/arch/common.c +++ b/tools/perf/arch/common.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include "common.h" #include "../util/env.h" #include "../util/debug.h" diff --git a/tools/perf/arch/x86/tests/rdpmc.c b/tools/perf/arch/x86/tests/rdpmc.c index 7a11f02d6c6c..345a6a0a328b 100644 --- a/tools/perf/arch/x86/tests/rdpmc.c +++ b/tools/perf/arch/x86/tests/rdpmc.c @@ -7,7 +7,7 @@ #include #include #include -#include "perf.h" +#include "perf-sys.h" #include "debug.h" #include "tests/tests.h" #include "cloexec.h" diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c index 0d7b77ff0ae6..74a606ea42d3 100644 --- a/tools/perf/arch/x86/util/perf_regs.c +++ b/tools/perf/arch/x86/util/perf_regs.c @@ -4,7 +4,7 @@ #include #include -#include "../../perf.h" +#include "../../perf-sys.h" #include "../../util/perf_regs.h" #include "../../util/debug.h" diff --git a/tools/perf/arch/x86/util/tsc.c b/tools/perf/arch/x86/util/tsc.c index 81720e27f8a3..a6ba45d0db6e 100644 --- a/tools/perf/arch/x86/util/tsc.c +++ b/tools/perf/arch/x86/util/tsc.c @@ -7,6 +7,7 @@ #include "../../../perf.h" #include +#include #include "../../../util/debug.h" #include "../../../util/tsc.h" diff --git a/tools/perf/bench/epoll-ctl.c b/tools/perf/bench/epoll-ctl.c index 84658d45f349..d1caa4a0a12a 100644 --- a/tools/perf/bench/epoll-ctl.c +++ b/tools/perf/bench/epoll-ctl.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/bench/epoll-wait.c b/tools/perf/bench/epoll-wait.c index c27a65639cfb..f6b4472847d2 100644 --- a/tools/perf/bench/epoll-wait.c +++ b/tools/perf/bench/epoll-wait.c @@ -63,6 +63,7 @@ /* For the CLR_() macros */ #include #include +#include #include #include diff --git a/tools/perf/bench/mem-functions.c b/tools/perf/bench/mem-functions.c index 64dc994c72ea..9235b76501be 100644 --- a/tools/perf/bench/mem-functions.c +++ b/tools/perf/bench/mem-functions.c @@ -8,7 +8,7 @@ */ #include "debug.h" -#include "../perf.h" +#include "../perf-sys.h" #include #include "../util/header.h" #include "../util/cloexec.h" @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 025151dcb651..91d0a9b10581 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include "builtin.h" #include "perf.h" +#include "perf-sys.h" #include "util/evlist.h" #include "util/cache.h" diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h index 6ffb0fbd6237..63e4349a772a 100644 --- a/tools/perf/perf-sys.h +++ b/tools/perf/perf-sys.h @@ -5,10 +5,17 @@ #include #include #include -#include #include -#include -#include + +struct perf_event_attr; + +extern bool test_attr__enabled; +void test_attr__ready(void); +void test_attr__init(void); +void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, + int fd, int group_fd, unsigned long flags); + +#define HAVE_ATTR_TEST static inline int sys_perf_event_open(struct perf_event_attr *attr, diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 34763a9b873d..a95a248a7421 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -19,6 +19,7 @@ #include "util/debug.h" #include "util/event.h" #include "util/util.h" +#include "perf-sys.h" #include #include #include diff --git a/tools/perf/perf.h b/tools/perf/perf.h index d9e6b8b957b6..7a1a92127b9b 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -4,18 +4,6 @@ #include #include -#include -#include -#include - -extern bool test_attr__enabled; -void test_attr__ready(void); -void test_attr__init(void); -void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, - int fd, int group_fd, unsigned long flags); - -#define HAVE_ATTR_TEST -#include "perf-sys.h" static inline unsigned long long rdclock(void) { diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c index d8426547219b..87dc3e1174af 100644 --- a/tools/perf/tests/attr.c +++ b/tools/perf/tests/attr.c @@ -30,7 +30,7 @@ #include #include #include -#include "../perf.h" +#include "../perf-sys.h" #include #include "tests.h" diff --git a/tools/perf/tests/bp_account.c b/tools/perf/tests/bp_account.c index 153624e2d0f5..c4a30318d7e0 100644 --- a/tools/perf/tests/bp_account.c +++ b/tools/perf/tests/bp_account.c @@ -19,7 +19,7 @@ #include "tests.h" #include "debug.h" -#include "perf.h" +#include "../perf-sys.h" #include "cloexec.h" volatile long the_var; diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c index 910e25e64188..2d292f8fb3dd 100644 --- a/tools/perf/tests/bp_signal.c +++ b/tools/perf/tests/bp_signal.c @@ -25,7 +25,7 @@ #include "tests.h" #include "debug.h" -#include "perf.h" +#include "perf-sys.h" #include "cloexec.h" static int fd1; diff --git a/tools/perf/tests/bp_signal_overflow.c b/tools/perf/tests/bp_signal_overflow.c index ca962559e845..101315a3b34f 100644 --- a/tools/perf/tests/bp_signal_overflow.c +++ b/tools/perf/tests/bp_signal_overflow.c @@ -24,7 +24,7 @@ #include "tests.h" #include "debug.h" -#include "perf.h" +#include "../perf-sys.h" #include "cloexec.h" static int overflows; diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c index f89e6806557b..982ac55d69ea 100644 --- a/tools/perf/tests/wp.c +++ b/tools/perf/tests/wp.c @@ -1,10 +1,12 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include "tests.h" #include "debug.h" #include "cloexec.h" +#include "../perf-sys.h" #define WP_TEST_ASSERT_VAL(fd, text, val) \ do { \ diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index b213e6431d88..1fa8a965b03f 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -15,6 +15,7 @@ #include #include #include +#include #include "../perf.h" #include "event.h" diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c index 06f48312c5ed..92d08198e64a 100644 --- a/tools/perf/util/cloexec.c +++ b/tools/perf/util/cloexec.c @@ -2,7 +2,7 @@ #include #include #include "util.h" -#include "../perf.h" +#include "../perf-sys.h" #include "cloexec.h" #include "asm/bug.h" #include "debug.h" diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index dbc04e1053a9..b6b406a1678f 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -41,6 +41,7 @@ #include "string2.h" #include "memswap.h" #include "util.h" +#include "../perf-sys.h" #include "util/parse-branch-options.h" #include diff --git a/tools/perf/util/genelf.c b/tools/perf/util/genelf.c index 7001247ebbd6..bc32f405b26e 100644 --- a/tools/perf/util/genelf.c +++ b/tools/perf/util/genelf.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +26,7 @@ #include "perf.h" #include "genelf.h" #include "../util/jitdump.h" +#include #ifndef NT_GNU_BUILD_ID #define NT_GNU_BUILD_ID 3 diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 11479a7ad1c7..9dd83871aafe 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -14,6 +14,7 @@ #include "thread_map.h" #include "mmap.h" #include "util.h" +#include "../perf-sys.h" #if PY_MAJOR_VERSION < 3 #define _PyUnicode_FromString(arg) \ diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 574507d46c98..c67a51397bc7 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c @@ -10,6 +10,7 @@ #include "util.h" #include "cloexec.h" #include "record.h" +#include "../perf-sys.h" typedef void (*setup_probe_fn_t)(struct evsel *evsel); diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c index 2ce0dc887364..0afdbf38a2b2 100644 --- a/tools/perf/util/strbuf.c +++ b/tools/perf/util/strbuf.c @@ -4,6 +4,7 @@ #include #include #include +#include /* * Used as the default ->buf value, so that people can always assume From f37110205c3065546d6995b1463751c7bbb50e89 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 29 Aug 2019 15:16:27 -0300 Subject: [PATCH 12/47] perf time-utils: Adopt rdclock() from perf.h Seems to be a better place for this function to live, further shrinking the hodge-podge that perf.h was. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-0zzt1u9rpyjukdy1ccr2u5r9@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 1 + tools/perf/perf.h | 9 --------- tools/perf/util/event.c | 1 + tools/perf/util/time-utils.h | 9 +++++++++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index a7e8c26635db..2741bcb049fb 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -62,6 +62,7 @@ #include "util/string2.h" #include "util/metricgroup.h" #include "util/target.h" +#include "util/time-utils.h" #include "util/top.h" #include "asm/bug.h" diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 7a1a92127b9b..74014033df60 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -2,17 +2,8 @@ #ifndef _PERF_PERF_H #define _PERF_PERF_H -#include #include -static inline unsigned long long rdclock(void) -{ - struct timespec ts; - - clock_gettime(CLOCK_MONOTONIC, &ts); - return ts.tv_sec * 1000000000ULL + ts.tv_nsec; -} - #ifndef MAX_NR_CPUS #define MAX_NR_CPUS 2048 #endif diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index c9d1f83c747a..7fa7a303e476 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -21,6 +21,7 @@ #include "strlist.h" #include "thread.h" #include "thread_map.h" +#include "time-utils.h" #include #include "map.h" #include "symbol.h" diff --git a/tools/perf/util/time-utils.h b/tools/perf/util/time-utils.h index 72a42ea1d513..4f42988eb2f7 100644 --- a/tools/perf/util/time-utils.h +++ b/tools/perf/util/time-utils.h @@ -3,6 +3,7 @@ #define _TIME_UTILS_H_ #include +#include #include struct perf_time_interval { @@ -34,4 +35,12 @@ int timestamp__scnprintf_nsec(u64 timestamp, char *buf, size_t sz); int fetch_current_timestamp(char *buf, size_t sz); +static inline unsigned long long rdclock(void) +{ + struct timespec ts; + + clock_gettime(CLOCK_MONOTONIC, &ts); + return ts.tv_sec * 1000000000ULL + ts.tv_nsec; +} + #endif From c1a604dff486399ae0be95e6396e0158df95ad5d Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 29 Aug 2019 15:20:59 -0300 Subject: [PATCH 13/47] perf tools: Remove needless perf.h include directive from headers Its not needed there, add it to the places that need it and were getting it via those headers. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-5yulx1u16vyd0zmrbg1tjhju@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-c2c.c | 1 + tools/perf/builtin-diff.c | 1 + tools/perf/builtin-record.c | 1 + tools/perf/builtin-script.c | 1 + tools/perf/builtin-stat.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/perf.c | 1 + tools/perf/ui/browsers/hists.c | 1 + tools/perf/ui/browsers/res_sample.c | 1 + tools/perf/ui/browsers/scripts.c | 1 + tools/perf/ui/hist.c | 1 + tools/perf/ui/tui/setup.c | 1 + tools/perf/util/auxtrace.h | 1 - tools/perf/util/callchain.c | 1 + tools/perf/util/event.c | 1 + tools/perf/util/event.h | 1 - tools/perf/util/evlist.c | 1 + tools/perf/util/evlist.h | 1 - tools/perf/util/mmap.c | 1 + tools/perf/util/session.c | 1 + tools/perf/util/top.c | 1 + 21 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 8335a4076a5a..25a5f186dfde 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -35,6 +35,7 @@ #include "thread.h" #include "mem2node.h" #include "symbol.h" +#include "../perf.h" struct c2c_hists { struct hists hists; diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 51c37e53b3d8..ae4a8ebf90d2 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -6,6 +6,7 @@ * DSOs and symbol information, sort them and produce a diff. */ #include "builtin.h" +#include "perf.h" #include "util/debug.h" #include "util/event.h" diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index bd2a0cc6eb52..56705d2a6bec 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -42,6 +42,7 @@ #include "util/units.h" #include "util/bpf-event.h" #include "asm/bug.h" +#include "perf.h" #include #include diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 37297b67905d..f3b31c6ed15f 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -53,6 +53,7 @@ #include #include "util/record.h" #include "util/util.h" +#include "perf.h" #include diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 2741bcb049fb..fa4212dac9bb 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -41,6 +41,7 @@ */ #include "builtin.h" +#include "perf.h" #include "util/cgroup.h" #include #include "util/parse-events.h" diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 6d9805a8791b..105695033ebc 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -51,6 +51,7 @@ #include "string2.h" #include "syscalltbl.h" #include "rb_resort.h" +#include "../perf.h" #include #include diff --git a/tools/perf/perf.c b/tools/perf/perf.c index a95a248a7421..237b9b3a1bf1 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -8,6 +8,7 @@ * perf top, perf record, perf report, etc.) are started. */ #include "builtin.h" +#include "perf.h" #include "util/env.h" #include diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 30547fdb0787..ccc37284860b 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -22,6 +22,7 @@ #include "../../util/top.h" #include "../../util/thread.h" #include "../../arch/common.h" +#include "../../perf.h" #include "../browsers/hists.h" #include "../helpline.h" diff --git a/tools/perf/ui/browsers/res_sample.c b/tools/perf/ui/browsers/res_sample.c index 41a9d8923ec4..db3954fea74c 100644 --- a/tools/perf/ui/browsers/res_sample.c +++ b/tools/perf/ui/browsers/res_sample.c @@ -8,6 +8,7 @@ #include "time-utils.h" #include "../util.h" #include "../../util/util.h" +#include "../../perf.h" #include #include diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c index 50e0c03171f2..e63f3778d75c 100644 --- a/tools/perf/ui/browsers/scripts.c +++ b/tools/perf/ui/browsers/scripts.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "../../builtin.h" +#include "../../perf.h" #include "../../util/sort.h" #include "../../util/util.h" #include "../../util/hist.h" diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index e5fb64347b2c..ae29f16979ac 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -9,6 +9,7 @@ #include "../util/sort.h" #include "../util/evsel.h" #include "../util/evlist.h" +#include "../perf.h" /* hist period print (hpp) functions */ diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c index 3ad0d3363ac6..2881982b483c 100644 --- a/tools/perf/ui/tui/setup.c +++ b/tools/perf/ui/tui/setup.c @@ -11,6 +11,7 @@ #include "../../util/cache.h" #include "../../util/debug.h" #include "../../util/util.h" +#include "../../perf.h" #include "../browser.h" #include "../helpline.h" #include "../ui.h" diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 1fa8a965b03f..bc39cc5610a8 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -17,7 +17,6 @@ #include #include -#include "../perf.h" #include "event.h" #include "session.h" #include "debug.h" diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index dd6e01000385..a47d0e8c2434 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -28,6 +28,7 @@ #include "callchain.h" #include "branch.h" #include "symbol.h" +#include "../perf.h" #define CALLCHAIN_PARAM_DEFAULT \ .mode = CHAIN_GRAPH_ABS, \ diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 7fa7a303e476..ef7fc574f701 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -30,6 +30,7 @@ #include "stat.h" #include "session.h" #include "bpf-event.h" +#include "../perf.h" #define DEFAULT_PROC_MAP_PARSE_TIMEOUT 500 diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 4c0c5232bd41..f56d268f06e3 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -9,7 +9,6 @@ #include #include -#include "../perf.h" #include "build-id.h" #include "perf_regs.h" diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 253dd8dd0e12..71b231c7097f 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -17,6 +17,7 @@ #include "debug.h" #include "units.h" #include "util.h" +#include "../perf.h" #include "asm/bug.h" #include "bpf-event.h" #include diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 16796de7af3f..ee288644e9e4 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -9,7 +9,6 @@ #include #include #include -#include "../perf.h" #include "event.h" #include "evsel.h" #include "mmap.h" diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index 5f3532e51ec9..28477ff5114e 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -16,6 +16,7 @@ #include "debug.h" #include "event.h" #include "mmap.h" +#include "../perf.h" #include "util.h" /* page_size */ size_t perf_mmap__mmap_len(struct perf_mmap *map) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 9eb843e5e6f0..82bd5d4361f0 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -29,6 +29,7 @@ #include "sample-raw.h" #include "stat.h" #include "util.h" +#include "../perf.h" #include "arch/common.h" #ifdef HAVE_ZSTD_SUPPORT diff --git a/tools/perf/util/top.c b/tools/perf/util/top.c index e5b690cf2898..51fb574998bb 100644 --- a/tools/perf/util/top.c +++ b/tools/perf/util/top.c @@ -12,6 +12,7 @@ #include "parse-events.h" #include "symbol.h" #include "top.h" +#include "../perf.h" #include #define SNPRINTF(buf, size, fmt, args...) \ From 0ac25fd0a04d8bd52ceac2476e71a4e497489987 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 29 Aug 2019 15:42:40 -0300 Subject: [PATCH 14/47] perf tools: Remove perf.h from source files not needing it With the movement of lots of stuff out of perf.h to other headers we ended up not needing it in lots of places, remove it from those places. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-c718m0sxxwp73lp9d8vpihb4@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/powerpc/util/perf_regs.c | 1 - tools/perf/arch/x86/tests/intel-cqm.c | 1 - tools/perf/arch/x86/util/archinsn.c | 1 - tools/perf/arch/x86/util/tsc.c | 1 - tools/perf/bench/numa.c | 1 - tools/perf/bench/sched-messaging.c | 1 - tools/perf/bench/sched-pipe.c | 1 - tools/perf/builtin-bench.c | 1 - tools/perf/builtin-buildid-cache.c | 1 - tools/perf/builtin-buildid-list.c | 1 - tools/perf/builtin-config.c | 2 -- tools/perf/builtin-ftrace.c | 1 - tools/perf/builtin-help.c | 1 - tools/perf/builtin-inject.c | 1 - tools/perf/builtin-list.c | 2 -- tools/perf/builtin-probe.c | 1 - tools/perf/scripts/perl/Perf-Trace-Util/Context.c | 1 - tools/perf/scripts/python/Perf-Trace-Util/Context.c | 1 - tools/perf/tests/hists_common.c | 1 - tools/perf/tests/hists_cumulate.c | 1 - tools/perf/tests/hists_filter.c | 1 - tools/perf/tests/hists_link.c | 1 - tools/perf/tests/hists_output.c | 1 - tools/perf/ui/browser.c | 1 - tools/perf/util/bpf-loader.c | 1 - tools/perf/util/bpf-prologue.c | 1 - tools/perf/util/branch.c | 1 - tools/perf/util/cacheline.c | 1 - tools/perf/util/cgroup.c | 1 - tools/perf/util/cpumap.c | 1 - tools/perf/util/debug.c | 2 -- tools/perf/util/event.c | 1 - tools/perf/util/genelf.c | 1 - tools/perf/util/genelf_debug.c | 1 - tools/perf/util/header.c | 1 - tools/perf/util/intel-pt.c | 1 - tools/perf/util/parse-branch-options.c | 1 - tools/perf/util/parse-events.c | 1 - tools/perf/util/scripting-engines/trace-event-perl.c | 1 - tools/perf/util/scripting-engines/trace-event-python.c | 1 - tools/perf/util/svghelper.c | 1 - tools/perf/util/thread.c | 1 - tools/perf/util/time-utils.c | 1 - tools/perf/util/trace-event-info.c | 1 - tools/perf/util/trace-event-parse.c | 1 - tools/perf/util/trace-event-read.c | 1 - tools/perf/util/trace-event-scripting.c | 1 - tools/perf/util/util.c | 1 - 48 files changed, 51 deletions(-) diff --git a/tools/perf/arch/powerpc/util/perf_regs.c b/tools/perf/arch/powerpc/util/perf_regs.c index f14102b85509..e9c436eeffc9 100644 --- a/tools/perf/arch/powerpc/util/perf_regs.c +++ b/tools/perf/arch/powerpc/util/perf_regs.c @@ -4,7 +4,6 @@ #include #include -#include "../../perf.h" #include "../../util/perf_regs.h" #include "../../util/debug.h" diff --git a/tools/perf/arch/x86/tests/intel-cqm.c b/tools/perf/arch/x86/tests/intel-cqm.c index 2a105e3b2ad1..3b5cc3373821 100644 --- a/tools/perf/arch/x86/tests/intel-cqm.c +++ b/tools/perf/arch/x86/tests/intel-cqm.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 #include "tests/tests.h" -#include "perf.h" #include "cloexec.h" #include "debug.h" #include "evlist.h" diff --git a/tools/perf/arch/x86/util/archinsn.c b/tools/perf/arch/x86/util/archinsn.c index 4237bb2e7fa2..62e8e1820132 100644 --- a/tools/perf/arch/x86/util/archinsn.c +++ b/tools/perf/arch/x86/util/archinsn.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include "perf.h" #include "archinsn.h" #include "util/intel-pt-decoder/insn.h" #include "machine.h" diff --git a/tools/perf/arch/x86/util/tsc.c b/tools/perf/arch/x86/util/tsc.c index a6ba45d0db6e..c5197a15119b 100644 --- a/tools/perf/arch/x86/util/tsc.c +++ b/tools/perf/arch/x86/util/tsc.c @@ -5,7 +5,6 @@ #include #include -#include "../../../perf.h" #include #include #include "../../../util/debug.h" diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c index 513cb2f2fa32..62b8ef4bcb1f 100644 --- a/tools/perf/bench/numa.c +++ b/tools/perf/bench/numa.c @@ -9,7 +9,6 @@ /* For the CLR_() macros */ #include -#include "../perf.h" #include "../builtin.h" #include #include "../util/cloexec.h" diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c index f9d7641ae833..c63eb9a46346 100644 --- a/tools/perf/bench/sched-messaging.c +++ b/tools/perf/bench/sched-messaging.c @@ -10,7 +10,6 @@ * */ -#include "../perf.h" #include "../util/util.h" #include #include "../builtin.h" diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c index 0591be008f2a..35b07f197d48 100644 --- a/tools/perf/bench/sched-pipe.c +++ b/tools/perf/bench/sched-pipe.c @@ -9,7 +9,6 @@ * http://people.redhat.com/mingo/cfs-scheduler/tools/pipe-test-1m.c * Ported to perf by Hitoshi Mitake */ -#include "../perf.h" #include "../util/util.h" #include #include "../builtin.h" diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c index b8e7c38ef221..c06fe21c8613 100644 --- a/tools/perf/builtin-bench.c +++ b/tools/perf/builtin-bench.c @@ -16,7 +16,6 @@ * futex ... Futex performance * epoll ... Event poll performance */ -#include "perf.h" #include #include "builtin.h" #include "bench/bench.h" diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index 7dde3ef0398f..9e756004ef28 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c @@ -14,7 +14,6 @@ #include #include #include "builtin.h" -#include "perf.h" #include "namespaces.h" #include "util/cache.h" #include "util/debug.h" diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index f403e19488b5..72bdc0eba990 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c @@ -1,4 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 /* * builtin-buildid-list.c * diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c index 6c1284c87aaa..edfc8f76f1bd 100644 --- a/tools/perf/builtin-config.c +++ b/tools/perf/builtin-config.c @@ -7,8 +7,6 @@ */ #include "builtin.h" -#include "perf.h" - #include "util/cache.h" #include #include "util/util.h" diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 565db782c1b9..7374f86833fd 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -6,7 +6,6 @@ */ #include "builtin.h" -#include "perf.h" #include #include diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index a83af92fb0d1..641d4a3f93c3 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c @@ -4,7 +4,6 @@ * * Builtin help command */ -#include "perf.h" #include "util/config.h" #include "builtin.h" #include diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 040142581d20..ae46de46e826 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -8,7 +8,6 @@ */ #include "builtin.h" -#include "perf.h" #include "util/color.h" #include "util/evlist.h" #include "util/evsel.h" diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c index e0312a1c4792..dca0d33c1343 100644 --- a/tools/perf/builtin-list.c +++ b/tools/perf/builtin-list.c @@ -10,8 +10,6 @@ */ #include "builtin.h" -#include "perf.h" - #include "util/parse-events.h" #include "util/cache.h" #include "util/pmu.h" diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 3d0ffd41fb55..f45fd7e9723e 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c @@ -16,7 +16,6 @@ #include #include -#include "perf.h" #include "builtin.h" #include "namespaces.h" #include "util/strlist.h" diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/Context.c b/tools/perf/scripts/perl/Perf-Trace-Util/Context.c index ead521dd8d79..25c47d23a130 100644 --- a/tools/perf/scripts/perl/Perf-Trace-Util/Context.c +++ b/tools/perf/scripts/perl/Perf-Trace-Util/Context.c @@ -19,7 +19,6 @@ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" -#include "../../../perf.h" #include "../../../util/trace-event.h" #ifndef PERL_UNUSED_VAR diff --git a/tools/perf/scripts/python/Perf-Trace-Util/Context.c b/tools/perf/scripts/python/Perf-Trace-Util/Context.c index 217568bc29ce..0b7096847991 100644 --- a/tools/perf/scripts/python/Perf-Trace-Util/Context.c +++ b/tools/perf/scripts/python/Perf-Trace-Util/Context.c @@ -6,7 +6,6 @@ */ #include -#include "../../../perf.h" #include "../../../util/trace-event.h" #if PY_MAJOR_VERSION < 3 diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c index 469958cd7fe0..96ad95d3f338 100644 --- a/tools/perf/tests/hists_common.c +++ b/tools/perf/tests/hists_common.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 #include -#include "perf.h" #include "util/debug.h" #include "util/map.h" #include "util/symbol.h" diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c index 1f3de85ae18b..93af420ad2e4 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include "perf.h" #include "util/debug.h" #include "util/event.h" #include "util/map.h" diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c index a274716fc438..41dede2f40d8 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include "perf.h" #include "util/debug.h" #include "util/map.h" #include "util/symbol.h" diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c index b25383aa2e6e..012fe8ac0b24 100644 --- a/tools/perf/tests/hists_link.c +++ b/tools/perf/tests/hists_link.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include "perf.h" #include "tests.h" #include "debug.h" #include "symbol.h" diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c index 009888adf4b3..07f4ca0704fb 100644 --- a/tools/perf/tests/hists_output.c +++ b/tools/perf/tests/hists_output.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include "perf.h" #include "util/debug.h" #include "util/event.h" #include "util/map.h" diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index c797a853d3a0..f93d40b1c203 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c @@ -2,7 +2,6 @@ #include "../util/util.h" #include "../util/string2.h" #include "../util/config.h" -#include "../perf.h" #include "libslang.h" #include "ui.h" #include "util.h" diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 80a828e75cf6..c1a57323e25d 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -14,7 +14,6 @@ #include #include #include -#include "perf.h" #include "debug.h" #include "evlist.h" #include "bpf-loader.h" diff --git a/tools/perf/util/bpf-prologue.c b/tools/perf/util/bpf-prologue.c index 77e4891e17b0..09e6c76e1c3b 100644 --- a/tools/perf/util/bpf-prologue.c +++ b/tools/perf/util/bpf-prologue.c @@ -8,7 +8,6 @@ */ #include -#include "perf.h" #include "debug.h" #include "bpf-loader.h" #include "bpf-prologue.h" diff --git a/tools/perf/util/branch.c b/tools/perf/util/branch.c index a4fce2729e50..02d6d839ff24 100644 --- a/tools/perf/util/branch.c +++ b/tools/perf/util/branch.c @@ -1,4 +1,3 @@ -#include "perf.h" #include "util/util.h" #include "util/debug.h" #include "util/branch.h" diff --git a/tools/perf/util/cacheline.c b/tools/perf/util/cacheline.c index 9361d3f61f75..e98b5250a517 100644 --- a/tools/perf/util/cacheline.c +++ b/tools/perf/util/cacheline.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 #include "cacheline.h" -#include "../perf.h" #include #ifdef _SC_LEVEL1_DCACHE_LINESIZE diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index f73599f271ff..96a931c6f728 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include "../perf.h" #include #include "evsel.h" #include "cgroup.h" diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index b9301e7e9c76..a22c1114e880 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 #include -#include "../perf.h" #include "cpumap.h" #include "debug.h" #include "event.h" diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 3780fe42453b..c822c5943340 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -1,8 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* For general debugging purposes */ -#include "../perf.h" - #include #include #include diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index ef7fc574f701..54169ad335c7 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1,4 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 #include #include #include diff --git a/tools/perf/util/genelf.c b/tools/perf/util/genelf.c index bc32f405b26e..f9f18b8b1df9 100644 --- a/tools/perf/util/genelf.c +++ b/tools/perf/util/genelf.c @@ -23,7 +23,6 @@ #include #endif -#include "perf.h" #include "genelf.h" #include "../util/jitdump.h" #include diff --git a/tools/perf/util/genelf_debug.c b/tools/perf/util/genelf_debug.c index 995e490c17fa..30e9f618f6cd 100644 --- a/tools/perf/util/genelf_debug.c +++ b/tools/perf/util/genelf_debug.c @@ -24,7 +24,6 @@ #include #include -#include "perf.h" #include "genelf.h" #include "../util/jitdump.h" diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index d252124f926d..20fb06162fd4 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -26,7 +26,6 @@ #include "evsel.h" #include "header.h" #include "memswap.h" -#include "../perf.h" #include "trace-event.h" #include "session.h" #include "symbol.h" diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index 825a6a3b03a1..825e3690940d 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -12,7 +12,6 @@ #include #include -#include "../perf.h" #include "session.h" #include "machine.h" #include "memswap.h" diff --git a/tools/perf/util/parse-branch-options.c b/tools/perf/util/parse-branch-options.c index 4ed20c833d44..1430437b9d51 100644 --- a/tools/perf/util/parse-branch-options.c +++ b/tools/perf/util/parse-branch-options.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include "perf.h" #include "util/debug.h" #include #include "util/parse-branch-options.h" diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 9101568946d2..5f1ba6820cdd 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -10,7 +10,6 @@ #include #include #include "term.h" -#include "../perf.h" #include "evlist.h" #include "evsel.h" #include diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c index 01ebf10b8bf4..800e82d35230 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c @@ -34,7 +34,6 @@ #include #include -#include "../../perf.h" #include "../callchain.h" #include "../machine.h" #include "../map.h" diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index 78c8bc9380bd..abfde356be18 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -31,7 +31,6 @@ #include #include -#include "../../perf.h" #include "../counts.h" #include "../debug.h" #include "../callchain.h" diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c index fef0f8a40e2f..582f4a69cd48 100644 --- a/tools/perf/util/svghelper.c +++ b/tools/perf/util/svghelper.c @@ -20,7 +20,6 @@ #include #include "env.h" -#include "perf.h" #include "svghelper.h" #include "cpumap.h" diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index dbcb9cfb0f2f..5ba1601e8860 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include "../perf.h" #include #include #include diff --git a/tools/perf/util/time-utils.c b/tools/perf/util/time-utils.c index c2abc259b51d..9796a2e43f67 100644 --- a/tools/perf/util/time-utils.c +++ b/tools/perf/util/time-utils.c @@ -10,7 +10,6 @@ #include #include -#include "perf.h" #include "debug.h" #include "time-utils.h" #include "session.h" diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c index 2f8a0601a546..d63d542b2cde 100644 --- a/tools/perf/util/trace-event-info.c +++ b/tools/perf/util/trace-event-info.c @@ -20,7 +20,6 @@ #include #include -#include "../perf.h" #include "trace-event.h" #include #include "evsel.h" diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index b3982e1bb4c5..8e31a63045c3 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -7,7 +7,6 @@ #include #include -#include "../perf.h" #include "debug.h" #include "trace-event.h" diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c index 13c1cf60d1bc..b6c0db068be0 100644 --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c @@ -15,7 +15,6 @@ #include #include -#include "../perf.h" #include "util.h" #include "trace-event.h" #include "debug.h" diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c index dfd2640c763a..714581b0de65 100644 --- a/tools/perf/util/trace-event-scripting.c +++ b/tools/perf/util/trace-event-scripting.c @@ -10,7 +10,6 @@ #include #include -#include "../perf.h" #include "debug.h" #include "trace-event.h" #include diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 44211e483fbf..607daec22943 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include "../perf.h" #include "util.h" #include "debug.h" #include "namespaces.h" From b42090256fba05dce1a0482a4ccd9bb6464cc499 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 29 Aug 2019 15:56:40 -0300 Subject: [PATCH 15/47] perf tools: Remove debug.h from header files not needing it And fix the fallout, adding it to places that must have it since they use its definitions. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-1s3jel4i26chq2g0lydoz7i3@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm/util/auxtrace.c | 1 + tools/perf/arch/arm/util/cs-etm.c | 1 + tools/perf/arch/x86/tests/perf-time-to-tsc.c | 1 + tools/perf/tests/code-reading.c | 1 + tools/perf/tests/keep-tracking.c | 1 + tools/perf/tests/mmap-basic.c | 1 + tools/perf/tests/sw-clock.c | 2 ++ tools/perf/tests/switch-tracking.c | 1 + tools/perf/tests/task-exit.c | 1 + tools/perf/ui/browsers/annotate.c | 1 + tools/perf/ui/browsers/hists.c | 1 + tools/perf/ui/hist.c | 1 + tools/perf/util/auxtrace.h | 2 +- tools/perf/util/config.c | 1 + tools/perf/util/hist.c | 1 + tools/perf/util/llvm-utils.h | 2 +- tools/perf/util/metricgroup.c | 2 ++ tools/perf/util/python.c | 1 + tools/perf/util/record.c | 1 + tools/perf/util/session.c | 1 + tools/perf/util/sort.c | 1 + tools/perf/util/stat.c | 1 + tools/perf/util/trigger.h | 1 - 23 files changed, 24 insertions(+), 3 deletions(-) diff --git a/tools/perf/arch/arm/util/auxtrace.c b/tools/perf/arch/arm/util/auxtrace.c index 41b78f74599f..0a6e75b8777a 100644 --- a/tools/perf/arch/arm/util/auxtrace.c +++ b/tools/perf/arch/arm/util/auxtrace.c @@ -9,6 +9,7 @@ #include #include "../../util/auxtrace.h" +#include "../../util/debug.h" #include "../../util/evlist.h" #include "../../util/pmu.h" #include "cs-etm.h" diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 9644e2d405f7..b74fd408d496 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -15,6 +15,7 @@ #include #include "cs-etm.h" +#include "../../util/debug.h" #include "../../util/record.h" #include "../../util/auxtrace.h" #include "../../util/cpumap.h" diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/arch/x86/tests/perf-time-to-tsc.c index 02776109ba46..2d1f4713b728 100644 --- a/tools/perf/arch/x86/tests/perf-time-to-tsc.c +++ b/tools/perf/arch/x86/tests/perf-time-to-tsc.c @@ -9,6 +9,7 @@ #include #include +#include "debug.h" #include "parse-events.h" #include "evlist.h" #include "evsel.h" diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index fe671b860086..c4b73bb4b113 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -11,6 +11,7 @@ #include #include +#include "debug.h" #include "parse-events.h" #include "evlist.h" #include "evsel.h" diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c index 2af6faf1bbd6..c758798d3774 100644 --- a/tools/perf/tests/keep-tracking.c +++ b/tools/perf/tests/keep-tracking.c @@ -5,6 +5,7 @@ #include #include +#include "debug.h" #include "parse-events.h" #include "evlist.h" #include "evsel.h" diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index 7327694fbde0..fe91350fd5ab 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c @@ -5,6 +5,7 @@ #include #include +#include "debug.h" #include "evlist.h" #include "evsel.h" #include "thread_map.h" diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c index c5f1a9f83380..97694a040986 100644 --- a/tools/perf/tests/sw-clock.c +++ b/tools/perf/tests/sw-clock.c @@ -5,8 +5,10 @@ #include #include #include +#include #include "tests.h" +#include "util/debug.h" #include "util/evsel.h" #include "util/evlist.h" #include "util/cpumap.h" diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c index b63f02768724..4bed15aee1a8 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c @@ -8,6 +8,7 @@ #include #include +#include "debug.h" #include "parse-events.h" #include "evlist.h" #include "evsel.h" diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index d79a22e2d8be..0e0e0627184e 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 +#include "debug.h" #include "evlist.h" #include "evsel.h" #include "target.h" diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index e633eb42550d..715601f5fce3 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -4,6 +4,7 @@ #include "../ui.h" #include "../util.h" #include "../../util/annotate.h" +#include "../../util/debug.h" #include "../../util/hist.h" #include "../../util/sort.h" #include "../../util/map.h" diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index ccc37284860b..a14dda74f43a 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -11,6 +11,7 @@ #include #include +#include "../../util/debug.h" #include "../../util/callchain.h" #include "../../util/evsel.h" #include "../../util/evlist.h" diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index ae29f16979ac..bf90ce5b2cdf 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -4,6 +4,7 @@ #include #include "../util/callchain.h" +#include "../util/debug.h" #include "../util/hist.h" #include "../util/util.h" #include "../util/sort.h" diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index bc39cc5610a8..b5ac24c770d4 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -19,7 +19,6 @@ #include "event.h" #include "session.h" -#include "debug.h" union perf_event; struct perf_session; @@ -614,6 +613,7 @@ void itrace_synth_opts__clear_time_range(struct itrace_synth_opts *opts) } #else +#include "debug.h" static inline struct auxtrace_record * auxtrace_record__init(struct evlist *evlist __maybe_unused, diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 042ffbc8c53f..eb5308c41ed1 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -18,6 +18,7 @@ #include "util/hist.h" /* perf_hist_config */ #include "util/llvm-utils.h" /* perf_llvm_config */ #include "config.h" +#include "debug.h" #include #include #include diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index e0b149673a88..adae4134e972 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "callchain.h" +#include "debug.h" #include "build-id.h" #include "hist.h" #include "map.h" diff --git a/tools/perf/util/llvm-utils.h b/tools/perf/util/llvm-utils.h index bf3f3f4c4fe2..7878a0e3fa98 100644 --- a/tools/perf/util/llvm-utils.h +++ b/tools/perf/util/llvm-utils.h @@ -6,7 +6,7 @@ #ifndef __LLVM_UTILS_H #define __LLVM_UTILS_H -#include "debug.h" +#include struct llvm_param { /* Path of clang executable */ diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index aaf55444f81b..33f5e2101874 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -6,6 +6,7 @@ /* Manage metrics and groups of metrics from JSON files */ #include "metricgroup.h" +#include "debug.h" #include "evlist.h" #include "evsel.h" #include "strbuf.h" @@ -18,6 +19,7 @@ #include "strlist.h" #include #include +#include #include #include diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 9dd83871aafe..9b350482c403 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -5,6 +5,7 @@ #include #include #include +#include "debug.h" #include "evlist.h" #include "callchain.h" #include "evsel.h" diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index c67a51397bc7..ccad796bce5f 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 +#include "debug.h" #include "evlist.h" #include "evsel.h" #include "cpumap.h" diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 82bd5d4361f0..a72774e4463f 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -12,6 +12,7 @@ #include #include +#include "debug.h" #include "evlist.h" #include "evsel.h" #include "memswap.h" diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 83eb3fa6f941..23d0ab7c801c 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -4,6 +4,7 @@ #include #include #include +#include "debug.h" #include "sort.h" #include "hist.h" #include "cacheline.h" diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index f6eb6af5f151..f4a1edcec7b2 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -3,6 +3,7 @@ #include #include #include "counts.h" +#include "debug.h" #include "stat.h" #include "target.h" #include "evlist.h" diff --git a/tools/perf/util/trigger.h b/tools/perf/util/trigger.h index 88223bc7c82b..33e997f9ccc8 100644 --- a/tools/perf/util/trigger.h +++ b/tools/perf/util/trigger.h @@ -2,7 +2,6 @@ #ifndef __TRIGGER_H_ #define __TRIGGER_H_ 1 -#include "util/debug.h" #include "asm/bug.h" /* From 8520a98dbab61e9e340cdfb72dd17ccc8a98961e Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 29 Aug 2019 16:18:59 -0300 Subject: [PATCH 16/47] perf debug: Remove needless include directives from debug.h All we need there is a forward declaration for 'union perf_event', so remove it from there and add missing header directives in places using things from this indirect include. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-7ftk0ztstqub1tirjj8o8xbl@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm/util/cs-etm.c | 1 + tools/perf/arch/common.c | 2 ++ tools/perf/arch/x86/tests/bp-modify.c | 1 + tools/perf/arch/x86/tests/insn-x86.c | 1 + tools/perf/arch/x86/tests/rdpmc.c | 2 ++ tools/perf/arch/x86/util/perf_regs.c | 1 + tools/perf/builtin-c2c.c | 2 ++ tools/perf/builtin-config.c | 1 + tools/perf/builtin-data.c | 2 ++ tools/perf/builtin-diff.c | 1 + tools/perf/builtin-ftrace.c | 3 ++- tools/perf/builtin-help.c | 4 ++++ tools/perf/builtin-kmem.c | 1 + tools/perf/builtin-list.c | 1 + tools/perf/builtin-probe.c | 1 + tools/perf/builtin-record.c | 1 + tools/perf/builtin-report.c | 2 ++ tools/perf/builtin-top.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/perf.c | 2 ++ tools/perf/tests/attr.c | 1 + tools/perf/tests/backward-ring-buffer.c | 1 + tools/perf/tests/bp_account.c | 1 + tools/perf/tests/bp_signal.c | 1 + tools/perf/tests/bp_signal_overflow.c | 1 + tools/perf/tests/bpf.c | 1 + tools/perf/tests/event-times.c | 1 + tools/perf/tests/expr.c | 1 + tools/perf/tests/kmod-path.c | 2 ++ tools/perf/tests/mmap-basic.c | 1 + tools/perf/tests/openat-syscall-all-cpus.c | 1 + tools/perf/tests/openat-syscall-tp-fields.c | 1 + tools/perf/tests/openat-syscall.c | 1 + tools/perf/tests/perf-record.c | 1 + tools/perf/tests/sample-parsing.c | 1 + tools/perf/tests/task-exit.c | 1 + tools/perf/tests/thread-map.c | 7 +++++++ tools/perf/tests/unit_number__scnprintf.c | 1 + tools/perf/tests/wp.c | 3 +++ tools/perf/ui/browsers/scripts.c | 1 + tools/perf/ui/gtk/helpline.c | 1 + tools/perf/ui/gtk/util.c | 1 + tools/perf/ui/tui/helpline.c | 1 + tools/perf/ui/util.c | 2 +- tools/perf/util/bpf-prologue.c | 1 + tools/perf/util/branch.c | 1 + tools/perf/util/callchain.c | 1 + tools/perf/util/cloexec.c | 2 ++ tools/perf/util/data.c | 1 + tools/perf/util/debug.c | 1 + tools/perf/util/debug.h | 6 ++---- tools/perf/util/dwarf-aux.c | 1 + tools/perf/util/dwarf-aux.h | 2 ++ tools/perf/util/env.c | 1 + tools/perf/util/evlist.c | 1 + tools/perf/util/expr.y | 2 ++ tools/perf/util/hist.c | 1 + tools/perf/util/intel-pt.c | 1 + tools/perf/util/llvm-utils.c | 1 + tools/perf/util/lzma.c | 1 + tools/perf/util/machine.c | 1 + tools/perf/util/map.c | 1 + tools/perf/util/ordered-events.c | 1 + tools/perf/util/parse-branch-options.c | 2 ++ tools/perf/util/perf-hooks.c | 1 + tools/perf/util/probe-finder.c | 1 + tools/perf/util/pstack.c | 1 + tools/perf/util/sort.c | 1 + tools/perf/util/strbuf.c | 4 ++++ tools/perf/util/symbol.c | 1 + tools/perf/util/target.c | 3 +++ tools/perf/util/thread-stack.c | 1 + tools/perf/util/util.c | 1 + tools/perf/util/values.c | 1 + tools/perf/util/zlib.c | 1 + 75 files changed, 104 insertions(+), 6 deletions(-) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index b74fd408d496..197041fcba25 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c index a769382fb644..59dd875fd5e4 100644 --- a/tools/perf/arch/common.c +++ b/tools/perf/arch/common.c @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include #include +#include #include #include "common.h" #include "../util/env.h" diff --git a/tools/perf/arch/x86/tests/bp-modify.c b/tools/perf/arch/x86/tests/bp-modify.c index f53e4406709f..adcacf1b6609 100644 --- a/tools/perf/arch/x86/tests/bp-modify.c +++ b/tools/perf/arch/x86/tests/bp-modify.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/arch/x86/tests/insn-x86.c b/tools/perf/arch/x86/tests/insn-x86.c index c3e5f4ab0d3e..d67bc0ffb70a 100644 --- a/tools/perf/arch/x86/tests/insn-x86.c +++ b/tools/perf/arch/x86/tests/insn-x86.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include "debug.h" #include "tests/tests.h" diff --git a/tools/perf/arch/x86/tests/rdpmc.c b/tools/perf/arch/x86/tests/rdpmc.c index 345a6a0a328b..6e67cee792b1 100644 --- a/tools/perf/arch/x86/tests/rdpmc.c +++ b/tools/perf/arch/x86/tests/rdpmc.c @@ -6,11 +6,13 @@ #include #include #include +#include #include #include "perf-sys.h" #include "debug.h" #include "tests/tests.h" #include "cloexec.h" +#include "event.h" #include "util.h" #include "arch-tests.h" diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c index 74a606ea42d3..99ea60211e16 100644 --- a/tools/perf/arch/x86/util/perf_regs.c +++ b/tools/perf/arch/x86/util/perf_regs.c @@ -7,6 +7,7 @@ #include "../../perf-sys.h" #include "../../util/perf_regs.h" #include "../../util/debug.h" +#include "../../util/event.h" const struct sample_reg sample_reg_masks[] = { SMPL_REG(AX, PERF_REG_X86_AX), diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 25a5f186dfde..d1ad694c67a2 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -20,6 +20,7 @@ #include #include "debug.h" #include "builtin.h" +#include #include #include "mem-events.h" #include "session.h" @@ -35,6 +36,7 @@ #include "thread.h" #include "mem2node.h" #include "symbol.h" +#include "ui/ui.h" #include "../perf.h" struct c2c_hists { diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c index edfc8f76f1bd..42d8157e047a 100644 --- a/tools/perf/builtin-config.c +++ b/tools/perf/builtin-config.c @@ -13,6 +13,7 @@ #include "util/debug.h" #include "util/config.h" #include +#include #include static bool use_system_config, use_user_config; diff --git a/tools/perf/builtin-data.c b/tools/perf/builtin-data.c index dde25d4ca56d..ca2fb44874e4 100644 --- a/tools/perf/builtin-data.c +++ b/tools/perf/builtin-data.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include +#include #include "builtin.h" #include "perf.h" #include "debug.h" diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index ae4a8ebf90d2..827e4800d862 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -24,6 +24,7 @@ #include "util/annotate.h" #include "util/map.h" #include +#include #include #include diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 7374f86833fd..2f8ea44c00c4 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -13,8 +13,10 @@ #include #include #include +#include #include "debug.h" +#include #include #include #include "evlist.h" @@ -24,7 +26,6 @@ #include "util/cap.h" #include "util/config.h" - #define DEFAULT_TRACER "function_graph" struct perf_ftrace { diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 641d4a3f93c3..3976aebe3677 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c @@ -4,7 +4,9 @@ * * Builtin help command */ +#include "util/cache.h" #include "util/config.h" +#include "util/strbuf.h" #include "builtin.h" #include #include "common-cmds.h" @@ -13,10 +15,12 @@ #include #include "util/debug.h" #include +#include #include #include #include #include +#include #include #include #include diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 46f828936120..7eec0da64c46 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -14,6 +14,7 @@ #include "util/callchain.h" #include "util/time-utils.h" +#include #include #include "util/trace-event.h" #include "util/data.h" diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c index dca0d33c1343..11afb760616b 100644 --- a/tools/perf/builtin-list.c +++ b/tools/perf/builtin-list.c @@ -16,6 +16,7 @@ #include "util/debug.h" #include "util/metricgroup.h" #include +#include static bool desc_flag = true; static bool details_flag; diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index f45fd7e9723e..8950c05ef8fd 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c @@ -26,6 +26,7 @@ #include "util/probe-finder.h" #include "util/probe-event.h" #include "util/probe-file.h" +#include #include #define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*" diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 56705d2a6bec..1447004eee8a 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 33c20e26b290..94e7e354cb16 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -45,6 +45,7 @@ #include "util/units.h" #include "util/branch.h" #include "util/util.h" +#include "ui/ui.h" #include #include @@ -53,6 +54,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index c3f95440e99c..5538b5886e35 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -45,6 +45,7 @@ #include "util/intlist.h" #include "util/parse-branch-options.h" #include "arch/common.h" +#include "ui/ui.h" #include "util/debug.h" #include "util/ordered-events.h" diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 105695033ebc..b1ec8ff52740 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -29,6 +29,7 @@ #include "util/event.h" #include "util/evlist.h" #include "util/evswitch.h" +#include #include #include "util/machine.h" #include "util/map.h" diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 237b9b3a1bf1..e0910637a82d 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -10,6 +10,7 @@ #include "builtin.h" #include "perf.h" +#include "util/cache.h" #include "util/env.h" #include #include "util/config.h" @@ -32,6 +33,7 @@ #include #include #include +#include #include const char perf_usage_string[] = diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c index 87dc3e1174af..a9599ab8c471 100644 --- a/tools/perf/tests/attr.c +++ b/tools/perf/tests/attr.c @@ -32,6 +32,7 @@ #include #include "../perf-sys.h" #include +#include "event.h" #include "tests.h" #define ENV "PERF_TEST_ATTR" diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c index b6f27ef9fb02..512288e9f547 100644 --- a/tools/perf/tests/backward-ring-buffer.c +++ b/tools/perf/tests/backward-ring-buffer.c @@ -10,6 +10,7 @@ #include "tests.h" #include "debug.h" #include +#include #define NR_ITERS 111 diff --git a/tools/perf/tests/bp_account.c b/tools/perf/tests/bp_account.c index c4a30318d7e0..016bba2c142d 100644 --- a/tools/perf/tests/bp_account.c +++ b/tools/perf/tests/bp_account.c @@ -19,6 +19,7 @@ #include "tests.h" #include "debug.h" +#include "event.h" #include "../perf-sys.h" #include "cloexec.h" diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c index 2d292f8fb3dd..c1c2c13de254 100644 --- a/tools/perf/tests/bp_signal.c +++ b/tools/perf/tests/bp_signal.c @@ -25,6 +25,7 @@ #include "tests.h" #include "debug.h" +#include "event.h" #include "perf-sys.h" #include "cloexec.h" diff --git a/tools/perf/tests/bp_signal_overflow.c b/tools/perf/tests/bp_signal_overflow.c index 101315a3b34f..eb4dbbddf4ff 100644 --- a/tools/perf/tests/bp_signal_overflow.c +++ b/tools/perf/tests/bp_signal_overflow.c @@ -24,6 +24,7 @@ #include "tests.h" #include "debug.h" +#include "event.h" #include "../perf-sys.h" #include "cloexec.h" diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c index 98642961fc63..9fc163b2acbb 100644 --- a/tools/perf/tests/bpf.c +++ b/tools/perf/tests/bpf.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include "tests.h" diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c index 714e3611352c..228d1618cf7d 100644 --- a/tools/perf/tests/event-times.c +++ b/tools/perf/tests/event-times.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c index ee1d88650e69..87843af4c118 100644 --- a/tools/perf/tests/expr.c +++ b/tools/perf/tests/expr.c @@ -3,6 +3,7 @@ #include "util/expr.h" #include "tests.h" #include +#include #include static int test(struct parse_ctx *ctx, const char *e, double val2) diff --git a/tools/perf/tests/kmod-path.c b/tools/perf/tests/kmod-path.c index 0579a70bbbff..e483210b176b 100644 --- a/tools/perf/tests/kmod-path.c +++ b/tools/perf/tests/kmod-path.c @@ -1,9 +1,11 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include "tests.h" #include "dso.h" #include "debug.h" +#include "event.h" static int test(const char *path, bool alloc_name, bool kmod, int comp, const char *name) diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index fe91350fd5ab..bdf77bfe1b80 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c @@ -13,6 +13,7 @@ #include "tests.h" #include #include +#include #include /* diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c index 4ae4dea07466..9171f77cd9cd 100644 --- a/tools/perf/tests/openat-syscall-all-cpus.c +++ b/tools/perf/tests/openat-syscall-all-cpus.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "evsel.h" #include "tests.h" diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c index 62492106fb5e..b71167b43dda 100644 --- a/tools/perf/tests/openat-syscall-tp-fields.c +++ b/tools/perf/tests/openat-syscall-tp-fields.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include #include #include diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c index 58df4bda5e12..5ebffae18605 100644 --- a/tools/perf/tests/openat-syscall.c +++ b/tools/perf/tests/openat-syscall.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c index 3a205f6f9363..e1b42292cf7f 100644 --- a/tools/perf/tests/perf-record.c +++ b/tools/perf/tests/perf-record.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include /* For the CLR_() macros */ #include diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c index a8ca29fe172b..0c09dc15a059 100644 --- a/tools/perf/tests/sample-parsing.c +++ b/tools/perf/tests/sample-parsing.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index 0e0e0627184e..f610e8c0a083 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c @@ -9,6 +9,7 @@ #include #include +#include #include static int exited; diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c index c19ec8849e77..39168c57943b 100644 --- a/tools/perf/tests/thread-map.c +++ b/tools/perf/tests/thread-map.c @@ -1,12 +1,19 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include #include "tests.h" #include "thread_map.h" #include "debug.h" +#include "event.h" #include +#include + +struct perf_sample; +struct perf_tool; +struct machine; #define NAME (const char *) "perf" #define NAMEUL (unsigned long) NAME diff --git a/tools/perf/tests/unit_number__scnprintf.c b/tools/perf/tests/unit_number__scnprintf.c index 2bb8cb0039c1..3721757435da 100644 --- a/tools/perf/tests/unit_number__scnprintf.c +++ b/tools/perf/tests/unit_number__scnprintf.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "tests.h" #include "units.h" #include "debug.h" diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c index 982ac55d69ea..d262d6639829 100644 --- a/tools/perf/tests/wp.c +++ b/tools/perf/tests/wp.c @@ -1,10 +1,13 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include +#include #include "tests.h" #include "debug.h" +#include "event.h" #include "cloexec.h" #include "../perf-sys.h" diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c index e63f3778d75c..77809c0fad02 100644 --- a/tools/perf/ui/browsers/scripts.c +++ b/tools/perf/ui/browsers/scripts.c @@ -9,6 +9,7 @@ #include "../browser.h" #include "../libslang.h" #include "config.h" +#include #include #define SCRIPT_NAMELEN 128 diff --git a/tools/perf/ui/gtk/helpline.c b/tools/perf/ui/gtk/helpline.c index fbf1ea9ce9a2..e166da9ec767 100644 --- a/tools/perf/ui/gtk/helpline.c +++ b/tools/perf/ui/gtk/helpline.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include "gtk.h" #include "../ui.h" diff --git a/tools/perf/ui/gtk/util.c b/tools/perf/ui/gtk/util.c index c28bdb7517ac..c2c558958b9c 100644 --- a/tools/perf/ui/gtk/util.c +++ b/tools/perf/ui/gtk/util.c @@ -3,6 +3,7 @@ #include "../../util/debug.h" #include "gtk.h" +#include #include #include diff --git a/tools/perf/ui/tui/helpline.c b/tools/perf/ui/tui/helpline.c index 93d6b7240285..1793c98653a5 100644 --- a/tools/perf/ui/tui/helpline.c +++ b/tools/perf/ui/tui/helpline.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "../../util/debug.h" #include "../helpline.h" diff --git a/tools/perf/ui/util.c b/tools/perf/ui/util.c index 9ed76e88a3e4..689b27c34246 100644 --- a/tools/perf/ui/util.c +++ b/tools/perf/ui/util.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include "util.h" #include "../util/debug.h" - +#include /* * Default error logging functions diff --git a/tools/perf/util/bpf-prologue.c b/tools/perf/util/bpf-prologue.c index 09e6c76e1c3b..b020a8678eb9 100644 --- a/tools/perf/util/bpf-prologue.c +++ b/tools/perf/util/bpf-prologue.c @@ -13,6 +13,7 @@ #include "bpf-prologue.h" #include "probe-finder.h" #include +#include #include #include diff --git a/tools/perf/util/branch.c b/tools/perf/util/branch.c index 02d6d839ff24..30642e1f2b1b 100644 --- a/tools/perf/util/branch.c +++ b/tools/perf/util/branch.c @@ -1,6 +1,7 @@ #include "util/util.h" #include "util/debug.h" #include "util/branch.h" +#include static bool cross_area(u64 addr1, u64 addr2, int size) { diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index a47d0e8c2434..76bf05b26d3b 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "asm/bug.h" diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c index 92d08198e64a..4e904fcb2783 100644 --- a/tools/perf/util/cloexec.c +++ b/tools/perf/util/cloexec.c @@ -4,10 +4,12 @@ #include "util.h" #include "../perf-sys.h" #include "cloexec.h" +#include "event.h" #include "asm/bug.h" #include "debug.h" #include #include +#include static unsigned long flag = PERF_FLAG_FD_CLOEXEC; diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 74aafe0df506..e75c3a279fe8 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include #include #include diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index c822c5943340..522887ee4c02 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -19,6 +19,7 @@ #include "print_binary.h" #include "util.h" #include "target.h" +#include "ui/helpline.h" #include diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index 77445dfc5c7d..b2deee987ffa 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h @@ -4,11 +4,7 @@ #define __PERF_DEBUG_H #include -#include #include -#include "event.h" -#include "../ui/helpline.h" -#include "../ui/progress.h" #include "../ui/util.h" extern int verbose; @@ -42,6 +38,8 @@ extern int debug_data_convert; #define STRERR_BUFSIZE 128 /* For the buffer size of str_error_r */ +union perf_event; + int dump_printf(const char *fmt, ...) __printf(1, 2); void trace_event(union perf_event *event); diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 03b2de1f5a35..df6cee5c071f 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -9,6 +9,7 @@ #include #include "debug.h" #include "dwarf-aux.h" +#include "strbuf.h" #include "string2.h" /** diff --git a/tools/perf/util/dwarf-aux.h b/tools/perf/util/dwarf-aux.h index 0489b0cf8e2c..f204e5892403 100644 --- a/tools/perf/util/dwarf-aux.h +++ b/tools/perf/util/dwarf-aux.h @@ -10,6 +10,8 @@ #include #include +struct strbuf; + /* Find the realpath of the target file */ const char *cu_find_realpath(Dwarf_Die *cu_die, const char *fname); diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index 571efb4f0351..3baca06786fb 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -9,6 +9,7 @@ #include #include #include +#include struct perf_env perf_env; diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 71b231c7097f..b5d6d6ec9a9b 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y index 432b8560cf51..f9a20a39b64a 100644 --- a/tools/perf/util/expr.y +++ b/tools/perf/util/expr.y @@ -2,9 +2,11 @@ %{ #include "util.h" #include "util/debug.h" +#include // strtod() #define IN_EXPR_Y 1 #include "expr.h" #include "smt.h" +#include #include #define MAXIDLEN 256 diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index adae4134e972..02ea2ee62814 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index 825e3690940d..9b56fb74bedf 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c index 9f0470ecbca9..55fb4b3b1157 100644 --- a/tools/perf/util/llvm-utils.c +++ b/tools/perf/util/llvm-utils.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "debug.h" #include "llvm-utils.h" diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c index b1dd29a9d915..397447066033 100644 --- a/tools/perf/util/lzma.c +++ b/tools/perf/util/lzma.c @@ -9,6 +9,7 @@ #include "compress.h" #include "util.h" #include "debug.h" +#include #include #define BUFSIZE 8192 diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index a1542b4c047b..6e9afe4e55dd 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -30,6 +30,7 @@ #include #include #include +#include #include static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock); diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 27b7b102e4a2..c75b20b93820 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -20,6 +20,7 @@ #include "namespaces.h" #include "unwind.h" #include "srccode.h" +#include "ui/ui.h" static void __maps__insert(struct maps *maps, struct map *map); static void __maps__insert_name(struct maps *maps, struct map *map); diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c index bb5f34b7ab44..359db2b1fcef 100644 --- a/tools/perf/util/ordered-events.c +++ b/tools/perf/util/ordered-events.c @@ -8,6 +8,7 @@ #include "session.h" #include "asm/bug.h" #include "debug.h" +#include "ui/progress.h" #define pr_N(n, fmt, ...) \ eprintf(n, debug_ordered_events, fmt, ##__VA_ARGS__) diff --git a/tools/perf/util/parse-branch-options.c b/tools/perf/util/parse-branch-options.c index 1430437b9d51..bb4aa88c50a8 100644 --- a/tools/perf/util/parse-branch-options.c +++ b/tools/perf/util/parse-branch-options.c @@ -1,8 +1,10 @@ // SPDX-License-Identifier: GPL-2.0 #include "util/debug.h" +#include "util/event.h" #include #include "util/parse-branch-options.h" #include +#include #define BRANCH_OPT(n, m) \ { .name = n, .mode = (m) } diff --git a/tools/perf/util/perf-hooks.c b/tools/perf/util/perf-hooks.c index 4f3aa8d99ef4..e635c594f773 100644 --- a/tools/perf/util/perf-hooks.c +++ b/tools/perf/util/perf-hooks.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 025fc4491993..505905fc21c5 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -24,6 +24,7 @@ #include "dso.h" #include "debug.h" #include "intlist.h" +#include "strbuf.h" #include "strlist.h" #include "symbol.h" #include "probe-finder.h" diff --git a/tools/perf/util/pstack.c b/tools/perf/util/pstack.c index 28de8a4c2ce8..80ff41fc45be 100644 --- a/tools/perf/util/pstack.c +++ b/tools/perf/util/pstack.c @@ -10,6 +10,7 @@ #include #include #include +#include struct pstack { unsigned short top; diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 23d0ab7c801c..035355a9945e 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -22,6 +22,7 @@ #include "annotate.h" #include "time-utils.h" #include +#include regex_t parent_regex; const char default_parent_pattern[] = "^sys_|^do_page_fault"; diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c index 0afdbf38a2b2..a64a37628f12 100644 --- a/tools/perf/util/strbuf.c +++ b/tools/perf/util/strbuf.c @@ -1,8 +1,12 @@ // SPDX-License-Identifier: GPL-2.0 +#include "cache.h" #include "debug.h" +#include "strbuf.h" #include +#include #include #include +#include #include #include diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 035f2e75728c..c37cca690864 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/util/target.c b/tools/perf/util/target.c index 3adc65480349..565f7aef7e6c 100644 --- a/tools/perf/util/target.c +++ b/tools/perf/util/target.c @@ -10,8 +10,11 @@ #include "debug.h" #include +#include #include #include +#include +#include enum target_errno target__validate(struct target *target) { diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c index 15134ac9b8f1..cd8a948d03ec 100644 --- a/tools/perf/util/thread-stack.c +++ b/tools/perf/util/thread-stack.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "thread.h" #include "event.h" #include "machine.h" diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 607daec22943..32322a20a68b 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include "util.h" #include "debug.h" +#include "event.h" #include "namespaces.h" #include #include diff --git a/tools/perf/util/values.c b/tools/perf/util/values.c index c59154e2d124..b9823f414f10 100644 --- a/tools/perf/util/values.c +++ b/tools/perf/util/values.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include diff --git a/tools/perf/util/zlib.c b/tools/perf/util/zlib.c index 512ad7c09b13..59d456f716e9 100644 --- a/tools/perf/util/zlib.c +++ b/tools/perf/util/zlib.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include #include #include From b6b5574b80d6ce6ca87ae3ea1e97cff1bf730f2e Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 29 Aug 2019 17:10:59 -0300 Subject: [PATCH 17/47] perf env: Remove env.h from other headers where just a fwd decl is needed And fixup the fallout of c files not building due to now missing headers. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-sw8k3kpla98pr3rqypbjk9hf@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/common.h | 4 +++- tools/perf/tests/mem2node.c | 2 ++ tools/perf/util/cputopo.h | 1 - tools/perf/util/mem2node.c | 2 ++ tools/perf/util/mem2node.h | 3 ++- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/perf/arch/common.h b/tools/perf/arch/common.h index c298a446d1f6..e965ed8bb328 100644 --- a/tools/perf/arch/common.h +++ b/tools/perf/arch/common.h @@ -2,7 +2,9 @@ #ifndef ARCH_PERF_COMMON_H #define ARCH_PERF_COMMON_H -#include "../util/env.h" +#include + +struct perf_env; int perf_env__lookup_objdump(struct perf_env *env, const char **path); bool perf_env__single_address_space(struct perf_env *env); diff --git a/tools/perf/tests/mem2node.c b/tools/perf/tests/mem2node.c index 73b2855acaf4..7672ade70f20 100644 --- a/tools/perf/tests/mem2node.c +++ b/tools/perf/tests/mem2node.c @@ -1,10 +1,12 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include #include #include "cpumap.h" #include "debug.h" +#include "env.h" #include "mem2node.h" #include "tests.h" diff --git a/tools/perf/util/cputopo.h b/tools/perf/util/cputopo.h index bae2f1d41856..7bf6b811f715 100644 --- a/tools/perf/util/cputopo.h +++ b/tools/perf/util/cputopo.h @@ -3,7 +3,6 @@ #define __PERF_CPUTOPO_H #include -#include "env.h" struct cpu_topology { u32 core_sib; diff --git a/tools/perf/util/mem2node.c b/tools/perf/util/mem2node.c index 14fb9e72aeeb..797d86a1ab09 100644 --- a/tools/perf/util/mem2node.c +++ b/tools/perf/util/mem2node.c @@ -1,8 +1,10 @@ #include #include #include +#include #include #include "debug.h" +#include "env.h" #include "mem2node.h" struct phys_entry { diff --git a/tools/perf/util/mem2node.h b/tools/perf/util/mem2node.h index 59c4752a2181..8dfa2b58d0cd 100644 --- a/tools/perf/util/mem2node.h +++ b/tools/perf/util/mem2node.h @@ -2,8 +2,9 @@ #define __MEM2NODE_H #include -#include "env.h" +#include +struct perf_env; struct phys_entry; struct mem2node { From 4cb3c6d546aa5493a960d05eb73bad8e69a58574 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 29 Aug 2019 17:19:02 -0300 Subject: [PATCH 18/47] perf event: Remove needless include directives from event.h bpf.h and build-id.h are not needed at all in event.h, remove them. And fixup the fallout of files that were getting needed stuff from this now pruned include. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-rdm3dgtlrndmmnlc4bafsg3b@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/powerpc/util/unwind-libdw.c | 1 + tools/perf/arch/x86/util/perf_regs.c | 1 + tools/perf/perf.c | 1 + tools/perf/util/bpf-event.h | 1 + tools/perf/util/callchain.h | 1 + tools/perf/util/config.c | 2 ++ tools/perf/util/debug.c | 1 + tools/perf/util/event.h | 18 ++++++++++++------ 8 files changed, 20 insertions(+), 6 deletions(-) diff --git a/tools/perf/arch/powerpc/util/unwind-libdw.c b/tools/perf/arch/powerpc/util/unwind-libdw.c index 7a1f05ef2fc0..abf2dbc7f829 100644 --- a/tools/perf/arch/powerpc/util/unwind-libdw.c +++ b/tools/perf/arch/powerpc/util/unwind-libdw.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include "../../util/unwind-libdw.h" #include "../../util/perf_regs.h" #include "../../util/event.h" diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c index 99ea60211e16..c218b83e063b 100644 --- a/tools/perf/arch/x86/util/perf_regs.c +++ b/tools/perf/arch/x86/util/perf_regs.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "../../perf-sys.h" diff --git a/tools/perf/perf.c b/tools/perf/perf.c index e0910637a82d..8763b2c0fbfd 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -10,6 +10,7 @@ #include "builtin.h" #include "perf.h" +#include "util/build-id.h" #include "util/cache.h" #include "util/env.h" #include diff --git a/tools/perf/util/bpf-event.h b/tools/perf/util/bpf-event.h index 417b78835ea0..a01c2fd68c03 100644 --- a/tools/perf/util/bpf-event.h +++ b/tools/perf/util/bpf-event.h @@ -13,6 +13,7 @@ struct machine; union perf_event; struct perf_env; struct perf_sample; +struct perf_session; struct record_opts; struct evlist; struct target; diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index 45b9ed49e2b1..b042ceef4114 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h @@ -8,6 +8,7 @@ #include "map_symbol.h" #include "branch.h" +struct evsel; struct map; #define HELP_PAD "\t\t\t\t" diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index eb5308c41ed1..7ebf9e31ae22 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -17,6 +17,8 @@ #include "util/event.h" /* proc_map_timeout */ #include "util/hist.h" /* perf_hist_config */ #include "util/llvm-utils.h" /* perf_llvm_config */ +#include "build-id.h" +#include "debug.h" #include "config.h" #include "debug.h" #include diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 522887ee4c02..143d379d4608 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #ifdef HAVE_BACKTRACE_SUPPORT #include diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index f56d268f06e3..006aa432be19 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -1,17 +1,23 @@ /* SPDX-License-Identifier: GPL-2.0 */ #ifndef __PERF_RECORD_H #define __PERF_RECORD_H - -#include +/* + * The linux/stddef.h isn't need here, but is needed for __always_inline used + * in files included from uapi/linux/perf_event.h such as + * /usr/include/linux/swab.h and /usr/include/linux/byteorder/little_endian.h, + * detected in at least musl libc, used in Alpine Linux. -acme + */ #include -#include -#include -#include +#include #include +#include -#include "build-id.h" #include "perf_regs.h" +struct dso; +struct machine; +struct perf_event_attr; + #ifdef __LP64__ /* * /usr/include/inttypes.h uses just 'lu' for PRIu64, but we end up defining From 38847db9740a984e8538ce2573cbc0fc7edf22b3 Mon Sep 17 00:00:00 2001 From: Tzvetomir Stoyanov Date: Mon, 5 Aug 2019 16:43:13 -0400 Subject: [PATCH 19/47] libtraceevent, perf tools: Changes in tep_print_event_* APIs Libtraceevent APIs for printing various trace events information are complicated, there are complex extra parameters. To control the way event information is printed, the user should call a set of functions in a specific sequence. These APIs are reimplemented to provide a more simple interface for printing event information. Removed APIs: tep_print_event_task() tep_print_event_time() tep_print_event_data() tep_event_info() tep_is_latency_format() tep_set_latency_format() tep_data_latency_format() tep_set_print_raw() A new API for printing event information is introduced: void tep_print_event(struct tep_handle *tep, struct trace_seq *s, struct tep_record *record, const char *fmt, ...); where "fmt" is a printf-like format string, followed by the event fields to be printed. Supported fields: TEP_PRINT_PID, "%d" - event PID TEP_PRINT_CPU, "%d" - event CPU TEP_PRINT_COMM, "%s" - event command string TEP_PRINT_NAME, "%s" - event name TEP_PRINT_LATENCY, "%s" - event latency TEP_PRINT_TIME, %d - event time stamp. A divisor and precision can be specified as part of this format string: "%precision.divisord". Example: "%3.1000d" - divide the time by 1000 and print the first 3 digits before the dot. Thus, the time stamp "123456000" will be printed as "123.456" TEP_PRINT_INFO, "%s" - event information. TEP_PRINT_INFO_RAW, "%s" - event information, in raw format. Example: tep_print_event(tep, s, record, "%16s-%-5d [%03d] %s %6.1000d %s %s", TEP_PRINT_COMM, TEP_PRINT_PID, TEP_PRINT_CPU, TEP_PRINT_LATENCY, TEP_PRINT_TIME, TEP_PRINT_NAME, TEP_PRINT_INFO); Output: ls-11314 [005] d.h. 185207.366383 function __wake_up Signed-off-by: Tzvetomir Stoyanov Cc: Andrew Morton Cc: Jiri Olsa Cc: Namhyung Kim Cc: linux-trace-devel@vger.kernel.org Cc: Patrick McLean Link: http://lore.kernel.org/linux-trace-devel/20190801074959.22023-2-tz.stoyanov@gmail.com Link: http://lore.kernel.org/lkml/20190805204355.041132030@goodmis.org Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse-api.c | 40 --- tools/lib/traceevent/event-parse-local.h | 4 - tools/lib/traceevent/event-parse.c | 346 +++++++++++++---------- tools/lib/traceevent/event-parse.h | 29 +- tools/perf/builtin-kmem.c | 3 +- tools/perf/util/sort.c | 3 +- tools/perf/util/trace-event-parse.c | 2 +- 7 files changed, 215 insertions(+), 212 deletions(-) diff --git a/tools/lib/traceevent/event-parse-api.c b/tools/lib/traceevent/event-parse-api.c index 988587840c80..4faf52a65791 100644 --- a/tools/lib/traceevent/event-parse-api.c +++ b/tools/lib/traceevent/event-parse-api.c @@ -302,33 +302,6 @@ void tep_set_local_bigendian(struct tep_handle *tep, enum tep_endian endian) tep->host_bigendian = endian; } -/** - * tep_is_latency_format - get if the latency output format is configured - * @tep: a handle to the tep_handle - * - * This returns true if the latency output format is configured - * If @tep is NULL, false is returned. - */ -bool tep_is_latency_format(struct tep_handle *tep) -{ - if (tep) - return (tep->latency_format); - return false; -} - -/** - * tep_set_latency_format - set the latency output format - * @tep: a handle to the tep_handle - * @lat: non zero for latency output format - * - * This sets the latency output format - */ -void tep_set_latency_format(struct tep_handle *tep, int lat) -{ - if (tep) - tep->latency_format = lat; -} - /** * tep_is_old_format - get if an old kernel is used * @tep: a handle to the tep_handle @@ -344,19 +317,6 @@ bool tep_is_old_format(struct tep_handle *tep) return false; } -/** - * tep_set_print_raw - set a flag to force print in raw format - * @tep: a handle to the tep_handle - * @print_raw: the new value of the print_raw flag - * - * This sets a flag to force print in raw format - */ -void tep_set_print_raw(struct tep_handle *tep, int print_raw) -{ - if (tep) - tep->print_raw = print_raw; -} - /** * tep_set_test_filters - set a flag to test a filter string * @tep: a handle to the tep_handle diff --git a/tools/lib/traceevent/event-parse-local.h b/tools/lib/traceevent/event-parse-local.h index 09aa142f7fdd..6e58ee1fe7c8 100644 --- a/tools/lib/traceevent/event-parse-local.h +++ b/tools/lib/traceevent/event-parse-local.h @@ -28,8 +28,6 @@ struct tep_handle { enum tep_endian file_bigendian; enum tep_endian host_bigendian; - int latency_format; - int old_format; int cpus; @@ -70,8 +68,6 @@ struct tep_handle { int ld_offset; int ld_size; - int print_raw; - int test_filters; int flags; diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 3e83636076b2..d1085aab9c43 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -5212,24 +5212,20 @@ out_failed: } } -/** - * tep_data_latency_format - parse the data for the latency format - * @tep: a handle to the trace event parser context - * @s: the trace_seq to write to - * @record: the record to read from - * +/* * This parses out the Latency format (interrupts disabled, * need rescheduling, in hard/soft interrupt, preempt count * and lock depth) and places it into the trace_seq. */ -void tep_data_latency_format(struct tep_handle *tep, - struct trace_seq *s, struct tep_record *record) +static void data_latency_format(struct tep_handle *tep, struct trace_seq *s, + char *format, struct tep_record *record) { static int check_lock_depth = 1; static int check_migrate_disable = 1; static int lock_depth_exists; static int migrate_disable_exists; unsigned int lat_flags; + struct trace_seq sq; unsigned int pc; int lock_depth = 0; int migrate_disable = 0; @@ -5237,6 +5233,7 @@ void tep_data_latency_format(struct tep_handle *tep, int softirq; void *data = record->data; + trace_seq_init(&sq); lat_flags = parse_common_flags(tep, data); pc = parse_common_pc(tep, data); /* lock_depth may not always exist */ @@ -5264,7 +5261,7 @@ void tep_data_latency_format(struct tep_handle *tep, hardirq = lat_flags & TRACE_FLAG_HARDIRQ; softirq = lat_flags & TRACE_FLAG_SOFTIRQ; - trace_seq_printf(s, "%c%c%c", + trace_seq_printf(&sq, "%c%c%c", (lat_flags & TRACE_FLAG_IRQS_OFF) ? 'd' : (lat_flags & TRACE_FLAG_IRQS_NOSUPPORT) ? 'X' : '.', @@ -5274,24 +5271,32 @@ void tep_data_latency_format(struct tep_handle *tep, hardirq ? 'h' : softirq ? 's' : '.'); if (pc) - trace_seq_printf(s, "%x", pc); + trace_seq_printf(&sq, "%x", pc); else - trace_seq_putc(s, '.'); + trace_seq_printf(&sq, "."); if (migrate_disable_exists) { if (migrate_disable < 0) - trace_seq_putc(s, '.'); + trace_seq_printf(&sq, "."); else - trace_seq_printf(s, "%d", migrate_disable); + trace_seq_printf(&sq, "%d", migrate_disable); } if (lock_depth_exists) { if (lock_depth < 0) - trace_seq_putc(s, '.'); + trace_seq_printf(&sq, "."); else - trace_seq_printf(s, "%d", lock_depth); + trace_seq_printf(&sq, "%d", lock_depth); } + if (sq.state == TRACE_SEQ__MEM_ALLOC_FAILED) { + s->state = TRACE_SEQ__MEM_ALLOC_FAILED; + return; + } + + trace_seq_terminate(&sq); + trace_seq_puts(s, sq.buffer); + trace_seq_destroy(&sq); trace_seq_terminate(s); } @@ -5452,21 +5457,16 @@ int tep_cmdline_pid(struct tep_handle *tep, struct tep_cmdline *cmdline) return cmdline->pid; } -/** - * tep_event_info - parse the data into the print format - * @s: the trace_seq to write to - * @event: the handle to the event - * @record: the record to read from - * +/* * This parses the raw @data using the given @event information and * writes the print format into the trace_seq. */ -void tep_event_info(struct trace_seq *s, struct tep_event *event, - struct tep_record *record) +static void print_event_info(struct trace_seq *s, char *format, bool raw, + struct tep_event *event, struct tep_record *record) { int print_pretty = 1; - if (event->tep->print_raw || (event->flags & TEP_EVENT_FL_PRINTRAW)) + if (raw || (event->flags & TEP_EVENT_FL_PRINTRAW)) tep_print_fields(s, record->data, record->size, event); else { @@ -5481,20 +5481,6 @@ void tep_event_info(struct trace_seq *s, struct tep_event *event, trace_seq_terminate(s); } -static bool is_timestamp_in_us(char *trace_clock, bool use_trace_clock) -{ - if (!trace_clock || !use_trace_clock) - return true; - - if (!strcmp(trace_clock, "local") || !strcmp(trace_clock, "global") - || !strcmp(trace_clock, "uptime") || !strcmp(trace_clock, "perf") - || !strncmp(trace_clock, "mono", 4)) - return true; - - /* trace_clock is setting in tsc or counter mode */ - return false; -} - /** * tep_find_event_by_record - return the event from a given record * @tep: a handle to the trace event parser context @@ -5518,129 +5504,195 @@ tep_find_event_by_record(struct tep_handle *tep, struct tep_record *record) return tep_find_event(tep, type); } -/** - * tep_print_event_task - Write the event task comm, pid and CPU - * @tep: a handle to the trace event parser context - * @s: the trace_seq to write to - * @event: the handle to the record's event - * @record: The record to get the event from - * - * Writes the tasks comm, pid and CPU to @s. +/* + * Writes the timestamp of the record into @s. Time divisor and precision can be + * specified as part of printf @format string. Example: + * "%3.1000d" - divide the time by 1000 and print the first 3 digits + * before the dot. Thus, the timestamp "123456000" will be printed as + * "123.456" */ -void tep_print_event_task(struct tep_handle *tep, struct trace_seq *s, - struct tep_event *event, - struct tep_record *record) +static void print_event_time(struct tep_handle *tep, struct trace_seq *s, + char *format, struct tep_event *event, + struct tep_record *record) +{ + unsigned long long time; + char *divstr; + int prec = 0, pr; + int div = 0; + int p10 = 1; + + if (isdigit(*(format + 1))) + prec = atoi(format + 1); + divstr = strchr(format, '.'); + if (divstr && isdigit(*(divstr + 1))) + div = atoi(divstr + 1); + time = record->ts; + if (div) + time /= div; + pr = prec; + while (pr--) + p10 *= 10; + + if (p10 > 1 && p10 < time) + trace_seq_printf(s, "%5llu.%0*llu", time / p10, prec, time % p10); + else + trace_seq_printf(s, "%12llu\n", time); +} + +struct print_event_type { + enum { + EVENT_TYPE_INT = 1, + EVENT_TYPE_STRING, + EVENT_TYPE_UNKNOWN, + } type; + char format[32]; +}; + +static void print_string(struct tep_handle *tep, struct trace_seq *s, + struct tep_record *record, struct tep_event *event, + const char *arg, struct print_event_type *type) { - void *data = record->data; const char *comm; int pid; - pid = parse_common_pid(tep, data); - comm = find_cmdline(tep, pid); - - if (tep->latency_format) - trace_seq_printf(s, "%8.8s-%-5d %3d", comm, pid, record->cpu); - else - trace_seq_printf(s, "%16s-%-5d [%03d]", comm, pid, record->cpu); -} - -/** - * tep_print_event_time - Write the event timestamp - * @tep: a handle to the trace event parser context - * @s: the trace_seq to write to - * @event: the handle to the record's event - * @record: The record to get the event from - * @use_trace_clock: Set to parse according to the @tep->trace_clock - * - * Writes the timestamp of the record into @s. - */ -void tep_print_event_time(struct tep_handle *tep, struct trace_seq *s, - struct tep_event *event, - struct tep_record *record, - bool use_trace_clock) -{ - unsigned long secs; - unsigned long usecs; - unsigned long nsecs; - int p; - bool use_usec_format; - - use_usec_format = is_timestamp_in_us(tep->trace_clock, use_trace_clock); - if (use_usec_format) { - secs = record->ts / NSEC_PER_SEC; - nsecs = record->ts - secs * NSEC_PER_SEC; + if (strncmp(arg, TEP_PRINT_LATENCY, strlen(TEP_PRINT_LATENCY)) == 0) { + data_latency_format(tep, s, type->format, record); + } else if (strncmp(arg, TEP_PRINT_COMM, strlen(TEP_PRINT_COMM)) == 0) { + pid = parse_common_pid(tep, record->data); + comm = find_cmdline(tep, pid); + trace_seq_printf(s, type->format, comm); + } else if (strncmp(arg, TEP_PRINT_INFO_RAW, strlen(TEP_PRINT_INFO_RAW)) == 0) { + print_event_info(s, type->format, true, event, record); + } else if (strncmp(arg, TEP_PRINT_INFO, strlen(TEP_PRINT_INFO)) == 0) { + print_event_info(s, type->format, false, event, record); + } else if (strncmp(arg, TEP_PRINT_NAME, strlen(TEP_PRINT_NAME)) == 0) { + trace_seq_printf(s, type->format, event->name); + } else { + trace_seq_printf(s, "[UNKNOWN TEP TYPE %s]", arg); } - if (tep->latency_format) { - tep_data_latency_format(tep, s, record); - } - - if (use_usec_format) { - if (tep->flags & TEP_NSEC_OUTPUT) { - usecs = nsecs; - p = 9; - } else { - usecs = (nsecs + 500) / NSEC_PER_USEC; - /* To avoid usecs larger than 1 sec */ - if (usecs >= USEC_PER_SEC) { - usecs -= USEC_PER_SEC; - secs++; - } - p = 6; - } - - trace_seq_printf(s, " %5lu.%0*lu:", secs, p, usecs); - } else - trace_seq_printf(s, " %12llu:", record->ts); } -/** - * tep_print_event_data - Write the event data section - * @tep: a handle to the trace event parser context - * @s: the trace_seq to write to - * @event: the handle to the record's event - * @record: The record to get the event from - * - * Writes the parsing of the record's data to @s. - */ -void tep_print_event_data(struct tep_handle *tep, struct trace_seq *s, - struct tep_event *event, - struct tep_record *record) +static void print_int(struct tep_handle *tep, struct trace_seq *s, + struct tep_record *record, struct tep_event *event, + int arg, struct print_event_type *type) { - static const char *spaces = " "; /* 20 spaces */ - int len; + int param; - trace_seq_printf(s, " %s: ", event->name); - - /* Space out the event names evenly. */ - len = strlen(event->name); - if (len < 20) - trace_seq_printf(s, "%.*s", 20 - len, spaces); - - tep_event_info(s, event, record); -} - -void tep_print_event(struct tep_handle *tep, struct trace_seq *s, - struct tep_record *record, bool use_trace_clock) -{ - struct tep_event *event; - - event = tep_find_event_by_record(tep, record); - if (!event) { - int i; - int type = trace_parse_common_type(tep, record->data); - - do_warning("ug! no event found for type %d", type); - trace_seq_printf(s, "[UNKNOWN TYPE %d]", type); - for (i = 0; i < record->size; i++) - trace_seq_printf(s, " %02x", - ((unsigned char *)record->data)[i]); + switch (arg) { + case TEP_PRINT_CPU: + param = record->cpu; + break; + case TEP_PRINT_PID: + param = parse_common_pid(tep, record->data); + break; + case TEP_PRINT_TIME: + return print_event_time(tep, s, type->format, event, record); + default: return; } + trace_seq_printf(s, type->format, param); +} - tep_print_event_task(tep, s, event, record); - tep_print_event_time(tep, s, event, record, use_trace_clock); - tep_print_event_data(tep, s, event, record); +static int tep_print_event_param_type(char *format, + struct print_event_type *type) +{ + char *str = format + 1; + int i = 1; + + type->type = EVENT_TYPE_UNKNOWN; + while (*str) { + switch (*str) { + case 'd': + case 'u': + case 'i': + case 'x': + case 'X': + case 'o': + type->type = EVENT_TYPE_INT; + break; + case 's': + type->type = EVENT_TYPE_STRING; + break; + } + str++; + i++; + if (type->type != EVENT_TYPE_UNKNOWN) + break; + } + memset(type->format, 0, 32); + memcpy(type->format, format, i < 32 ? i : 31); + return i; +} + +/** + * tep_print_event - Write various event information + * @tep: a handle to the trace event parser context + * @s: the trace_seq to write to + * @record: The record to get the event from + * @format: a printf format string. Supported event fileds: + * TEP_PRINT_PID, "%d" - event PID + * TEP_PRINT_CPU, "%d" - event CPU + * TEP_PRINT_COMM, "%s" - event command string + * TEP_PRINT_NAME, "%s" - event name + * TEP_PRINT_LATENCY, "%s" - event latency + * TEP_PRINT_TIME, %d - event time stamp. A divisor and precision + * can be specified as part of this format string: + * "%precision.divisord". Example: + * "%3.1000d" - divide the time by 1000 and print the first + * 3 digits before the dot. Thus, the time stamp + * "123456000" will be printed as "123.456" + * TEP_PRINT_INFO, "%s" - event information. If any width is specified in + * the format string, the event information will be printed + * in raw format. + * Writes the specified event information into @s. + */ +void tep_print_event(struct tep_handle *tep, struct trace_seq *s, + struct tep_record *record, const char *fmt, ...) +{ + struct print_event_type type; + char *format = strdup(fmt); + char *current = format; + char *str = format; + int offset; + va_list args; + struct tep_event *event; + + if (!format) + return; + + event = tep_find_event_by_record(tep, record); + va_start(args, fmt); + while (*current) { + current = strchr(str, '%'); + if (!current) { + trace_seq_puts(s, str); + break; + } + memset(&type, 0, sizeof(type)); + offset = tep_print_event_param_type(current, &type); + *current = '\0'; + trace_seq_puts(s, str); + current += offset; + switch (type.type) { + case EVENT_TYPE_STRING: + print_string(tep, s, record, event, + va_arg(args, char*), &type); + break; + case EVENT_TYPE_INT: + print_int(tep, s, record, event, + va_arg(args, int), &type); + break; + case EVENT_TYPE_UNKNOWN: + default: + trace_seq_printf(s, "[UNKNOWN TYPE]"); + break; + } + str = current; + + } + va_end(args); + free(format); } static int events_id_cmp(const void *a, const void *b) diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 642f68ab5fb2..cf7f302eb44a 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -442,18 +442,18 @@ int tep_register_print_string(struct tep_handle *tep, const char *fmt, unsigned long long addr); bool tep_is_pid_registered(struct tep_handle *tep, int pid); -void tep_print_event_task(struct tep_handle *tep, struct trace_seq *s, - struct tep_event *event, - struct tep_record *record); -void tep_print_event_time(struct tep_handle *tep, struct trace_seq *s, - struct tep_event *event, - struct tep_record *record, - bool use_trace_clock); -void tep_print_event_data(struct tep_handle *tep, struct trace_seq *s, - struct tep_event *event, - struct tep_record *record); +#define TEP_PRINT_INFO "INFO" +#define TEP_PRINT_INFO_RAW "INFO_RAW" +#define TEP_PRINT_COMM "COMM" +#define TEP_PRINT_LATENCY "LATENCY" +#define TEP_PRINT_NAME "NAME" +#define TEP_PRINT_PID 1U +#define TEP_PRINT_TIME 2U +#define TEP_PRINT_CPU 3U + void tep_print_event(struct tep_handle *tep, struct trace_seq *s, - struct tep_record *record, bool use_trace_clock); + struct tep_record *record, const char *fmt, ...) + __attribute__ ((format (printf, 4, 5))); int tep_parse_header_page(struct tep_handle *tep, char *buf, unsigned long size, int long_size); @@ -525,8 +525,6 @@ tep_find_event_by_name(struct tep_handle *tep, const char *sys, const char *name struct tep_event * tep_find_event_by_record(struct tep_handle *tep, struct tep_record *record); -void tep_data_latency_format(struct tep_handle *tep, - struct trace_seq *s, struct tep_record *record); int tep_data_type(struct tep_handle *tep, struct tep_record *rec); int tep_data_pid(struct tep_handle *tep, struct tep_record *rec); int tep_data_preempt_count(struct tep_handle *tep, struct tep_record *rec); @@ -541,8 +539,6 @@ void tep_print_field(struct trace_seq *s, void *data, struct tep_format_field *field); void tep_print_fields(struct trace_seq *s, void *data, int size __maybe_unused, struct tep_event *event); -void tep_event_info(struct trace_seq *s, struct tep_event *event, - struct tep_record *record); int tep_strerror(struct tep_handle *tep, enum tep_errno errnum, char *buf, size_t buflen); @@ -566,12 +562,9 @@ bool tep_is_file_bigendian(struct tep_handle *tep); void tep_set_file_bigendian(struct tep_handle *tep, enum tep_endian endian); bool tep_is_local_bigendian(struct tep_handle *tep); void tep_set_local_bigendian(struct tep_handle *tep, enum tep_endian endian); -bool tep_is_latency_format(struct tep_handle *tep); -void tep_set_latency_format(struct tep_handle *tep, int lat); int tep_get_header_page_size(struct tep_handle *tep); int tep_get_header_timestamp_size(struct tep_handle *tep); bool tep_is_old_format(struct tep_handle *tep); -void tep_set_print_raw(struct tep_handle *tep, int print_raw); void tep_set_test_filters(struct tep_handle *tep, int test_filters); struct tep_handle *tep_alloc(void); diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 7eec0da64c46..378b09c910a8 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -750,7 +750,8 @@ static int parse_gfp_flags(struct evsel *evsel, struct perf_sample *sample, } trace_seq_init(&seq); - tep_event_info(&seq, evsel->tp_format, &record); + tep_print_event(evsel->tp_format->tep, + &seq, &record, "%s", TEP_PRINT_INFO); str = strtok_r(seq.buffer, " ", &pos); while (str) { diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 035355a9945e..4650704540c9 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -709,7 +709,8 @@ static char *get_trace_output(struct hist_entry *he) tep_print_fields(&seq, he->raw_data, he->raw_size, evsel->tp_format); } else { - tep_event_info(&seq, evsel->tp_format, &rec); + tep_print_event(evsel->tp_format->tep, + &seq, &rec, "%s", TEP_PRINT_INFO); } /* * Trim the buffer, it starts at 4KB and we're not going to diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 8e31a63045c3..5d6bfc70b210 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -109,7 +109,7 @@ void event_format__fprintf(struct tep_event *event, record.data = data; trace_seq_init(&s); - tep_event_info(&s, event, &record); + tep_print_event(event->tep, &s, &record, "%s", TEP_PRINT_INFO); trace_seq_do_fprintf(&s, fp); trace_seq_destroy(&s); } From 5d6552ab3b71fac48a9c7452c7014d37ca80b17f Mon Sep 17 00:00:00 2001 From: Tzvetomir Stoyanov Date: Mon, 5 Aug 2019 16:43:14 -0400 Subject: [PATCH 20/47] libtraceevent: Remove tep_register_trace_clock() The tep_register_trace_clock() API is used to instruct the traceevent library how to print the event time stamps. As event print interface if redesigned, this API is not needed any more. The new event print API is flexible and the user can specify how the time stamps are printed. Signed-off-by: Tzvetomir Stoyanov Cc: Andrew Morton Cc: Jiri Olsa Cc: Namhyung Kim Cc: Patrick McLean Cc: linux-trace-devel@vger.kernel.org Link: http://lore.kernel.org/linux-trace-devel/20190801074959.22023-3-tz.stoyanov@gmail.com Link: http://lore.kernel.org/lkml/20190805204355.195042846@goodmis.org Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse-local.h | 2 -- tools/lib/traceevent/event-parse.c | 11 ----------- tools/lib/traceevent/event-parse.h | 1 - 3 files changed, 14 deletions(-) diff --git a/tools/lib/traceevent/event-parse-local.h b/tools/lib/traceevent/event-parse-local.h index 6e58ee1fe7c8..cee469803a34 100644 --- a/tools/lib/traceevent/event-parse-local.h +++ b/tools/lib/traceevent/event-parse-local.h @@ -81,8 +81,6 @@ struct tep_handle { /* cache */ struct tep_event *last_event; - - char *trace_clock; }; void tep_free_event(struct tep_event *event); diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index d1085aab9c43..bb22238debfe 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -393,16 +393,6 @@ int tep_override_comm(struct tep_handle *tep, const char *comm, int pid) return _tep_register_comm(tep, comm, pid, true); } -int tep_register_trace_clock(struct tep_handle *tep, const char *trace_clock) -{ - tep->trace_clock = strdup(trace_clock); - if (!tep->trace_clock) { - errno = ENOMEM; - return -1; - } - return 0; -} - struct func_map { unsigned long long addr; char *func; @@ -7057,7 +7047,6 @@ void tep_free(struct tep_handle *tep) free_handler(handle); } - free(tep->trace_clock); free(tep->events); free(tep->sort_events); free(tep->func_resolver); diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index cf7f302eb44a..d438ee44289f 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -435,7 +435,6 @@ int tep_set_function_resolver(struct tep_handle *tep, void tep_reset_function_resolver(struct tep_handle *tep); int tep_register_comm(struct tep_handle *tep, const char *comm, int pid); int tep_override_comm(struct tep_handle *tep, const char *comm, int pid); -int tep_register_trace_clock(struct tep_handle *tep, const char *trace_clock); int tep_register_function(struct tep_handle *tep, char *name, unsigned long long addr, char *mod); int tep_register_print_string(struct tep_handle *tep, const char *fmt, From e97fd1383cd77c467d2aed7fa4e596789df83977 Mon Sep 17 00:00:00 2001 From: Tzvetomir Stoyanov Date: Mon, 5 Aug 2019 16:43:15 -0400 Subject: [PATCH 21/47] libtraceevent: Change users plugin directory To be compliant with XDG user directory layout, the user's plugin directory is changed from ~/.traceevent/plugins to ~/.local/lib/traceevent/plugins/ Suggested-by: Patrick McLean Signed-off-by: Tzvetomir Stoyanov Cc: Andrew Morton Cc: Jiri Olsa Cc: Namhyung Kim Cc: Patrick McLean Cc: linux-trace-devel@vger.kernel.org Link: https://lore.kernel.org/linux-trace-devel/20190313144206.41e75cf8@patrickm/ Link: http://lore.kernel.org/linux-trace-devel/20190801074959.22023-4-tz.stoyanov@gmail.com Link: http://lore.kernel.org/lkml/20190805204355.344622683@goodmis.org Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/Makefile | 6 +++--- tools/lib/traceevent/event-plugin.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile index 8352d53dcb5a..a39cdd0d890d 100644 --- a/tools/lib/traceevent/Makefile +++ b/tools/lib/traceevent/Makefile @@ -62,15 +62,15 @@ set_plugin_dir := 1 # Set plugin_dir to preffered global plugin location # If we install under $HOME directory we go under -# $(HOME)/.traceevent/plugins +# $(HOME)/.local/lib/traceevent/plugins # # We dont set PLUGIN_DIR in case we install under $HOME # directory, because by default the code looks under: -# $(HOME)/.traceevent/plugins by default. +# $(HOME)/.local/lib/traceevent/plugins by default. # ifeq ($(plugin_dir),) ifeq ($(prefix),$(HOME)) -override plugin_dir = $(HOME)/.traceevent/plugins +override plugin_dir = $(HOME)/.local/lib/traceevent/plugins set_plugin_dir := 0 else override plugin_dir = $(libdir)/traceevent/plugins diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c index 8ca28de9337a..e1f7ddd5a6cf 100644 --- a/tools/lib/traceevent/event-plugin.c +++ b/tools/lib/traceevent/event-plugin.c @@ -18,7 +18,7 @@ #include "event-utils.h" #include "trace-seq.h" -#define LOCAL_PLUGIN_DIR ".traceevent/plugins" +#define LOCAL_PLUGIN_DIR ".local/lib/traceevent/plugins/" static struct registered_plugin_options { struct registered_plugin_options *next; From fac583fdb6741bf4850928b2a5bb8b0118b5879c Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 09:43:25 -0300 Subject: [PATCH 22/47] perf dso: Adopt DSO related macros from symbol.h Reducing the size of symbol.h by removing things that are better placed somewhere else. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-edenkmjt1oe5fks2s6umd30b@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 1 + tools/perf/util/build-id.c | 1 + tools/perf/util/dso.h | 3 +++ tools/perf/util/probe-file.c | 1 + tools/perf/util/symbol.c | 1 + tools/perf/util/symbol.h | 3 --- 6 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 3bd1691f0be7..67a7513077d0 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -20,6 +20,7 @@ #include "color.h" #include "config.h" #include "cache.h" +#include "dso.h" #include "map.h" #include "symbol.h" #include "srcline.h" diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 4c96a33b09ff..e5fb77755d9e 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -13,6 +13,7 @@ #include #include #include +#include "dso.h" #include "build-id.h" #include "event.h" #include "namespaces.h" diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 6e3f63781e51..ff0b81854628 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -16,6 +16,9 @@ struct machine; struct map; struct perf_env; +#define DSO__NAME_KALLSYMS "[kernel.kallsyms]" +#define DSO__NAME_KCORE "[kernel.kcore]" + enum dso_binary_type { DSO_BINARY_TYPE__KALLSYMS = 0, DSO_BINARY_TYPE__GUEST_KALLSYMS, diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 5b4d49382932..10d2ab179c71 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -16,6 +16,7 @@ #include "strlist.h" #include "strfilter.h" #include "debug.h" +#include "dso.h" #include "cache.h" #include "color.h" #include "symbol.h" diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index c37cca690864..b11a69681662 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -18,6 +18,7 @@ #include "annotate.h" #include "build-id.h" #include "cap.h" +#include "dso.h" #include "util.h" #include "debug.h" #include "event.h" diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 183f630cb5f1..159c59652a5c 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -46,9 +46,6 @@ Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ #endif -#define DSO__NAME_KALLSYMS "[kernel.kallsyms]" -#define DSO__NAME_KCORE "[kernel.kcore]" - /** struct symbol - symtab entry * * @ignore - resolvable but tools ignore it (e.g. idle routines) From 9bea81b36a8d7d23c9bb7f4d63a9a842eec134a0 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 10:01:50 -0300 Subject: [PATCH 23/47] perf symbol: Move C++ demangle defines to the only file using it No need to have it generally available in such a critical header as symbol.h. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-es1ufxv7bihiumytn5dm3drn@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/symbol-elf.c | 6 ++++++ tools/perf/util/symbol.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 7d504dc22108..6d22437e88ae 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -40,6 +40,12 @@ typedef Elf64_Nhdr GElf_Nhdr; +#ifndef DMGL_PARAMS +#define DMGL_NO_OPTS 0 /* For readability... */ +#define DMGL_PARAMS (1 << 0) /* Include function args */ +#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ +#endif + #ifdef HAVE_CPLUS_DEMANGLE_SUPPORT extern char *cplus_demangle(const char *, int); diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 159c59652a5c..bcc0d84a42b8 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -40,12 +40,6 @@ Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, GElf_Shdr *shp, const char *name, size_t *idx); #endif -#ifndef DMGL_PARAMS -#define DMGL_NO_OPTS 0 /* For readability... */ -#define DMGL_PARAMS (1 << 0) /* Include function args */ -#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ -#endif - /** struct symbol - symtab entry * * @ignore - resolvable but tools ignore it (e.g. idle routines) From c38fa94d188234f40fe3911b1a7650e056ef42ea Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 10:19:19 -0300 Subject: [PATCH 24/47] perf symbols: Add missing linux/refcount.h to symbol.h We use refcount_t there, so we need that header or else it'll break when we remove dso.h, that is from where it is getting that definition now... Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-5albrk0uve6x9cf6x3ebwpae@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/symbol.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index bcc0d84a42b8..22660c7614a5 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -3,6 +3,7 @@ #define __PERF_SYMBOL 1 #include +#include #include #include #include From b1d1b094f7570a13dd7c9b995209baacc8aa6273 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 10:26:37 -0300 Subject: [PATCH 25/47] perf symbols: Move symsrc prototypes to a separate header So that we can remove dso.h from symbol.h and reduce the header dependency tree. Fixup cases where struct dso guts are needed but were obtained via symbol.h, indirectly. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-ip683cegt306ncu3gsz7ii21@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/powerpc/util/sym-handling.c | 1 + tools/perf/builtin-probe.c | 1 + tools/perf/ui/browsers/map.c | 1 + tools/perf/ui/gtk/annotate.c | 1 + tools/perf/util/symbol-elf.c | 1 + tools/perf/util/symbol-minimal.c | 2 + tools/perf/util/symbol.c | 1 + tools/perf/util/symbol.h | 36 ++-------------- tools/perf/util/symbol_fprintf.c | 1 + tools/perf/util/symsrc.h | 46 +++++++++++++++++++++ 10 files changed, 58 insertions(+), 33 deletions(-) create mode 100644 tools/perf/util/symsrc.h diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c index b0a67eaf2ce8..8a4b717e0a53 100644 --- a/tools/perf/arch/powerpc/util/sym-handling.c +++ b/tools/perf/arch/powerpc/util/sym-handling.c @@ -5,6 +5,7 @@ */ #include "debug.h" +#include "dso.h" #include "symbol.h" #include "map.h" #include "probe-event.h" diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 8950c05ef8fd..6dce1724a378 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c @@ -18,6 +18,7 @@ #include "builtin.h" #include "namespaces.h" +#include "util/build-id.h" #include "util/strlist.h" #include "util/strfilter.h" #include "util/symbol.h" diff --git a/tools/perf/ui/browsers/map.c b/tools/perf/ui/browsers/map.c index 4c545b92e20d..893b065971f6 100644 --- a/tools/perf/ui/browsers/map.c +++ b/tools/perf/ui/browsers/map.c @@ -8,6 +8,7 @@ #include "../../util/util.h" #include "../../util/debug.h" #include "../../util/map.h" +#include "../../util/dso.h" #include "../../util/symbol.h" #include "../browser.h" #include "../helpline.h" diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c index d7f984436dec..8e744af24f7c 100644 --- a/tools/perf/ui/gtk/annotate.c +++ b/tools/perf/ui/gtk/annotate.c @@ -5,6 +5,7 @@ #include "util/annotate.h" #include "util/evsel.h" #include "util/map.h" +#include "util/dso.h" #include "util/symbol.h" #include "ui/helpline.h" #include diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 6d22437e88ae..9428639872a6 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -10,6 +10,7 @@ #include "map.h" #include "map_groups.h" #include "symbol.h" +#include "symsrc.h" #include "demangle-java.h" #include "demangle-rust.h" #include "machine.h" diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c index 3bc8b7e3300e..7e2813ec9498 100644 --- a/tools/perf/util/symbol-minimal.c +++ b/tools/perf/util/symbol-minimal.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 +#include "dso.h" #include "symbol.h" +#include "symsrc.h" #include "util.h" #include diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index b11a69681662..e5ffe61ad66b 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -25,6 +25,7 @@ #include "machine.h" #include "map.h" #include "symbol.h" +#include "symsrc.h" #include "strlist.h" #include "intlist.h" #include "namespaces.h" diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 22660c7614a5..5a58407c2945 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -20,8 +20,7 @@ #endif #include -#include "dso.h" - +struct dso; struct map; struct map_groups; struct option; @@ -148,37 +147,6 @@ struct addr_location { s32 socket; }; -struct symsrc { - char *name; - int fd; - enum dso_binary_type type; - -#ifdef HAVE_LIBELF_SUPPORT - Elf *elf; - GElf_Ehdr ehdr; - - Elf_Scn *opdsec; - size_t opdidx; - GElf_Shdr opdshdr; - - Elf_Scn *symtab; - GElf_Shdr symshdr; - - Elf_Scn *dynsym; - size_t dynsym_idx; - GElf_Shdr dynshdr; - - bool adjust_symbols; - bool is_64_bit; -#endif -}; - -void symsrc__destroy(struct symsrc *ss); -int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, - enum dso_binary_type type); -bool symsrc__has_symtab(struct symsrc *ss); -bool symsrc__possibly_runtime(struct symsrc *ss); - int dso__load(struct dso *dso, struct map *map); int dso__load_vmlinux(struct dso *dso, struct map *map, const char *vmlinux, bool vmlinux_allocated); @@ -232,6 +200,8 @@ bool symbol__restricted_filename(const char *filename, int symbol__config_symfs(const struct option *opt __maybe_unused, const char *dir, int unset __maybe_unused); +struct symsrc; + int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, struct symsrc *runtime_ss, int kmodule); int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss); diff --git a/tools/perf/util/symbol_fprintf.c b/tools/perf/util/symbol_fprintf.c index 02e89b02c2ce..35c936ce33ef 100644 --- a/tools/perf/util/symbol_fprintf.c +++ b/tools/perf/util/symbol_fprintf.c @@ -3,6 +3,7 @@ #include #include +#include "dso.h" #include "map.h" #include "symbol.h" diff --git a/tools/perf/util/symsrc.h b/tools/perf/util/symsrc.h new file mode 100644 index 000000000000..2665b4bde751 --- /dev/null +++ b/tools/perf/util/symsrc.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __PERF_SYMSRC_ +#define __PERF_SYMSRC_ 1 + +#include +#include +#include "dso.h" + +#ifdef HAVE_LIBELF_SUPPORT +#include +#include +#endif +#include + +struct symsrc { + char *name; + int fd; + enum dso_binary_type type; + +#ifdef HAVE_LIBELF_SUPPORT + Elf *elf; + GElf_Ehdr ehdr; + + Elf_Scn *opdsec; + size_t opdidx; + GElf_Shdr opdshdr; + + Elf_Scn *symtab; + GElf_Shdr symshdr; + + Elf_Scn *dynsym; + size_t dynsym_idx; + GElf_Shdr dynshdr; + + bool adjust_symbols; + bool is_64_bit; +#endif +}; + +int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, enum dso_binary_type type); +void symsrc__destroy(struct symsrc *ss); + +bool symsrc__has_symtab(struct symsrc *ss); +bool symsrc__possibly_runtime(struct symsrc *ss); + +#endif /* __PERF_SYMSRC_ */ From 4a3cec84949d14dc3ef7fb8a51b8949af93cac13 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 11:11:01 -0300 Subject: [PATCH 26/47] perf dsos: Move the dsos struct and its methods to separate source files So that we can reduce the header dependency tree further, in the process noticed that lots of places were getting even things like build-id routines and 'struct perf_tool' definition indirectly, so fix all those too. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-ti0btma9ow5ndrytyoqdk62j@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-annotate.c | 1 + tools/perf/builtin-buildid-cache.c | 1 + tools/perf/builtin-buildid-list.c | 1 + tools/perf/builtin-inject.c | 1 + tools/perf/builtin-kallsyms.c | 1 + tools/perf/builtin-kmem.c | 1 + tools/perf/builtin-kvm.c | 1 + tools/perf/builtin-mem.c | 1 + tools/perf/builtin-report.c | 1 + tools/perf/builtin-script.c | 1 + tools/perf/builtin-top.c | 1 + tools/perf/builtin-trace.c | 2 + tools/perf/tests/code-reading.c | 1 + tools/perf/tests/dso-data.c | 1 + tools/perf/tests/dwarf-unwind.c | 1 + tools/perf/tests/event_update.c | 1 + tools/perf/tests/hists_common.c | 1 + tools/perf/tests/hists_cumulate.c | 1 + tools/perf/tests/hists_output.c | 1 + tools/perf/tests/vmlinux-kallsyms.c | 1 + tools/perf/ui/browsers/annotate.c | 1 + tools/perf/ui/browsers/hists.c | 1 + tools/perf/util/Build | 1 + tools/perf/util/bpf-event.c | 1 + tools/perf/util/callchain.c | 1 + tools/perf/util/cs-etm.c | 2 + tools/perf/util/db-export.c | 1 + tools/perf/util/dso.c | 235 +----------------- tools/perf/util/dso.h | 25 +- tools/perf/util/dsos.c | 232 +++++++++++++++++ tools/perf/util/dsos.h | 44 ++++ tools/perf/util/event.c | 2 + tools/perf/util/header.c | 1 + tools/perf/util/hist.c | 1 + tools/perf/util/intel-bts.c | 1 + tools/perf/util/jitdump.c | 1 + tools/perf/util/machine.c | 1 + tools/perf/util/machine.h | 3 +- tools/perf/util/map.c | 1 + tools/perf/util/parse-events.c | 1 + tools/perf/util/probe-event.c | 2 + tools/perf/util/s390-cpumsf.c | 1 + .../util/scripting-engines/trace-event-perl.c | 1 + .../scripting-engines/trace-event-python.c | 2 + tools/perf/util/sort.c | 1 + tools/perf/util/thread.c | 1 + tools/perf/util/unwind-libdw.c | 1 + tools/perf/util/unwind-libunwind.c | 1 + tools/perf/util/vdso.c | 1 + 49 files changed, 331 insertions(+), 257 deletions(-) create mode 100644 tools/perf/util/dsos.c create mode 100644 tools/perf/util/dsos.h diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 9bb637165bf9..738471a0a549 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -27,6 +27,7 @@ #include "util/thread.h" #include "util/sort.h" #include "util/hist.h" +#include "util/dso.h" #include "util/map.h" #include "util/session.h" #include "util/tool.h" diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index 9e756004ef28..b035911969b8 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c @@ -22,6 +22,7 @@ #include "util/strlist.h" #include "util/build-id.h" #include "util/session.h" +#include "util/dso.h" #include "util/symbol.h" #include "util/time-utils.h" #include "util/util.h" diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index 72bdc0eba990..38b2ec61c021 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c @@ -12,6 +12,7 @@ #include "util/build-id.h" #include "util/cache.h" #include "util/debug.h" +#include "util/dso.h" #include #include "util/session.h" #include "util/symbol.h" diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index ae46de46e826..c14f40b858bc 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -9,6 +9,7 @@ #include "builtin.h" #include "util/color.h" +#include "util/dso.h" #include "util/evlist.h" #include "util/evsel.h" #include "util/map.h" diff --git a/tools/perf/builtin-kallsyms.c b/tools/perf/builtin-kallsyms.c index c1a44671b0b5..c08ee81529e8 100644 --- a/tools/perf/builtin-kallsyms.c +++ b/tools/perf/builtin-kallsyms.c @@ -11,6 +11,7 @@ #include #include #include "debug.h" +#include "dso.h" #include "machine.h" #include "map.h" #include "symbol.h" diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 378b09c910a8..b5682beaad72 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -2,6 +2,7 @@ #include "builtin.h" #include "perf.h" +#include "util/dso.h" #include "util/evlist.h" #include "util/evsel.h" #include "util/config.h" diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 69d16ac852c3..474c4799d29d 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -2,6 +2,7 @@ #include "builtin.h" #include "perf.h" +#include "util/build-id.h" #include "util/evsel.h" #include "util/evlist.h" #include "util/term.h" diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index 9e60eda9297d..c5f3b9e9509d 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -13,6 +13,7 @@ #include "util/data.h" #include "util/mem-events.h" #include "util/debug.h" +#include "util/dso.h" #include "util/map.h" #include "util/symbol.h" diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 94e7e354cb16..ba419ee40283 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -12,6 +12,7 @@ #include "util/annotate.h" #include "util/color.h" +#include "util/dso.h" #include #include #include diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index f3b31c6ed15f..1ff04b00a561 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -4,6 +4,7 @@ #include "util/cache.h" #include "util/counts.h" #include "util/debug.h" +#include "util/dso.h" #include #include "util/header.h" #include diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 5538b5886e35..0b7b12cfdd63 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -24,6 +24,7 @@ #include "util/bpf-event.h" #include "util/config.h" #include "util/color.h" +#include "util/dso.h" #include "util/evlist.h" #include "util/evsel.h" #include "util/event.h" diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index b1ec8ff52740..0f633f0d6be8 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -25,6 +25,7 @@ #include "util/color.h" #include "util/config.h" #include "util/debug.h" +#include "util/dso.h" #include "util/env.h" #include "util/event.h" #include "util/evlist.h" @@ -42,6 +43,7 @@ #include "util/intlist.h" #include "util/thread_map.h" #include "util/stat.h" +#include "util/tool.h" #include "util/util.h" #include "trace/beauty/beauty.h" #include "trace-event.h" diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index c4b73bb4b113..7b2b89f4b716 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -12,6 +12,7 @@ #include #include "debug.h" +#include "dso.h" #include "parse-events.h" #include "evlist.h" #include "evsel.h" diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c index 946ab4b63acd..a4874d4ce7ef 100644 --- a/tools/perf/tests/dso-data.c +++ b/tools/perf/tests/dso-data.c @@ -9,6 +9,7 @@ #include #include #include +#include "dso.h" #include "util.h" #include "machine.h" #include "symbol.h" diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c index f33709a79335..4125255ff637 100644 --- a/tools/perf/tests/dwarf-unwind.c +++ b/tools/perf/tests/dwarf-unwind.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "tests.h" #include "debug.h" diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_update.c index 1411155597b8..4b68ec3a13fc 100644 --- a/tools/perf/tests/event_update.c +++ b/tools/perf/tests/event_update.c @@ -4,6 +4,7 @@ #include "evlist.h" #include "evsel.h" #include "machine.h" +#include "tool.h" #include "tests.h" #include "debug.h" diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c index 96ad95d3f338..cdde41c03056 100644 --- a/tools/perf/tests/hists_common.c +++ b/tools/perf/tests/hists_common.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include "util/debug.h" +#include "util/dso.h" #include "util/map.h" #include "util/symbol.h" #include "util/sort.h" diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c index 93af420ad2e4..fa55b7bad3af 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "util/debug.h" +#include "util/dso.h" #include "util/event.h" #include "util/map.h" #include "util/symbol.h" diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c index 07f4ca0704fb..3f6dfa212260 100644 --- a/tools/perf/tests/hists_output.c +++ b/tools/perf/tests/hists_output.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "util/debug.h" +#include "util/dso.h" #include "util/event.h" #include "util/map.h" #include "util/symbol.h" diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c index 5e8834fc7dec..01f434c067c6 100644 --- a/tools/perf/tests/vmlinux-kallsyms.c +++ b/tools/perf/tests/vmlinux-kallsyms.c @@ -4,6 +4,7 @@ #include #include #include +#include "dso.h" #include "map.h" #include "symbol.h" #include "util.h" diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 715601f5fce3..ac74ed2c23a0 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -5,6 +5,7 @@ #include "../util.h" #include "../../util/annotate.h" #include "../../util/debug.h" +#include "../../util/dso.h" #include "../../util/hist.h" #include "../../util/sort.h" #include "../../util/map.h" diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index a14dda74f43a..cf8857456056 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -12,6 +12,7 @@ #include #include "../../util/debug.h" +#include "../../util/dso.h" #include "../../util/callchain.h" #include "../../util/evsel.h" #include "../../util/evlist.h" diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 2e3856471e61..0b4d8e0d474c 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -36,6 +36,7 @@ perf-y += strfilter.o perf-y += top.o perf-y += usage.o perf-y += dso.o +perf-y += dsos.o perf-y += symbol.o perf-y += symbol_fprintf.o perf-y += color.o diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c index 2d6d500c9af7..7a3d4b125323 100644 --- a/tools/perf/util/bpf-event.c +++ b/tools/perf/util/bpf-event.c @@ -8,6 +8,7 @@ #include #include "bpf-event.h" #include "debug.h" +#include "dso.h" #include "symbol.h" #include "machine.h" #include "env.h" diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 76bf05b26d3b..c14646c1f2eb 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -22,6 +22,7 @@ #include "asm/bug.h" #include "debug.h" +#include "dso.h" #include "hist.h" #include "sort.h" #include "machine.h" diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index d6de3834865e..3ed1d3bb7089 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -21,12 +21,14 @@ #include "cs-etm.h" #include "cs-etm-decoder/cs-etm-decoder.h" #include "debug.h" +#include "dso.h" #include "evlist.h" #include "intlist.h" #include "machine.h" #include "map.h" #include "perf.h" #include "symbol.h" +#include "tool.h" #include "thread.h" #include "thread_map.h" #include "thread-stack.h" diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c index 701e9f814313..752227b265e7 100644 --- a/tools/perf/util/db-export.c +++ b/tools/perf/util/db-export.c @@ -7,6 +7,7 @@ #include #include +#include "dso.h" #include "evsel.h" #include "machine.h" #include "thread.h" diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index ebc9d46c15a7..ece97209792d 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include "bpf-event.h" #include "compress.h" @@ -20,6 +19,7 @@ #include "symbol.h" #include "srcline.h" #include "dso.h" +#include "dsos.h" #include "machine.h" #include "auxtrace.h" #include "util.h" /* O_CLOEXEC for older systems */ @@ -1094,66 +1094,6 @@ struct dso *machine__findnew_kernel(struct machine *machine, const char *name, return dso; } -/* - * Find a matching entry and/or link current entry to RB tree. - * Either one of the dso or name parameter must be non-NULL or the - * function will not work. - */ -static struct dso *__dso__findlink_by_longname(struct rb_root *root, - struct dso *dso, const char *name) -{ - struct rb_node **p = &root->rb_node; - struct rb_node *parent = NULL; - - if (!name) - name = dso->long_name; - /* - * Find node with the matching name - */ - while (*p) { - struct dso *this = rb_entry(*p, struct dso, rb_node); - int rc = strcmp(name, this->long_name); - - parent = *p; - if (rc == 0) { - /* - * In case the new DSO is a duplicate of an existing - * one, print a one-time warning & put the new entry - * at the end of the list of duplicates. - */ - if (!dso || (dso == this)) - return this; /* Find matching dso */ - /* - * The core kernel DSOs may have duplicated long name. - * In this case, the short name should be different. - * Comparing the short names to differentiate the DSOs. - */ - rc = strcmp(dso->short_name, this->short_name); - if (rc == 0) { - pr_err("Duplicated dso name: %s\n", name); - return NULL; - } - } - if (rc < 0) - p = &parent->rb_left; - else - p = &parent->rb_right; - } - if (dso) { - /* Add new node and rebalance tree */ - rb_link_node(&dso->rb_node, parent, p); - rb_insert_color(&dso->rb_node, root); - dso->root = root; - } - return NULL; -} - -static inline struct dso *__dso__find_by_longname(struct rb_root *root, - const char *name) -{ - return __dso__findlink_by_longname(root, NULL, name); -} - void dso__set_long_name(struct dso *dso, const char *name, bool name_allocated) { struct rb_root *root = dso->root; @@ -1167,7 +1107,7 @@ void dso__set_long_name(struct dso *dso, const char *name, bool name_allocated) if (root) { rb_erase(&dso->rb_node, root); /* - * __dso__findlink_by_longname() isn't guaranteed to add it + * __dsos__findnew_link_by_longname() isn't guaranteed to add it * back, so a clean removal is required here. */ RB_CLEAR_NODE(&dso->rb_node); @@ -1179,7 +1119,7 @@ void dso__set_long_name(struct dso *dso, const char *name, bool name_allocated) dso->long_name_allocated = name_allocated; if (root) - __dso__findlink_by_longname(root, dso, NULL); + __dsos__findnew_link_by_longname(root, dso, NULL); } void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated) @@ -1195,38 +1135,6 @@ void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated) dso->short_name_allocated = name_allocated; } -static void dso__set_basename(struct dso *dso) -{ - char *base, *lname; - int tid; - - if (sscanf(dso->long_name, "/tmp/perf-%d.map", &tid) == 1) { - if (asprintf(&base, "[JIT] tid %d", tid) < 0) - return; - } else { - /* - * basename() may modify path buffer, so we must pass - * a copy. - */ - lname = strdup(dso->long_name); - if (!lname) - return; - - /* - * basename() may return a pointer to internal - * storage which is reused in subsequent calls - * so copy the result. - */ - base = strdup(basename(lname)); - - free(lname); - - if (!base) - return; - } - dso__set_short_name(dso, base, true); -} - int dso__name_len(const struct dso *dso) { if (!dso) @@ -1377,143 +1285,6 @@ int dso__kernel_module_get_build_id(struct dso *dso, return 0; } -bool __dsos__read_build_ids(struct list_head *head, bool with_hits) -{ - bool have_build_id = false; - struct dso *pos; - struct nscookie nsc; - - list_for_each_entry(pos, head, node) { - if (with_hits && !pos->hit && !dso__is_vdso(pos)) - continue; - if (pos->has_build_id) { - have_build_id = true; - continue; - } - nsinfo__mountns_enter(pos->nsinfo, &nsc); - if (filename__read_build_id(pos->long_name, pos->build_id, - sizeof(pos->build_id)) > 0) { - have_build_id = true; - pos->has_build_id = true; - } - nsinfo__mountns_exit(&nsc); - } - - return have_build_id; -} - -void __dsos__add(struct dsos *dsos, struct dso *dso) -{ - list_add_tail(&dso->node, &dsos->head); - __dso__findlink_by_longname(&dsos->root, dso, NULL); - /* - * It is now in the linked list, grab a reference, then garbage collect - * this when needing memory, by looking at LRU dso instances in the - * list with atomic_read(&dso->refcnt) == 1, i.e. no references - * anywhere besides the one for the list, do, under a lock for the - * list: remove it from the list, then a dso__put(), that probably will - * be the last and will then call dso__delete(), end of life. - * - * That, or at the end of the 'struct machine' lifetime, when all - * 'struct dso' instances will be removed from the list, in - * dsos__exit(), if they have no other reference from some other data - * structure. - * - * E.g.: after processing a 'perf.data' file and storing references - * to objects instantiated while processing events, we will have - * references to the 'thread', 'map', 'dso' structs all from 'struct - * hist_entry' instances, but we may not need anything not referenced, - * so we might as well call machines__exit()/machines__delete() and - * garbage collect it. - */ - dso__get(dso); -} - -void dsos__add(struct dsos *dsos, struct dso *dso) -{ - down_write(&dsos->lock); - __dsos__add(dsos, dso); - up_write(&dsos->lock); -} - -struct dso *__dsos__find(struct dsos *dsos, const char *name, bool cmp_short) -{ - struct dso *pos; - - if (cmp_short) { - list_for_each_entry(pos, &dsos->head, node) - if (strcmp(pos->short_name, name) == 0) - return pos; - return NULL; - } - return __dso__find_by_longname(&dsos->root, name); -} - -struct dso *dsos__find(struct dsos *dsos, const char *name, bool cmp_short) -{ - struct dso *dso; - down_read(&dsos->lock); - dso = __dsos__find(dsos, name, cmp_short); - up_read(&dsos->lock); - return dso; -} - -struct dso *__dsos__addnew(struct dsos *dsos, const char *name) -{ - struct dso *dso = dso__new(name); - - if (dso != NULL) { - __dsos__add(dsos, dso); - dso__set_basename(dso); - /* Put dso here because __dsos_add already got it */ - dso__put(dso); - } - return dso; -} - -struct dso *__dsos__findnew(struct dsos *dsos, const char *name) -{ - struct dso *dso = __dsos__find(dsos, name, false); - - return dso ? dso : __dsos__addnew(dsos, name); -} - -struct dso *dsos__findnew(struct dsos *dsos, const char *name) -{ - struct dso *dso; - down_write(&dsos->lock); - dso = dso__get(__dsos__findnew(dsos, name)); - up_write(&dsos->lock); - return dso; -} - -size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp, - bool (skip)(struct dso *dso, int parm), int parm) -{ - struct dso *pos; - size_t ret = 0; - - list_for_each_entry(pos, head, node) { - if (skip && skip(pos, parm)) - continue; - ret += dso__fprintf_buildid(pos, fp); - ret += fprintf(fp, " %s\n", pos->long_name); - } - return ret; -} - -size_t __dsos__fprintf(struct list_head *head, FILE *fp) -{ - struct dso *pos; - size_t ret = 0; - - list_for_each_entry(pos, head, node) { - ret += dso__fprintf(pos, fp); - } - - return ret; -} - size_t dso__fprintf_buildid(struct dso *dso, FILE *fp) { char sbuild_id[SBUILD_ID_SIZE]; diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index ff0b81854628..e4dddb76770d 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -2,13 +2,13 @@ #ifndef __PERF_DSO #define __PERF_DSO +#include #include #include #include #include #include #include -#include "rwsem.h" #include #include "build-id.h" @@ -129,16 +129,6 @@ struct dso_cache { char data[0]; }; -/* - * DSOs are put into both a list for fast iteration and rbtree for fast - * long name lookup. - */ -struct dsos { - struct list_head head; - struct rb_root root; /* rbtree root sorted by long name */ - struct rw_semaphore lock; -}; - struct auxtrace_cache; struct dso { @@ -347,21 +337,8 @@ struct map *dso__new_map(const char *name); struct dso *machine__findnew_kernel(struct machine *machine, const char *name, const char *short_name, int dso_type); -void __dsos__add(struct dsos *dsos, struct dso *dso); -void dsos__add(struct dsos *dsos, struct dso *dso); -struct dso *__dsos__addnew(struct dsos *dsos, const char *name); -struct dso *__dsos__find(struct dsos *dsos, const char *name, bool cmp_short); -struct dso *dsos__find(struct dsos *dsos, const char *name, bool cmp_short); -struct dso *__dsos__findnew(struct dsos *dsos, const char *name); -struct dso *dsos__findnew(struct dsos *dsos, const char *name); -bool __dsos__read_build_ids(struct list_head *head, bool with_hits); - void dso__reset_find_symbol_cache(struct dso *dso); -size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp, - bool (skip)(struct dso *dso, int parm), int parm); -size_t __dsos__fprintf(struct list_head *head, FILE *fp); - size_t dso__fprintf_buildid(struct dso *dso, FILE *fp); size_t dso__fprintf_symbols_by_name(struct dso *dso, FILE *fp); size_t dso__fprintf(struct dso *dso, FILE *fp); diff --git a/tools/perf/util/dsos.c b/tools/perf/util/dsos.c new file mode 100644 index 000000000000..3ea80d203587 --- /dev/null +++ b/tools/perf/util/dsos.c @@ -0,0 +1,232 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "debug.h" +#include "dsos.h" +#include "dso.h" +#include "vdso.h" +#include "namespaces.h" +#include +#include +#include +#include // filename__read_build_id + +bool __dsos__read_build_ids(struct list_head *head, bool with_hits) +{ + bool have_build_id = false; + struct dso *pos; + struct nscookie nsc; + + list_for_each_entry(pos, head, node) { + if (with_hits && !pos->hit && !dso__is_vdso(pos)) + continue; + if (pos->has_build_id) { + have_build_id = true; + continue; + } + nsinfo__mountns_enter(pos->nsinfo, &nsc); + if (filename__read_build_id(pos->long_name, pos->build_id, + sizeof(pos->build_id)) > 0) { + have_build_id = true; + pos->has_build_id = true; + } + nsinfo__mountns_exit(&nsc); + } + + return have_build_id; +} + +/* + * Find a matching entry and/or link current entry to RB tree. + * Either one of the dso or name parameter must be non-NULL or the + * function will not work. + */ +struct dso *__dsos__findnew_link_by_longname(struct rb_root *root, struct dso *dso, const char *name) +{ + struct rb_node **p = &root->rb_node; + struct rb_node *parent = NULL; + + if (!name) + name = dso->long_name; + /* + * Find node with the matching name + */ + while (*p) { + struct dso *this = rb_entry(*p, struct dso, rb_node); + int rc = strcmp(name, this->long_name); + + parent = *p; + if (rc == 0) { + /* + * In case the new DSO is a duplicate of an existing + * one, print a one-time warning & put the new entry + * at the end of the list of duplicates. + */ + if (!dso || (dso == this)) + return this; /* Find matching dso */ + /* + * The core kernel DSOs may have duplicated long name. + * In this case, the short name should be different. + * Comparing the short names to differentiate the DSOs. + */ + rc = strcmp(dso->short_name, this->short_name); + if (rc == 0) { + pr_err("Duplicated dso name: %s\n", name); + return NULL; + } + } + if (rc < 0) + p = &parent->rb_left; + else + p = &parent->rb_right; + } + if (dso) { + /* Add new node and rebalance tree */ + rb_link_node(&dso->rb_node, parent, p); + rb_insert_color(&dso->rb_node, root); + dso->root = root; + } + return NULL; +} + +void __dsos__add(struct dsos *dsos, struct dso *dso) +{ + list_add_tail(&dso->node, &dsos->head); + __dsos__findnew_link_by_longname(&dsos->root, dso, NULL); + /* + * It is now in the linked list, grab a reference, then garbage collect + * this when needing memory, by looking at LRU dso instances in the + * list with atomic_read(&dso->refcnt) == 1, i.e. no references + * anywhere besides the one for the list, do, under a lock for the + * list: remove it from the list, then a dso__put(), that probably will + * be the last and will then call dso__delete(), end of life. + * + * That, or at the end of the 'struct machine' lifetime, when all + * 'struct dso' instances will be removed from the list, in + * dsos__exit(), if they have no other reference from some other data + * structure. + * + * E.g.: after processing a 'perf.data' file and storing references + * to objects instantiated while processing events, we will have + * references to the 'thread', 'map', 'dso' structs all from 'struct + * hist_entry' instances, but we may not need anything not referenced, + * so we might as well call machines__exit()/machines__delete() and + * garbage collect it. + */ + dso__get(dso); +} + +void dsos__add(struct dsos *dsos, struct dso *dso) +{ + down_write(&dsos->lock); + __dsos__add(dsos, dso); + up_write(&dsos->lock); +} + +struct dso *__dsos__find(struct dsos *dsos, const char *name, bool cmp_short) +{ + struct dso *pos; + + if (cmp_short) { + list_for_each_entry(pos, &dsos->head, node) + if (strcmp(pos->short_name, name) == 0) + return pos; + return NULL; + } + return __dsos__findnew_by_longname(&dsos->root, name); +} + +struct dso *dsos__find(struct dsos *dsos, const char *name, bool cmp_short) +{ + struct dso *dso; + down_read(&dsos->lock); + dso = __dsos__find(dsos, name, cmp_short); + up_read(&dsos->lock); + return dso; +} + +static void dso__set_basename(struct dso *dso) +{ + char *base, *lname; + int tid; + + if (sscanf(dso->long_name, "/tmp/perf-%d.map", &tid) == 1) { + if (asprintf(&base, "[JIT] tid %d", tid) < 0) + return; + } else { + /* + * basename() may modify path buffer, so we must pass + * a copy. + */ + lname = strdup(dso->long_name); + if (!lname) + return; + + /* + * basename() may return a pointer to internal + * storage which is reused in subsequent calls + * so copy the result. + */ + base = strdup(basename(lname)); + + free(lname); + + if (!base) + return; + } + dso__set_short_name(dso, base, true); +} + +struct dso *__dsos__addnew(struct dsos *dsos, const char *name) +{ + struct dso *dso = dso__new(name); + + if (dso != NULL) { + __dsos__add(dsos, dso); + dso__set_basename(dso); + /* Put dso here because __dsos_add already got it */ + dso__put(dso); + } + return dso; +} + +struct dso *__dsos__findnew(struct dsos *dsos, const char *name) +{ + struct dso *dso = __dsos__find(dsos, name, false); + + return dso ? dso : __dsos__addnew(dsos, name); +} + +struct dso *dsos__findnew(struct dsos *dsos, const char *name) +{ + struct dso *dso; + down_write(&dsos->lock); + dso = dso__get(__dsos__findnew(dsos, name)); + up_write(&dsos->lock); + return dso; +} + +size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp, + bool (skip)(struct dso *dso, int parm), int parm) +{ + struct dso *pos; + size_t ret = 0; + + list_for_each_entry(pos, head, node) { + if (skip && skip(pos, parm)) + continue; + ret += dso__fprintf_buildid(pos, fp); + ret += fprintf(fp, " %s\n", pos->long_name); + } + return ret; +} + +size_t __dsos__fprintf(struct list_head *head, FILE *fp) +{ + struct dso *pos; + size_t ret = 0; + + list_for_each_entry(pos, head, node) { + ret += dso__fprintf(pos, fp); + } + + return ret; +} diff --git a/tools/perf/util/dsos.h b/tools/perf/util/dsos.h new file mode 100644 index 000000000000..32f1fbee0feb --- /dev/null +++ b/tools/perf/util/dsos.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __PERF_DSOS +#define __PERF_DSOS + +#include +#include +#include +#include +#include "rwsem.h" + +struct dso; + +/* + * DSOs are put into both a list for fast iteration and rbtree for fast + * long name lookup. + */ +struct dsos { + struct list_head head; + struct rb_root root; /* rbtree root sorted by long name */ + struct rw_semaphore lock; +}; + +void __dsos__add(struct dsos *dsos, struct dso *dso); +void dsos__add(struct dsos *dsos, struct dso *dso); +struct dso *__dsos__addnew(struct dsos *dsos, const char *name); +struct dso *__dsos__find(struct dsos *dsos, const char *name, bool cmp_short); +struct dso *dsos__find(struct dsos *dsos, const char *name, bool cmp_short); +struct dso *__dsos__findnew(struct dsos *dsos, const char *name); +struct dso *dsos__findnew(struct dsos *dsos, const char *name); + +struct dso *__dsos__findnew_link_by_longname(struct rb_root *root, struct dso *dso, const char *name); + +static inline struct dso *__dsos__findnew_by_longname(struct rb_root *root, const char *name) +{ + return __dsos__findnew_link_by_longname(root, NULL, name); +} + +bool __dsos__read_build_ids(struct list_head *head, bool with_hits); + +size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp, + bool (skip)(struct dso *dso, int parm), int parm); +size_t __dsos__fprintf(struct list_head *head, FILE *fp); + +#endif /* __PERF_DSOS */ diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 54169ad335c7..f4afbb858ebb 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -11,6 +11,7 @@ #include #include #include +#include "dso.h" #include "event.h" #include "debug.h" #include "hist.h" @@ -29,6 +30,7 @@ #include "stat.h" #include "session.h" #include "bpf-event.h" +#include "tool.h" #include "../perf.h" #define DEFAULT_PROC_MAP_PARSE_TIMEOUT 500 diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 20fb06162fd4..b0c34dda30a0 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -22,6 +22,7 @@ #include #include +#include "dso.h" #include "evlist.h" #include "evsel.h" #include "header.h" diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 02ea2ee62814..b526ef3ede98 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include "callchain.h" #include "debug.h" +#include "dso.h" #include "build-id.h" #include "hist.h" #include "map.h" diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index 99dddb63dac1..a30427aa1de0 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -22,6 +22,7 @@ #include "map.h" #include "symbol.h" #include "session.h" +#include "tool.h" #include "thread.h" #include "thread-stack.h" #include "debug.h" diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index bbeac4f66402..b80f29bfc7bb 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -14,6 +14,7 @@ #include #include +#include "build-id.h" #include "util.h" #include "event.h" #include "debug.h" diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 6e9afe4e55dd..003025465198 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -5,6 +5,7 @@ #include #include "callchain.h" #include "debug.h" +#include "dso.h" #include "event.h" #include "evsel.h" #include "hist.h" diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 7d69119d0b5d..ffd391a925a6 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h @@ -5,12 +5,13 @@ #include #include #include "map_groups.h" -#include "dso.h" +#include "dsos.h" #include "event.h" #include "rwsem.h" struct addr_location; struct branch_stack; +struct dso; struct evsel; struct perf_sample; struct symbol; diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index c75b20b93820..623a63cd1eec 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -8,6 +8,7 @@ #include #include #include /* To get things like MAP_HUGETLB even on older libc headers */ +#include "dso.h" #include "map.h" #include "thread.h" #include "vdso.h" diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 5f1ba6820cdd..523af1bd82e6 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -10,6 +10,7 @@ #include #include #include "term.h" +#include "build-id.h" #include "evlist.h" #include "evsel.h" #include diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 8394d48f8b32..5d12a78c8ac8 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -19,11 +19,13 @@ #include #include +#include "build-id.h" #include "event.h" #include "namespaces.h" #include "strlist.h" #include "strfilter.h" #include "debug.h" +#include "dso.h" #include "cache.h" #include "color.h" #include "map.h" diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 4f6c1465998f..2ba4baa2c52f 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -157,6 +157,7 @@ #include "evlist.h" #include "machine.h" #include "session.h" +#include "tool.h" #include "thread.h" #include "debug.h" #include "auxtrace.h" diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c index 800e82d35230..15961854ba67 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c @@ -35,6 +35,7 @@ #include #include "../callchain.h" +#include "../dso.h" #include "../machine.h" #include "../map.h" #include "../symbol.h" diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index abfde356be18..666a56e88d8e 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -31,8 +31,10 @@ #include #include +#include "../build-id.h" #include "../counts.h" #include "../debug.h" +#include "../dso.h" #include "../callchain.h" #include "../evsel.h" #include "../util.h" diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 4650704540c9..32ade5a1b553 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -5,6 +5,7 @@ #include #include #include "debug.h" +#include "dso.h" #include "sort.h" #include "hist.h" #include "cacheline.h" diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 5ba1601e8860..b64e9e049636 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -5,6 +5,7 @@ #include #include #include +#include "dso.h" #include "session.h" #include "thread.h" #include "thread-stack.h" diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c index 28f71ca6ce1c..9ece188ae48a 100644 --- a/tools/perf/util/unwind-libdw.c +++ b/tools/perf/util/unwind-libdw.c @@ -5,6 +5,7 @@ #include #include #include "debug.h" +#include "dso.h" #include "unwind.h" #include "unwind-libdw.h" #include "machine.h" diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c index 6499b22b158b..a24fb57c9b2c 100644 --- a/tools/perf/util/unwind-libunwind.c +++ b/tools/perf/util/unwind-libunwind.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "unwind.h" +#include "dso.h" #include "map.h" #include "thread.h" #include "session.h" diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c index 7f427bab6c12..e5e6599603f4 100644 --- a/tools/perf/util/vdso.c +++ b/tools/perf/util/vdso.c @@ -10,6 +10,7 @@ #include #include "vdso.h" +#include "dso.h" #include "util.h" #include "map.h" #include "symbol.h" From 171f7474b6bb6c7074431f76c28ea87d625c68fd Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 11:28:14 -0300 Subject: [PATCH 27/47] perf hist: Remove needless ui/progress.h from hist.h We only need a forward declaration, add it and fixup all the files that need ui_progress definitions but were wrongly getting it from hist.h. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-84a90o9jdxybffxo9jmouokw@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-c2c.c | 1 + tools/perf/builtin-report.c | 1 + tools/perf/util/hist.h | 2 +- tools/perf/util/session.c | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index d1ad694c67a2..0d76b2cb8c0a 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -37,6 +37,7 @@ #include "mem2node.h" #include "symbol.h" #include "ui/ui.h" +#include "ui/progress.h" #include "../perf.h" struct c2c_hists { diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index ba419ee40283..d7a345667945 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -47,6 +47,7 @@ #include "util/branch.h" #include "util/util.h" #include "ui/ui.h" +#include "ui/progress.h" #include #include diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 7b9267ebebeb..1c0a635e5e32 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -8,7 +8,6 @@ #include "evsel.h" #include "header.h" #include "color.h" -#include "ui/progress.h" struct hist_entry; struct hist_entry_ops; @@ -18,6 +17,7 @@ struct mem_info; struct branch_info; struct block_info; struct symbol; +struct ui_progress; enum hist_filter { HIST_FILTER__DSO, diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index a72774e4463f..f166da76acf1 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -30,6 +30,7 @@ #include "sample-raw.h" #include "stat.h" #include "util.h" +#include "ui/progress.h" #include "../perf.h" #include "arch/common.h" From 4772925885dac93aa5f00d1c1da93277778099cd Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 11:44:32 -0300 Subject: [PATCH 28/47] perf tools: Move 'struct events_stats' and prototypes to separate header This will allow us to untangle the header dependency a bit more, as some places will not need event.h anymore. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-enqncj29ovzaat3cd9203rwl@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/auxtrace.h | 5 ++++ tools/perf/util/event.h | 42 ---------------------------- tools/perf/util/events_stats.h | 51 ++++++++++++++++++++++++++++++++++ tools/perf/util/evlist.h | 2 +- tools/perf/util/hist.h | 4 +-- tools/perf/util/sort.h | 1 - 6 files changed, 58 insertions(+), 47 deletions(-) create mode 100644 tools/perf/util/events_stats.h diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index b5ac24c770d4..c539e7b6ed56 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -30,6 +30,11 @@ struct record_opts; struct perf_record_auxtrace_info; struct events_stats; +enum auxtrace_error_type { + PERF_AUXTRACE_ERROR_ITRACE = 1, + PERF_AUXTRACE_ERROR_MAX +}; + /* Auxtrace records must have the same alignment as perf event records */ #define PERF_AUXTRACE_RECORD_ALIGNMENT 8 diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 006aa432be19..47ad81d47b1a 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -151,11 +151,6 @@ struct perf_sample { PERF_MEM_S(LOCK, NA) |\ PERF_MEM_S(TLB, NA)) -enum auxtrace_error_type { - PERF_AUXTRACE_ERROR_ITRACE = 1, - PERF_AUXTRACE_ERROR_MAX -}; - /* Attribute type for custom synthesized events */ #define PERF_TYPE_SYNTH (INT_MAX + 1U) @@ -277,43 +272,6 @@ static inline void *perf_synth__raw_data(void *p) #define perf_sample__bad_synth_size(s, d) ((s)->raw_size < sizeof(d) - 4) -/* - * The kernel collects the number of events it couldn't send in a stretch and - * when possible sends this number in a PERF_RECORD_LOST event. The number of - * such "chunks" of lost events is stored in .nr_events[PERF_EVENT_LOST] while - * total_lost tells exactly how many events the kernel in fact lost, i.e. it is - * the sum of all struct perf_record_lost.lost fields reported. - * - * The kernel discards mixed up samples and sends the number in a - * PERF_RECORD_LOST_SAMPLES event. The number of lost-samples events is stored - * in .nr_events[PERF_RECORD_LOST_SAMPLES] while total_lost_samples tells - * exactly how many samples the kernel in fact dropped, i.e. it is the sum of - * all struct perf_record_lost_samples.lost fields reported. - * - * The total_period is needed because by default auto-freq is used, so - * multipling nr_events[PERF_EVENT_SAMPLE] by a frequency isn't possible to get - * the total number of low level events, it is necessary to to sum all struct - * perf_record_sample.period and stash the result in total_period. - */ -struct events_stats { - u64 total_period; - u64 total_non_filtered_period; - u64 total_lost; - u64 total_lost_samples; - u64 total_aux_lost; - u64 total_aux_partial; - u64 total_invalid_chains; - u32 nr_events[PERF_RECORD_HEADER_MAX]; - u32 nr_non_filtered_samples; - u32 nr_lost_warned; - u32 nr_unknown_events; - u32 nr_invalid_chains; - u32 nr_unknown_id; - u32 nr_unprocessable_samples; - u32 nr_auxtrace_errors[PERF_AUXTRACE_ERROR_MAX]; - u32 nr_proc_map_timeout; -}; - enum { PERF_STAT_ROUND_TYPE__INTERVAL = 0, PERF_STAT_ROUND_TYPE__FINAL = 1, diff --git a/tools/perf/util/events_stats.h b/tools/perf/util/events_stats.h new file mode 100644 index 000000000000..859cb34fcff2 --- /dev/null +++ b/tools/perf/util/events_stats.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __PERF_EVENTS_STATS_ +#define __PERF_EVENTS_STATS_ + +#include +#include +#include +#include "auxtrace.h" + +/* + * The kernel collects the number of events it couldn't send in a stretch and + * when possible sends this number in a PERF_RECORD_LOST event. The number of + * such "chunks" of lost events is stored in .nr_events[PERF_EVENT_LOST] while + * total_lost tells exactly how many events the kernel in fact lost, i.e. it is + * the sum of all struct perf_record_lost.lost fields reported. + * + * The kernel discards mixed up samples and sends the number in a + * PERF_RECORD_LOST_SAMPLES event. The number of lost-samples events is stored + * in .nr_events[PERF_RECORD_LOST_SAMPLES] while total_lost_samples tells + * exactly how many samples the kernel in fact dropped, i.e. it is the sum of + * all struct perf_record_lost_samples.lost fields reported. + * + * The total_period is needed because by default auto-freq is used, so + * multipling nr_events[PERF_EVENT_SAMPLE] by a frequency isn't possible to get + * the total number of low level events, it is necessary to to sum all struct + * perf_record_sample.period and stash the result in total_period. + */ +struct events_stats { + u64 total_period; + u64 total_non_filtered_period; + u64 total_lost; + u64 total_lost_samples; + u64 total_aux_lost; + u64 total_aux_partial; + u64 total_invalid_chains; + u32 nr_events[PERF_RECORD_HEADER_MAX]; + u32 nr_non_filtered_samples; + u32 nr_lost_warned; + u32 nr_unknown_events; + u32 nr_invalid_chains; + u32 nr_unknown_id; + u32 nr_unprocessable_samples; + u32 nr_auxtrace_errors[PERF_AUXTRACE_ERROR_MAX]; + u32 nr_proc_map_timeout; +}; + +void events_stats__inc(struct events_stats *stats, u32 type); + +size_t events_stats__fprintf(struct events_stats *stats, FILE *fp); + +#endif /* __PERF_EVENTS_STATS_ */ diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index ee288644e9e4..a55f0f2546e5 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -9,7 +9,7 @@ #include #include #include -#include "event.h" +#include "events_stats.h" #include "evsel.h" #include "mmap.h" #include diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 1c0a635e5e32..34803e33dc80 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -6,8 +6,8 @@ #include #include #include "evsel.h" -#include "header.h" #include "color.h" +#include "events_stats.h" struct hist_entry; struct hist_entry_ops; @@ -190,8 +190,6 @@ void hists__reset_stats(struct hists *hists); void hists__inc_stats(struct hists *hists, struct hist_entry *h); void hists__inc_nr_events(struct hists *hists, u32 type); void hists__inc_nr_samples(struct hists *hists, bool filtered); -void events_stats__inc(struct events_stats *stats, u32 type); -size_t events_stats__fprintf(struct events_stats *stats, FILE *fp); size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, int max_cols, float min_pcnt, FILE *fp, diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 3d7cef73924c..7b93f34ac1f4 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -9,7 +9,6 @@ #include "symbol_conf.h" #include "callchain.h" #include "values.h" - #include "hist.h" struct option; From 5c9dbe6da13398d09efc9ec479194afa6d9ec9e6 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 11:54:00 -0300 Subject: [PATCH 29/47] perf tools: Remove needless sort.h include directives Now that sort.h isn't included by any other header, we can check where it is really needed, i.e. we can remove it and be sure that it isn't being obtained indirectly. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-tom8k0lbsxd9joprr8zpu6w1@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-top.c | 1 + tools/perf/ui/browsers/scripts.c | 1 - tools/perf/util/hist.c | 1 + tools/perf/util/mem-events.c | 1 - tools/perf/util/session.c | 1 - 5 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 0b7b12cfdd63..0f0d96262d14 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -39,6 +39,7 @@ #include #include #include "util/parse-events.h" +#include "util/callchain.h" #include "util/cpumap.h" #include "util/sort.h" #include "util/string2.h" diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c index 77809c0fad02..bf1d9f9ec035 100644 --- a/tools/perf/ui/browsers/scripts.c +++ b/tools/perf/ui/browsers/scripts.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "../../builtin.h" #include "../../perf.h" -#include "../../util/sort.h" #include "../../util/util.h" #include "../../util/hist.h" #include "../../util/debug.h" diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index b526ef3ede98..0978dc4a33db 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c index 42c3e5a229d2..3a8d38ce3b54 100644 --- a/tools/perf/util/mem-events.c +++ b/tools/perf/util/mem-events.c @@ -11,7 +11,6 @@ #include "mem-events.h" #include "debug.h" #include "symbol.h" -#include "sort.h" unsigned int perf_mem_events__loads_ldlat = 30; diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index f166da76acf1..e5ac5f3c94d4 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -20,7 +20,6 @@ #include "symbol.h" #include "session.h" #include "tool.h" -#include "sort.h" #include "cpumap.h" #include "perf_regs.h" #include "asm/bug.h" From afce8c482c48e2c42c155eeae4cd048c2b5fbb99 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 11:56:47 -0300 Subject: [PATCH 30/47] perf probe: No need for symbol.h, symbol_conf is enough Remove one more unneeded use of symbol.h Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-vrda1tuem1o8pk82t2kfjtun@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 6dce1724a378..26bc5923e6b5 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c @@ -21,7 +21,7 @@ #include "util/build-id.h" #include "util/strlist.h" #include "util/strfilter.h" -#include "util/symbol.h" +#include "util/symbol_conf.h" #include "util/debug.h" #include #include "util/probe-finder.h" From df1a0a110c2c0138665f6d8ec96812ea14c2d818 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 12:07:23 -0300 Subject: [PATCH 31/47] perf tools: Remove needless map.h include directives Now that map.h isn't included by any other header, we can check where it is really needed, i.e. we can remove it and be sure that it isn't being obtained indirectly. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-iu8ylqky7g1i9i54v3y7qovw@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm64/util/sym-handling.c | 8 +++----- tools/perf/tests/thread-mg-share.c | 1 - tools/perf/util/intel-bts.c | 1 - 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/tools/perf/arch/arm64/util/sym-handling.c b/tools/perf/arch/arm64/util/sym-handling.c index 27fcf24d6850..5df788985130 100644 --- a/tools/perf/arch/arm64/util/sym-handling.c +++ b/tools/perf/arch/arm64/util/sym-handling.c @@ -4,11 +4,9 @@ * Copyright (C) 2015 Naveen N. Rao, IBM Corporation */ -#include "debug.h" -#include "symbol.h" -#include "map.h" -#include "probe-event.h" -#include "probe-file.h" +#include "symbol.h" // for the elf__needs_adjust_symbols() prototype +#include +#include #ifdef HAVE_LIBELF_SUPPORT bool elf__needs_adjust_symbols(GElf_Ehdr ehdr) diff --git a/tools/perf/tests/thread-mg-share.c b/tools/perf/tests/thread-mg-share.c index b1d1bbafe7ae..cbac71716dec 100644 --- a/tools/perf/tests/thread-mg-share.c +++ b/tools/perf/tests/thread-mg-share.c @@ -2,7 +2,6 @@ #include "tests.h" #include "machine.h" #include "thread.h" -#include "map.h" #include "debug.h" int test__thread_mg_share(struct test *test __maybe_unused, int subtest __maybe_unused) diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index a30427aa1de0..aacffa2b0362 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -19,7 +19,6 @@ #include "evsel.h" #include "evlist.h" #include "machine.h" -#include "map.h" #include "symbol.h" #include "session.h" #include "tool.h" From 4becb2395f9166b11d68817ed4af8fc06b840908 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 12:13:45 -0300 Subject: [PATCH 32/47] perf tools: Remove needless thread.h include directives Now that thread.h isn't included by any other header, we can check where it is really needed, i.e. we can remove it and be sure that it isn't being obtained indirectly. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-kh333ivjbw05wsggckpziu86@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-annotate.c | 1 - tools/perf/builtin-stat.c | 1 - tools/perf/builtin-top.c | 1 - tools/perf/tests/hists_filter.c | 1 - tools/perf/tests/hists_link.c | 1 - tools/perf/util/arm-spe.c | 1 - tools/perf/util/probe-event.c | 1 - tools/perf/util/probe-file.c | 1 - tools/perf/util/s390-cpumsf.c | 1 - 9 files changed, 9 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 738471a0a549..7135b77a18e7 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -24,7 +24,6 @@ #include "util/event.h" #include #include "util/parse-events.h" -#include "util/thread.h" #include "util/sort.h" #include "util/hist.h" #include "util/dso.h" diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index fa4212dac9bb..7e17bf9f700a 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -54,7 +54,6 @@ #include "util/stat.h" #include "util/header.h" #include "util/cpumap.h" -#include "util/thread.h" #include "util/thread_map.h" #include "util/counts.h" #include "util/group.h" diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 0f0d96262d14..eb941213fa0c 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -32,7 +32,6 @@ #include "util/map.h" #include "util/session.h" #include "util/symbol.h" -#include "util/thread.h" #include "util/thread_map.h" #include "util/top.h" #include "util/util.h" diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c index 41dede2f40d8..618b51ffcc01 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c @@ -7,7 +7,6 @@ #include "util/event.h" #include "util/evlist.h" #include "util/machine.h" -#include "util/thread.h" #include "util/parse-events.h" #include "tests/tests.h" #include "tests/hists_common.h" diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c index 012fe8ac0b24..8be4d0b61e3a 100644 --- a/tools/perf/tests/hists_link.c +++ b/tools/perf/tests/hists_link.c @@ -6,7 +6,6 @@ #include "evsel.h" #include "evlist.h" #include "machine.h" -#include "thread.h" #include "parse-events.h" #include "hists_common.h" #include diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index d7c3fbb3694f..6bee59946c4f 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -20,7 +20,6 @@ #include "evlist.h" #include "machine.h" #include "session.h" -#include "thread.h" #include "debug.h" #include "auxtrace.h" #include "arm-spe.h" diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 5d12a78c8ac8..e90faa6bb5aa 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -31,7 +31,6 @@ #include "map.h" #include "map_groups.h" #include "symbol.h" -#include "thread.h" #include #include "trace-event.h" /* For __maybe_unused */ #include "probe-event.h" diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 10d2ab179c71..adc949e8314f 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -20,7 +20,6 @@ #include "cache.h" #include "color.h" #include "symbol.h" -#include "thread.h" #include #include "probe-event.h" #include "probe-file.h" diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 2ba4baa2c52f..24a99909d8b3 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -158,7 +158,6 @@ #include "machine.h" #include "session.h" #include "tool.h" -#include "thread.h" #include "debug.h" #include "auxtrace.h" #include "s390-cpumsf.h" From ef7d95661d046eddf2cf33847278781404679a2f Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 12:18:50 -0300 Subject: [PATCH 33/47] perf tools: Remove needless thread_map.h include directives Now that thread_map.h isn't included by any other header, we can check where it is really needed, i.e. we can remove it and be sure that it isn't being obtained indirectly. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-fyzvg64cz1ikvyxp8d6nrhz1@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm/util/cs-etm.c | 1 - tools/perf/builtin-top.c | 1 - tools/perf/util/cs-etm.c | 1 - 3 files changed, 3 deletions(-) diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 197041fcba25..59e44f90dc46 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -24,7 +24,6 @@ #include "../../util/evlist.h" #include "../../util/evsel.h" #include "../../util/pmu.h" -#include "../../util/thread_map.h" #include "../../util/cs-etm.h" #include "../../util/util.h" diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index eb941213fa0c..726e3f2dd8c7 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -32,7 +32,6 @@ #include "util/map.h" #include "util/session.h" #include "util/symbol.h" -#include "util/thread_map.h" #include "util/top.h" #include "util/util.h" #include diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 3ed1d3bb7089..30c2048ce67d 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -30,7 +30,6 @@ #include "symbol.h" #include "tool.h" #include "thread.h" -#include "thread_map.h" #include "thread-stack.h" #include #include "util.h" From 7ae811b12e419fd70b7d7159f20ed8519bbe18cc Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 12:29:03 -0300 Subject: [PATCH 34/47] perf tools: Remove needless evlist.h include directives Now that evlist.h isn't included by any other header, we can check where it is really needed, i.e. we can remove it and be sure that it isn't being obtained indirectly. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-6d7kape36m94a266md0d3xbh@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-lock.c | 2 +- tools/perf/builtin-timechart.c | 2 +- tools/perf/tests/hists_common.c | 1 - tools/perf/tests/sdt.c | 3 ++- tools/perf/ui/gtk/browser.c | 1 - tools/perf/util/arm-spe.c | 3 ++- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 38500bff4423..b0ff952be9db 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -4,7 +4,7 @@ #include "builtin.h" #include "perf.h" -#include "util/evlist.h" +#include "util/evlist.h" // for struct evsel_str_handler #include "util/evsel.h" #include "util/cache.h" #include "util/symbol.h" diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 1a74499f3311..65560a86f643 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -15,7 +15,7 @@ #include "util/color.h" #include #include "util/cache.h" -#include "util/evlist.h" +#include "util/evlist.h" // for struct evsel_str_handler #include "util/evsel.h" #include #include diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c index cdde41c03056..de110d8f169b 100644 --- a/tools/perf/tests/hists_common.c +++ b/tools/perf/tests/hists_common.c @@ -6,7 +6,6 @@ #include "util/symbol.h" #include "util/sort.h" #include "util/evsel.h" -#include "util/evlist.h" #include "util/machine.h" #include "util/thread.h" #include "tests/hists_common.h" diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c index dbc35a8912ed..cf1bd57d3023 100644 --- a/tools/perf/tests/sdt.c +++ b/tools/perf/tests/sdt.c @@ -1,8 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include +#include #include -#include #include #include #include "tests.h" diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c index 4820e25ac68d..06a6a1ebaef0 100644 --- a/tools/perf/ui/gtk/browser.c +++ b/tools/perf/ui/gtk/browser.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include "../evlist.h" #include "../cache.h" #include "../evsel.h" #include "../sort.h" diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 6bee59946c4f..8a7340f6a2a2 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include #include @@ -17,7 +19,6 @@ #include "cpumap.h" #include "color.h" #include "evsel.h" -#include "evlist.h" #include "machine.h" #include "session.h" #include "debug.h" From fa0d98462fae5d4951f22f3ac1090d48c53396d1 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 12:52:25 -0300 Subject: [PATCH 35/47] perf tools: Remove needless evlist.h include directives Remove the last unneeded use of cache.h in a header, we can check where it is really needed, i.e. we can remove it and be sure that it isn't being obtained indirectly. This is an old file, used by now incorrectly in many places, so it was providing includes needed indirectly, fixup this fallout. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-3x3l8gihoaeh7714os861ia7@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-buildid-cache.c | 3 ++- tools/perf/builtin-buildid-list.c | 2 +- tools/perf/builtin-kvm.c | 4 +++- tools/perf/builtin-list.c | 2 +- tools/perf/builtin-lock.c | 2 +- tools/perf/builtin-sched.c | 2 +- tools/perf/builtin-script.c | 2 +- tools/perf/builtin-timechart.c | 2 +- tools/perf/perf.c | 2 +- tools/perf/tests/llvm.c | 2 +- tools/perf/ui/browsers/header.c | 1 - tools/perf/ui/gtk/browser.c | 1 - tools/perf/ui/gtk/hists.c | 1 - tools/perf/ui/gtk/setup.c | 1 - tools/perf/ui/helpline.h | 2 -- tools/perf/ui/progress.c | 1 - tools/perf/ui/setup.c | 3 ++- tools/perf/ui/tui/helpline.c | 1 + tools/perf/ui/tui/progress.c | 1 - tools/perf/ui/tui/setup.c | 2 -- tools/perf/ui/tui/util.c | 1 - tools/perf/util/annotate.c | 1 - tools/perf/util/color.c | 3 ++- tools/perf/util/color_config.c | 3 ++- tools/perf/util/debug.c | 2 +- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 +- tools/perf/util/parse-events.c | 2 +- tools/perf/util/path.c | 3 ++- tools/perf/util/path.h | 3 +++ tools/perf/util/pmu.c | 3 ++- tools/perf/util/probe-event.c | 3 ++- tools/perf/util/probe-file.c | 2 +- 32 files changed, 33 insertions(+), 32 deletions(-) diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index b035911969b8..1a69eb565dc0 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c @@ -15,9 +15,9 @@ #include #include "builtin.h" #include "namespaces.h" -#include "util/cache.h" #include "util/debug.h" #include "util/header.h" +#include #include #include "util/strlist.h" #include "util/build-id.h" @@ -27,6 +27,7 @@ #include "util/time-utils.h" #include "util/util.h" #include "util/probe-file.h" +#include static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid) { diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index 38b2ec61c021..5a0d8b378cb5 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c @@ -10,9 +10,9 @@ #include "builtin.h" #include "perf.h" #include "util/build-id.h" -#include "util/cache.h" #include "util/debug.h" #include "util/dso.h" +#include #include #include "util/session.h" #include "util/symbol.h" diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 474c4799d29d..0a4fcbe32bf6 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -6,12 +6,12 @@ #include "util/evsel.h" #include "util/evlist.h" #include "util/term.h" -#include "util/cache.h" #include "util/symbol.h" #include "util/thread.h" #include "util/header.h" #include "util/session.h" #include "util/intlist.h" +#include #include #include "util/trace-event.h" #include "util/debug.h" @@ -20,6 +20,7 @@ #include "util/top.h" #include "util/data.h" #include "util/ordered-events.h" +#include "ui/ui.h" #include #ifdef HAVE_TIMERFD_SUPPORT @@ -31,6 +32,7 @@ #include #include +#include #include #include #include diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c index 11afb760616b..e290f6b348d8 100644 --- a/tools/perf/builtin-list.c +++ b/tools/perf/builtin-list.c @@ -11,10 +11,10 @@ #include "builtin.h" #include "util/parse-events.h" -#include "util/cache.h" #include "util/pmu.h" #include "util/debug.h" #include "util/metricgroup.h" +#include #include #include diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index b0ff952be9db..4c2b7f437cdf 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -6,11 +6,11 @@ #include "util/evlist.h" // for struct evsel_str_handler #include "util/evsel.h" -#include "util/cache.h" #include "util/symbol.h" #include "util/thread.h" #include "util/header.h" +#include #include #include "util/trace-event.h" diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 91d0a9b10581..ec96d64aec69 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -4,7 +4,6 @@ #include "perf-sys.h" #include "util/evlist.h" -#include "util/cache.h" #include "util/evsel.h" #include "util/symbol.h" #include "util/thread.h" @@ -19,6 +18,7 @@ #include "util/callchain.h" #include "util/time-utils.h" +#include #include #include "util/trace-event.h" diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 1ff04b00a561..e079b34201f2 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "builtin.h" -#include "util/cache.h" #include "util/counts.h" #include "util/debug.h" #include "util/dso.h" @@ -30,6 +29,7 @@ #include "util/thread-stack.h" #include "util/time-utils.h" #include "util/path.h" +#include "ui/ui.h" #include "print_binary.h" #include "archinsn.h" #include diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 65560a86f643..e0e822695a29 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -14,7 +14,6 @@ #include "builtin.h" #include "util/color.h" #include -#include "util/cache.h" #include "util/evlist.h" // for struct evsel_str_handler #include "util/evsel.h" #include @@ -27,6 +26,7 @@ #include "perf.h" #include "util/header.h" +#include #include #include "util/parse-events.h" #include "util/event.h" diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 8763b2c0fbfd..1193b923e801 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -1,4 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 /* * perf.c * @@ -22,6 +21,7 @@ #include "util/debug.h" #include "util/event.h" #include "util/util.h" +#include "ui/ui.h" #include "perf-sys.h" #include #include diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c index ca5a5f94ce79..022e4c9cf092 100644 --- a/tools/perf/tests/llvm.c +++ b/tools/perf/tests/llvm.c @@ -1,9 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include #include -#include #include "llvm.h" #include "tests.h" #include "debug.h" diff --git a/tools/perf/ui/browsers/header.c b/tools/perf/ui/browsers/header.c index 5aeb663dd184..0f59a7001479 100644 --- a/tools/perf/ui/browsers/header.c +++ b/tools/perf/ui/browsers/header.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include "util/cache.h" #include "util/debug.h" #include "ui/browser.h" #include "ui/keysyms.h" diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c index 06a6a1ebaef0..8f3e43d148a8 100644 --- a/tools/perf/ui/gtk/browser.c +++ b/tools/perf/ui/gtk/browser.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include "../cache.h" #include "../evsel.h" #include "../sort.h" #include "../hist.h" diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index 0efdb226d1a7..6c2efc10bf5c 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 #include "../evlist.h" -#include "../cache.h" #include "../callchain.h" #include "../evsel.h" #include "../sort.h" diff --git a/tools/perf/ui/gtk/setup.c b/tools/perf/ui/gtk/setup.c index 506e73b3834c..1a2616b97b5c 100644 --- a/tools/perf/ui/gtk/setup.c +++ b/tools/perf/ui/gtk/setup.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 #include "gtk.h" -#include "../../util/cache.h" #include "../../util/debug.h" extern struct perf_error_ops perf_gtk_eops; diff --git a/tools/perf/ui/helpline.h b/tools/perf/ui/helpline.h index 8f775a053ca3..2165a098dee8 100644 --- a/tools/perf/ui/helpline.h +++ b/tools/perf/ui/helpline.h @@ -5,8 +5,6 @@ #include #include -#include "../util/cache.h" - struct ui_helpline { void (*pop)(void); void (*push)(const char *msg); diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/progress.c index 8cd3b64c6893..99d60223c74b 100644 --- a/tools/perf/ui/progress.c +++ b/tools/perf/ui/progress.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 #include -#include "../util/cache.h" #include "progress.h" static void null_progress__update(struct ui_progress *p __maybe_unused) diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c index 3bc7c9a6fae9..c7a86b4be9f5 100644 --- a/tools/perf/ui/setup.c +++ b/tools/perf/ui/setup.c @@ -2,10 +2,11 @@ #include #include -#include "../util/cache.h" +#include #include "../util/debug.h" #include "../util/hist.h" #include "../util/util.h" +#include "ui.h" pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; void *perf_gtk_handle; diff --git a/tools/perf/ui/tui/helpline.c b/tools/perf/ui/tui/helpline.c index 1793c98653a5..5f188f678c55 100644 --- a/tools/perf/ui/tui/helpline.c +++ b/tools/perf/ui/tui/helpline.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "../../util/debug.h" #include "../helpline.h" diff --git a/tools/perf/ui/tui/progress.c b/tools/perf/ui/tui/progress.c index 5a24dd3ce4db..3d74af5a7ece 100644 --- a/tools/perf/ui/tui/progress.c +++ b/tools/perf/ui/tui/progress.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 #include -#include "../../util/cache.h" #include "../progress.h" #include "../libslang.h" #include "../ui.h" diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c index 2881982b483c..56651a4f5aa0 100644 --- a/tools/perf/ui/tui/setup.c +++ b/tools/perf/ui/tui/setup.c @@ -1,4 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 #include #include #include @@ -8,7 +7,6 @@ #include #endif -#include "../../util/cache.h" #include "../../util/debug.h" #include "../../util/util.h" #include "../../perf.h" diff --git a/tools/perf/ui/tui/util.c b/tools/perf/ui/tui/util.c index 1163df8b6f06..087d9ab054c8 100644 --- a/tools/perf/ui/tui/util.c +++ b/tools/perf/ui/tui/util.c @@ -5,7 +5,6 @@ #include #include -#include "../../util/cache.h" #include "../../util/debug.h" #include "../browser.h" #include "../keysyms.h" diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 67a7513077d0..eb3c50de831d 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -19,7 +19,6 @@ #include "build-id.h" #include "color.h" #include "config.h" -#include "cache.h" #include "dso.h" #include "map.h" #include "symbol.h" diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c index 39b8c4ec4e2e..bffbdd216a6a 100644 --- a/tools/perf/util/color.c +++ b/tools/perf/util/color.c @@ -1,8 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 #include -#include "cache.h" +#include #include #include +#include #include "color.h" #include #include diff --git a/tools/perf/util/color_config.c b/tools/perf/util/color_config.c index 817dc56e7e95..dc09ba7cb31e 100644 --- a/tools/perf/util/color_config.c +++ b/tools/perf/util/color_config.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include -#include "cache.h" +#include +#include #include "config.h" #include #include diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 143d379d4608..a1b59bd35519 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -13,7 +13,6 @@ #ifdef HAVE_BACKTRACE_SUPPORT #include #endif -#include "cache.h" #include "color.h" #include "event.h" #include "debug.h" @@ -21,6 +20,7 @@ #include "util.h" #include "target.h" #include "ui/helpline.h" +#include "ui/ui.h" #include diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c index 3bfdf2b7a96a..f8ccfd6be0ee 100644 --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c @@ -14,9 +14,9 @@ #include #include #include +#include #include -#include "../cache.h" #include "../auxtrace.h" #include "intel-pt-insn-decoder.h" diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 523af1bd82e6..5ec21d21113c 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -13,13 +13,13 @@ #include "build-id.h" #include "evlist.h" #include "evsel.h" +#include #include #include "parse-events.h" #include #include "string2.h" #include "strlist.h" #include "symbol.h" -#include "cache.h" #include "header.h" #include "bpf-loader.h" #include "debug.h" diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c index ca56ba2dd3da..caed0336429f 100644 --- a/tools/perf/util/path.c +++ b/tools/perf/util/path.c @@ -11,11 +11,12 @@ * * which is what it's designed for. */ -#include "cache.h" #include "path.h" +#include "cache.h" #include #include #include +#include #include #include #include diff --git a/tools/perf/util/path.h b/tools/perf/util/path.h index f014f905df50..083429b7efa3 100644 --- a/tools/perf/util/path.h +++ b/tools/perf/util/path.h @@ -2,6 +2,9 @@ #ifndef _PERF_PATH_H #define _PERF_PATH_H +#include +#include + struct dirent; int path__join(char *bf, size_t size, const char *path1, const char *path2); diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 9807be6f09bb..6b3448f6eb94 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -22,8 +23,8 @@ #include "cpumap.h" #include "header.h" #include "pmu-events/pmu-events.h" -#include "cache.h" #include "string2.h" +#include "strbuf.h" struct perf_pmu_format { char *name; diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index e90faa6bb5aa..b8e0967c5c21 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -26,7 +26,6 @@ #include "strfilter.h" #include "debug.h" #include "dso.h" -#include "cache.h" #include "color.h" #include "map.h" #include "map_groups.h" @@ -38,7 +37,9 @@ #include "probe-file.h" #include "session.h" #include "string2.h" +#include "strbuf.h" +#include #include #include diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index adc949e8314f..d13db55a2feb 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -17,9 +17,9 @@ #include "strfilter.h" #include "debug.h" #include "dso.h" -#include "cache.h" #include "color.h" #include "symbol.h" +#include "strbuf.h" #include #include "probe-event.h" #include "probe-file.h" From f2a39fe84901df2b3d1bec3459b65cee3e8db57c Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 14:45:20 -0300 Subject: [PATCH 36/47] perf auxtrace: Uninline functions that touch perf_session So that we don't carry the session.h include directive in auxtrace.h, which in turn opens a can of worms of files that were getting all sorts of things via that include, fix them all. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-d2d83aovpgri2z75wlitquni@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm/annotate/instructions.c | 1 + tools/perf/arch/arm/util/cs-etm.c | 1 + tools/perf/arch/arm64/annotate/instructions.c | 1 + tools/perf/arch/x86/tests/perf-time-to-tsc.c | 1 + tools/perf/builtin-ftrace.c | 1 + tools/perf/tests/backward-ring-buffer.c | 1 + tools/perf/tests/bpf.c | 1 + tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/code-reading.c | 6 +++ tools/perf/tests/event-times.c | 1 + tools/perf/tests/event_update.c | 2 + tools/perf/tests/keep-tracking.c | 1 + tools/perf/tests/mmap-basic.c | 1 + tools/perf/tests/parse-events.c | 1 + tools/perf/tests/switch-tracking.c | 1 + tools/perf/ui/browsers/hists.c | 1 + tools/perf/ui/browsers/res_sample.c | 2 + tools/perf/ui/browsers/scripts.c | 1 + tools/perf/ui/hist.c | 2 + tools/perf/ui/stdio/hist.c | 1 + tools/perf/util/annotate.c | 3 ++ tools/perf/util/auxtrace.c | 33 ++++++++++++++ tools/perf/util/auxtrace.h | 43 +++---------------- tools/perf/util/bpf-loader.c | 1 + tools/perf/util/cgroup.c | 2 + tools/perf/util/config.c | 1 + tools/perf/util/cs-etm.c | 1 + tools/perf/util/cs-etm.h | 3 +- tools/perf/util/dso.c | 2 + tools/perf/util/evlist.c | 1 + tools/perf/util/evsel.c | 1 + tools/perf/util/machine.c | 2 + tools/perf/util/mmap.c | 3 ++ tools/perf/util/mmap.h | 1 + tools/perf/util/python.c | 2 + tools/perf/util/record.c | 2 + tools/perf/util/s390-sample-raw.c | 1 - tools/perf/util/sort.c | 1 + tools/perf/util/stat-display.c | 1 + tools/perf/util/stat.c | 3 ++ tools/perf/util/top.h | 1 + 41 files changed, 98 insertions(+), 38 deletions(-) diff --git a/tools/perf/arch/arm/annotate/instructions.c b/tools/perf/arch/arm/annotate/instructions.c index c7d1a69b894f..e1d4b484cc4b 100644 --- a/tools/perf/arch/arm/annotate/instructions.c +++ b/tools/perf/arch/arm/annotate/instructions.c @@ -3,6 +3,7 @@ #include #include #include +#include struct arm_annotate { regex_t call_insn, diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 59e44f90dc46..c32db09baf0d 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -26,6 +26,7 @@ #include "../../util/pmu.h" #include "../../util/cs-etm.h" #include "../../util/util.h" +#include "../../util/session.h" #include #include diff --git a/tools/perf/arch/arm64/annotate/instructions.c b/tools/perf/arch/arm64/annotate/instructions.c index 8f70a1b282df..43aa93ed8414 100644 --- a/tools/perf/arch/arm64/annotate/instructions.c +++ b/tools/perf/arch/arm64/annotate/instructions.c @@ -2,6 +2,7 @@ #include #include #include +#include struct arm64_annotate { regex_t call_insn, diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/arch/x86/tests/perf-time-to-tsc.c index 2d1f4713b728..eb3635941c2b 100644 --- a/tools/perf/arch/x86/tests/perf-time-to-tsc.c +++ b/tools/perf/arch/x86/tests/perf-time-to-tsc.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include #include #include diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 2f8ea44c00c4..d5adc417a4ca 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c index 512288e9f547..a637a4a90760 100644 --- a/tools/perf/tests/backward-ring-buffer.c +++ b/tools/perf/tests/backward-ring-buffer.c @@ -9,6 +9,7 @@ #include "record.h" #include "tests.h" #include "debug.h" +#include "parse-events.h" #include #include diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c index 9fc163b2acbb..fc102e4f403e 100644 --- a/tools/perf/tests/bpf.c +++ b/tools/perf/tests/bpf.c @@ -18,6 +18,7 @@ #include "tests.h" #include "llvm.h" #include "debug.h" +#include "parse-events.h" #define NR_ITERS 111 #define PERF_TEST_BPF_PATH "/sys/fs/bpf/perf_test" diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index c3bec9d2c201..55774baffc2a 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index 7b2b89f4b716..c1c29e08e7fb 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -13,7 +13,9 @@ #include "debug.h" #include "dso.h" +#include "env.h" #include "parse-events.h" +#include "trace-event.h" #include "evlist.h" #include "evsel.h" #include "thread_map.h" @@ -496,6 +498,10 @@ static void fs_something(void) } } +#ifdef __s390x__ +#include "header.h" // for get_cpuid() +#endif + static const char *do_determine_event(bool excl_kernel) { const char *event = excl_kernel ? "cycles:u" : "cycles"; diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c index 228d1618cf7d..d824a726906c 100644 --- a/tools/perf/tests/event-times.c +++ b/tools/perf/tests/event-times.c @@ -11,6 +11,7 @@ #include "evsel.h" #include "util.h" #include "debug.h" +#include "parse-events.h" #include "thread_map.h" #include "target.h" diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_update.c index 4b68ec3a13fc..cac4290e233a 100644 --- a/tools/perf/tests/event_update.c +++ b/tools/perf/tests/event_update.c @@ -1,8 +1,10 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include "evlist.h" #include "evsel.h" +#include "header.h" #include "machine.h" #include "tool.h" #include "tests.h" diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c index c758798d3774..9f0762d987fa 100644 --- a/tools/perf/tests/keep-tracking.c +++ b/tools/perf/tests/keep-tracking.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index bdf77bfe1b80..85e1d7337dc0 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c @@ -3,6 +3,7 @@ #include /* For the CLR_() macros */ #include +#include #include #include "debug.h" diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 49f52e4de41b..02ba696fb87f 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -5,6 +5,7 @@ #include #include "tests.h" #include "debug.h" +#include "pmu.h" #include "util.h" #include #include diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c index 4bed15aee1a8..1a60fa1219f5 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index cf8857456056..f7e54c16e594 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -16,6 +16,7 @@ #include "../../util/callchain.h" #include "../../util/evsel.h" #include "../../util/evlist.h" +#include "../../util/header.h" #include "../../util/hist.h" #include "../../util/map.h" #include "../../util/symbol.h" diff --git a/tools/perf/ui/browsers/res_sample.c b/tools/perf/ui/browsers/res_sample.c index db3954fea74c..f16a38fea45e 100644 --- a/tools/perf/ui/browsers/res_sample.c +++ b/tools/perf/ui/browsers/res_sample.c @@ -9,6 +9,8 @@ #include "../util.h" #include "../../util/util.h" #include "../../perf.h" +#include +#include #include #include diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c index bf1d9f9ec035..586a21acc13d 100644 --- a/tools/perf/ui/browsers/scripts.c +++ b/tools/perf/ui/browsers/scripts.c @@ -10,6 +10,7 @@ #include "config.h" #include #include +#include #define SCRIPT_NAMELEN 128 #define SCRIPT_MAX_NO 64 diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index bf90ce5b2cdf..3e533de7d852 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include +#include #include #include "../util/callchain.h" diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 51ed67548b83..832ca6cfbe30 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include "../../util/callchain.h" diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index eb3c50de831d..1748f528b6e9 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -20,7 +21,9 @@ #include "color.h" #include "config.h" #include "dso.h" +#include "env.h" #include "map.h" +#include "map_groups.h" #include "symbol.h" #include "srcline.h" #include "units.h" diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 10c707724035..6f25224a3def 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -2196,3 +2196,36 @@ int auxtrace_parse_filters(struct evlist *evlist) return 0; } + +int auxtrace__process_event(struct perf_session *session, union perf_event *event, + struct perf_sample *sample, struct perf_tool *tool) +{ + if (!session->auxtrace) + return 0; + + return session->auxtrace->process_event(session, event, sample, tool); +} + +int auxtrace__flush_events(struct perf_session *session, struct perf_tool *tool) +{ + if (!session->auxtrace) + return 0; + + return session->auxtrace->flush_events(session, tool); +} + +void auxtrace__free_events(struct perf_session *session) +{ + if (!session->auxtrace) + return; + + return session->auxtrace->free_events(session); +} + +void auxtrace__free(struct perf_session *session) +{ + if (!session->auxtrace) + return; + + return session->auxtrace->free(session); +} diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index c539e7b6ed56..37e70dc01436 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -18,7 +18,6 @@ #include #include "event.h" -#include "session.h" union perf_event; struct perf_session; @@ -380,6 +379,8 @@ struct addr_filters { int cnt; }; +struct auxtrace_cache; + #ifdef HAVE_AUXTRACE_SUPPORT /* @@ -549,41 +550,11 @@ int addr_filters__parse_bare_filter(struct addr_filters *filts, const char *filter); int auxtrace_parse_filters(struct evlist *evlist); -static inline int auxtrace__process_event(struct perf_session *session, - union perf_event *event, - struct perf_sample *sample, - struct perf_tool *tool) -{ - if (!session->auxtrace) - return 0; - - return session->auxtrace->process_event(session, event, sample, tool); -} - -static inline int auxtrace__flush_events(struct perf_session *session, - struct perf_tool *tool) -{ - if (!session->auxtrace) - return 0; - - return session->auxtrace->flush_events(session, tool); -} - -static inline void auxtrace__free_events(struct perf_session *session) -{ - if (!session->auxtrace) - return; - - return session->auxtrace->free_events(session); -} - -static inline void auxtrace__free(struct perf_session *session) -{ - if (!session->auxtrace) - return; - - return session->auxtrace->free(session); -} +int auxtrace__process_event(struct perf_session *session, union perf_event *event, + struct perf_sample *sample, struct perf_tool *tool); +int auxtrace__flush_events(struct perf_session *session, struct perf_tool *tool); +void auxtrace__free_events(struct perf_session *session); +void auxtrace__free(struct perf_session *session); #define ITRACE_HELP \ " i: synthesize instructions events\n" \ diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index c1a57323e25d..37283e865352 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "debug.h" #include "evlist.h" #include "bpf-loader.h" diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index 96a931c6f728..4881d4af3381 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include int nr_cgroups; diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 7ebf9e31ae22..0bc9c4d7fdc5 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -23,6 +23,7 @@ #include "debug.h" #include #include +#include #include #include #include diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 30c2048ce67d..0174ecf757d7 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -27,6 +27,7 @@ #include "machine.h" #include "map.h" #include "perf.h" +#include "session.h" #include "symbol.h" #include "tool.h" #include "thread.h" diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h index bc848fd095f4..650ecc2a6349 100644 --- a/tools/perf/util/cs-etm.h +++ b/tools/perf/util/cs-etm.h @@ -8,9 +8,10 @@ #define INCLUDE__UTIL_PERF_CS_ETM_H__ #include "util/event.h" -#include "util/session.h" #include +struct perf_session; + /* Versionning header in case things need tro change in the future. That way * decoding of old snapshot is still possible. */ diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index ece97209792d..e11ddf86f2b3 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -10,9 +10,11 @@ #include #include #include +#include #include #include "bpf-event.h" #include "compress.h" +#include "env.h" #include "namespaces.h" #include "path.h" #include "map.h" diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index b5d6d6ec9a9b..095924aa186b 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "parse-events.h" #include diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index b6b406a1678f..85825384f9e8 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "asm/bug.h" #include "callchain.h" diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 003025465198..6a77aefbe319 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -3,9 +3,11 @@ #include #include #include +#include #include "callchain.h" #include "debug.h" #include "dso.h" +#include "env.h" #include "event.h" #include "evsel.h" #include "hist.h" diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index 28477ff5114e..33c5b5495482 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -10,9 +10,12 @@ #include #include #include +#include +#include #ifdef HAVE_LIBNUMA_SUPPORT #include #endif +#include "cpumap.h" #include "debug.h" #include "event.h" #include "mmap.h" diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index 274ce389cd84..3857a49e8f96 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h @@ -6,6 +6,7 @@ #include #include #include +#include // for cpu_set_t #ifdef HAVE_AIO_SUPPORT #include #endif diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 9b350482c403..07ca4535e6f7 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "debug.h" #include "evlist.h" #include "callchain.h" @@ -13,6 +14,7 @@ #include "cpumap.h" #include "print_binary.h" #include "thread_map.h" +#include "trace-event.h" #include "mmap.h" #include "util.h" #include "../perf-sys.h" diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index ccad796bce5f..286fe816c0f3 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c @@ -5,6 +5,8 @@ #include "cpumap.h" #include "parse-events.h" #include +#include +#include #include #include #include diff --git a/tools/perf/util/s390-sample-raw.c b/tools/perf/util/s390-sample-raw.c index d311c81464e5..0ddfa7b3e4f2 100644 --- a/tools/perf/util/s390-sample-raw.c +++ b/tools/perf/util/s390-sample-raw.c @@ -23,7 +23,6 @@ #include "debug.h" #include "util.h" -#include "auxtrace.h" #include "session.h" #include "evlist.h" #include "config.h" diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 32ade5a1b553..b974a2c3a3c5 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include "debug.h" diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 1461dac2322d..ed3b0ac2f785 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index f4a1edcec7b2..8f1ea27f976f 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -2,9 +2,12 @@ #include #include #include +#include #include "counts.h" #include "debug.h" +#include "header.h" #include "stat.h" +#include "session.h" #include "target.h" #include "evlist.h" #include "evsel.h" diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index 7367433e767a..f117d4f4821e 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h @@ -5,6 +5,7 @@ #include "tool.h" #include "evswitch.h" #include "annotate.h" +#include "ordered-events.h" #include "record.h" #include #include From d3300a3c4e76ccecf4daa889327e340a870c550b Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 30 Aug 2019 15:09:54 -0300 Subject: [PATCH 37/47] perf symbols: Move mem_info and branch_info out of symbol.h The mem_info struct goes to mem-events.h and branch_info goes to branch.h, where they belong, this way we can remove several headers from symbols.h and trim the include dependency tree more. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-aupw71xnravcsu2xoabfmhpc@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/powerpc/util/mem-events.c | 1 + tools/perf/builtin-annotate.c | 2 ++ tools/perf/builtin-c2c.c | 1 + tools/perf/builtin-mem.c | 1 + tools/perf/builtin-report.c | 3 +++ tools/perf/builtin-version.c | 2 +- tools/perf/tests/mem.c | 1 + tools/perf/tests/sample-parsing.c | 1 + tools/perf/ui/browsers/hists.c | 2 ++ tools/perf/util/branch.c | 1 + tools/perf/util/branch.h | 8 ++++++++ tools/perf/util/cs-etm.c | 2 ++ tools/perf/util/hist.c | 3 +++ tools/perf/util/machine.c | 3 +++ tools/perf/util/map.c | 1 + tools/perf/util/mem-events.c | 1 + tools/perf/util/mem-events.h | 9 +++++++++ tools/perf/util/s390-sample-raw.c | 1 - tools/perf/util/session.c | 2 ++ tools/perf/util/sort.c | 2 ++ tools/perf/util/symbol.c | 2 ++ tools/perf/util/symbol.h | 17 ----------------- 22 files changed, 47 insertions(+), 19 deletions(-) diff --git a/tools/perf/arch/powerpc/util/mem-events.c b/tools/perf/arch/powerpc/util/mem-events.c index d08311f04e95..07fb5e049488 100644 --- a/tools/perf/arch/powerpc/util/mem-events.c +++ b/tools/perf/arch/powerpc/util/mem-events.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 +#include "map_symbol.h" #include "mem-events.h" /* PowerPC does not support 'ldlat' parameter. */ diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 7135b77a18e7..4e4d2e76232e 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -33,6 +33,8 @@ #include "util/data.h" #include "arch/common.h" #include "util/block-range.h" +#include "util/map_symbol.h" +#include "util/branch.h" #include #include diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 0d76b2cb8c0a..b09b12e0976b 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -22,6 +22,7 @@ #include "builtin.h" #include #include +#include "map_symbol.h" #include "mem-events.h" #include "session.h" #include "hist.h" diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index c5f3b9e9509d..27d2bde943a8 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -11,6 +11,7 @@ #include "util/tool.h" #include "util/session.h" #include "util/data.h" +#include "util/map_symbol.h" #include "util/mem-events.h" #include "util/debug.h" #include "util/dso.h" diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index d7a345667945..b18fab94d38d 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -19,6 +19,9 @@ #include #include "util/map.h" #include "util/symbol.h" +#include "util/map_symbol.h" +#include "util/mem-events.h" +#include "util/branch.h" #include "util/callchain.h" #include "util/values.h" diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c index bf114ca9ca87..05cf2af9e2c2 100644 --- a/tools/perf/builtin-version.c +++ b/tools/perf/builtin-version.c @@ -2,8 +2,8 @@ #include "builtin.h" #include "perf.h" #include "color.h" -#include #include +#include #include #include #include diff --git a/tools/perf/tests/mem.c b/tools/perf/tests/mem.c index efe3397824d2..673a11a6cd1b 100644 --- a/tools/perf/tests/mem.c +++ b/tools/perf/tests/mem.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 +#include "util/map_symbol.h" #include "util/mem-events.h" #include "util/symbol.h" #include "linux/perf_event.h" diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c index 0c09dc15a059..5fcc06817076 100644 --- a/tools/perf/tests/sample-parsing.c +++ b/tools/perf/tests/sample-parsing.c @@ -7,6 +7,7 @@ #include #include +#include "map_symbol.h" #include "branch.h" #include "util.h" #include "event.h" diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index f7e54c16e594..589168ca9f62 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -20,6 +20,8 @@ #include "../../util/hist.h" #include "../../util/map.h" #include "../../util/symbol.h" +#include "../../util/map_symbol.h" +#include "../../util/branch.h" #include "../../util/pstack.h" #include "../../util/sort.h" #include "../../util/top.h" diff --git a/tools/perf/util/branch.c b/tools/perf/util/branch.c index 30642e1f2b1b..9d1e090084a2 100644 --- a/tools/perf/util/branch.c +++ b/tools/perf/util/branch.c @@ -1,5 +1,6 @@ #include "util/util.h" #include "util/debug.h" +#include "util/map_symbol.h" #include "util/branch.h" #include diff --git a/tools/perf/util/branch.h b/tools/perf/util/branch.h index 64f96b79f1d7..06f66dad0b79 100644 --- a/tools/perf/util/branch.h +++ b/tools/perf/util/branch.h @@ -16,6 +16,14 @@ struct branch_flags { u64 reserved:40; }; +struct branch_info { + struct addr_map_symbol from; + struct addr_map_symbol to; + struct branch_flags flags; + char *srcline_from; + char *srcline_to; +}; + struct branch_entry { u64 from; u64 to; diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 0174ecf757d7..707afdbd9529 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -28,6 +28,8 @@ #include "map.h" #include "perf.h" #include "session.h" +#include "map_symbol.h" +#include "branch.h" #include "symbol.h" #include "tool.h" #include "thread.h" diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 0978dc4a33db..679a1d75090c 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -5,6 +5,9 @@ #include "build-id.h" #include "hist.h" #include "map.h" +#include "map_symbol.h" +#include "branch.h" +#include "mem-events.h" #include "session.h" #include "namespaces.h" #include "sort.h" diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 6a77aefbe319..b4749d3eed08 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -13,6 +13,9 @@ #include "hist.h" #include "machine.h" #include "map.h" +#include "map_symbol.h" +#include "branch.h" +#include "mem-events.h" #include "srcline.h" #include "symbol.h" #include "sort.h" diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 623a63cd1eec..5b83ed1ebbd6 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -10,6 +10,7 @@ #include /* To get things like MAP_HUGETLB even on older libc headers */ #include "dso.h" #include "map.h" +#include "map_symbol.h" #include "thread.h" #include "vdso.h" #include "build-id.h" diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c index 3a8d38ce3b54..3d391583f2ae 100644 --- a/tools/perf/util/mem-events.c +++ b/tools/perf/util/mem-events.c @@ -8,6 +8,7 @@ #include #include #include +#include "map_symbol.h" #include "mem-events.h" #include "debug.h" #include "symbol.h" diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h index a889ec2fa9f5..f1389bdae7bf 100644 --- a/tools/perf/util/mem-events.h +++ b/tools/perf/util/mem-events.h @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include "stat.h" struct perf_mem_event { @@ -16,6 +18,13 @@ struct perf_mem_event { const char *sysfs_name; }; +struct mem_info { + struct addr_map_symbol iaddr; + struct addr_map_symbol daddr; + union perf_mem_data_src data_src; + refcount_t refcnt; +}; + enum { PERF_MEM_EVENTS__LOAD, PERF_MEM_EVENTS__STORE, diff --git a/tools/perf/util/s390-sample-raw.c b/tools/perf/util/s390-sample-raw.c index 0ddfa7b3e4f2..4d9593e331ea 100644 --- a/tools/perf/util/s390-sample-raw.c +++ b/tools/perf/util/s390-sample-raw.c @@ -25,7 +25,6 @@ #include "util.h" #include "session.h" #include "evlist.h" -#include "config.h" #include "color.h" #include "sample-raw.h" #include "s390-cpumcf-kernel.h" diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index e5ac5f3c94d4..e9e4a04f15db 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -12,6 +12,8 @@ #include #include +#include "map_symbol.h" +#include "branch.h" #include "debug.h" #include "evlist.h" #include "evsel.h" diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index b974a2c3a3c5..a2308eb77681 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -13,6 +13,8 @@ #include "comm.h" #include "map.h" #include "symbol.h" +#include "map_symbol.h" +#include "branch.h" #include "thread.h" #include "evsel.h" #include "evlist.h" diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index e5ffe61ad66b..765c75df2904 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -25,6 +25,8 @@ #include "machine.h" #include "map.h" #include "symbol.h" +#include "map_symbol.h" +#include "mem-events.h" #include "symsrc.h" #include "strlist.h" #include "intlist.h" diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 5a58407c2945..0b0c6b5b1899 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -9,8 +9,6 @@ #include #include #include -#include "map_symbol.h" -#include "branch.h" #include "path.h" #include "symbol_conf.h" @@ -107,21 +105,6 @@ struct ref_reloc_sym { u64 unrelocated_addr; }; -struct branch_info { - struct addr_map_symbol from; - struct addr_map_symbol to; - struct branch_flags flags; - char *srcline_from; - char *srcline_to; -}; - -struct mem_info { - struct addr_map_symbol iaddr; - struct addr_map_symbol daddr; - union perf_mem_data_src data_src; - refcount_t refcnt; -}; - struct block_info { struct symbol *sym; u64 start; From a55ab7c4ca6986a542d313b02043a39ebf712a39 Mon Sep 17 00:00:00 2001 From: Jin Yao Date: Wed, 28 Aug 2019 13:59:29 +0800 Subject: [PATCH 38/47] perf pmu: Change convert_scale from static to global The function convert_scale() can be used to convert string to unit and scale. For example, s = "6000000000ns"; convert_scale(s, &unit, &scale); unit = "ns", scale = 6000000000. Currently this function is static. This patch renames the function to perf_pmu__convert_scale and changes the function to global. No functional change. Signed-off-by: Jin Yao Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Kan Liang Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20190828055932.8269-2-yao.jin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/pmu.c | 6 +++--- tools/perf/util/pmu.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 6b3448f6eb94..fb597fa94234 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -102,7 +102,7 @@ static int pmu_format(const char *name, struct list_head *format) return 0; } -static int convert_scale(const char *scale, char **end, double *sval) +int perf_pmu__convert_scale(const char *scale, char **end, double *sval) { char *lc; int ret = 0; @@ -165,7 +165,7 @@ static int perf_pmu__parse_scale(struct perf_pmu_alias *alias, char *dir, char * else scale[sret] = '\0'; - ret = convert_scale(scale, NULL, &alias->scale); + ret = perf_pmu__convert_scale(scale, NULL, &alias->scale); error: close(fd); return ret; @@ -373,7 +373,7 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, desc ? strdup(desc) : NULL; alias->topic = topic ? strdup(topic) : NULL; if (unit) { - if (convert_scale(unit, &unit, &alias->scale) < 0) + if (perf_pmu__convert_scale(unit, &unit, &alias->scale) < 0) return -1; snprintf(alias->unit, sizeof(alias->unit), "%s", unit); } diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 3f8b79b1dd85..f36ade6df76d 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -96,4 +96,6 @@ struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu); struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu); +int perf_pmu__convert_scale(const char *scale, char **end, double *sval); + #endif /* __PMU_H */ From 287f2649f791819dd2d8f32f0213c8c521d6dfa0 Mon Sep 17 00:00:00 2001 From: Jin Yao Date: Wed, 28 Aug 2019 13:59:31 +0800 Subject: [PATCH 39/47] perf metricgroup: Scale the metric result Some metrics define the scale unit, such as { "BriefDescription": "Intel Optane DC persistent memory read latency (ns). Derived from unc_m_pmm_rpq_occupancy.all", "Counter": "0,1,2,3", "EventCode": "0xE0", "EventName": "UNC_M_PMM_READ_LATENCY", "MetricExpr": "UNC_M_PMM_RPQ_OCCUPANCY.ALL / UNC_M_PMM_RPQ_INSERTS / UNC_M_CLOCKTICKS", "MetricName": "UNC_M_PMM_READ_LATENCY", "PerPkg": "1", "ScaleUnit": "6000000000ns", "UMask": "0x1", "Unit": "iMC" }, For above example, the ratio should be, ratio = (UNC_M_PMM_RPQ_OCCUPANCY.ALL / UNC_M_PMM_RPQ_INSERTS / UNC_M_CLOCKTICKS) * 6000000000 But in current code, the ratio is not scaled ( * 6000000000) With this patch, the ratio is scaled and the unit (ns) is printed. For example, # 219.4 ns UNC_M_PMM_READ_LATENCY Signed-off-by: Jin Yao Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Kan Liang Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20190828055932.8269-4-yao.jin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/metricgroup.c | 3 +++ tools/perf/util/metricgroup.h | 1 + tools/perf/util/stat-shadow.c | 38 +++++++++++++++++++++++++---------- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 33f5e2101874..f474a29f1b69 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -87,6 +87,7 @@ struct egroup { const char **ids; const char *metric_name; const char *metric_expr; + const char *metric_unit; }; static bool record_evsel(int *ind, struct evsel **start, @@ -182,6 +183,7 @@ static int metricgroup__setup_events(struct list_head *groups, } expr->metric_expr = eg->metric_expr; expr->metric_name = eg->metric_name; + expr->metric_unit = eg->metric_unit; expr->metric_events = metric_events; list_add(&expr->nd, &me->head); } @@ -453,6 +455,7 @@ static int metricgroup__add_metric(const char *metric, struct strbuf *events, eg->idnum = idnum; eg->metric_name = pe->metric_name; eg->metric_expr = pe->metric_expr; + eg->metric_unit = pe->unit; list_add_tail(&eg->nd, group_list); ret = 0; } diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.h index e5092f6404ae..475c7f912864 100644 --- a/tools/perf/util/metricgroup.h +++ b/tools/perf/util/metricgroup.h @@ -20,6 +20,7 @@ struct metric_expr { struct list_head nd; const char *metric_expr; const char *metric_name; + const char *metric_unit; struct evsel **metric_events; }; diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 2ed5e0066c70..696d263f6eb6 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -715,6 +715,7 @@ static void generic_metric(struct perf_stat_config *config, struct evsel **metric_events, char *name, const char *metric_name, + const char *metric_unit, double avg, int cpu, struct perf_stat_output_ctx *out, @@ -722,7 +723,7 @@ static void generic_metric(struct perf_stat_config *config, { print_metric_t print_metric = out->print_metric; struct parse_ctx pctx; - double ratio; + double ratio, scale; int i; void *ctxp = out->ctx; char *n, *pn; @@ -732,7 +733,6 @@ static void generic_metric(struct perf_stat_config *config, for (i = 0; metric_events[i]; i++) { struct saved_value *v; struct stats *stats; - double scale; if (!strcmp(metric_events[i]->name, "duration_time")) { stats = &walltime_nsecs_stats; @@ -762,16 +762,32 @@ static void generic_metric(struct perf_stat_config *config, if (!metric_events[i]) { const char *p = metric_expr; - if (expr__parse(&ratio, &pctx, &p) == 0) - print_metric(config, ctxp, NULL, "%8.1f", - metric_name ? - metric_name : - out->force_header ? name : "", - ratio); - else + if (expr__parse(&ratio, &pctx, &p) == 0) { + char *unit; + char metric_bf[64]; + + if (metric_unit && metric_name) { + if (perf_pmu__convert_scale(metric_unit, + &unit, &scale) >= 0) { + ratio *= scale; + } + + scnprintf(metric_bf, sizeof(metric_bf), + "%s %s", unit, metric_name); + print_metric(config, ctxp, NULL, "%8.1f", + metric_bf, ratio); + } else { + print_metric(config, ctxp, NULL, "%8.1f", + metric_name ? + metric_name : + out->force_header ? name : "", + ratio); + } + } else { print_metric(config, ctxp, NULL, NULL, out->force_header ? (metric_name ? metric_name : name) : "", 0); + } } else print_metric(config, ctxp, NULL, NULL, "", 0); @@ -992,7 +1008,7 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, print_metric(config, ctxp, NULL, NULL, name, 0); } else if (evsel->metric_expr) { generic_metric(config, evsel->metric_expr, evsel->metric_events, evsel->name, - evsel->metric_name, avg, cpu, out, st); + evsel->metric_name, NULL, avg, cpu, out, st); } else if (runtime_stat_n(st, STAT_NSECS, 0, cpu) != 0) { char unit = 'M'; char unit_buf[10]; @@ -1021,7 +1037,7 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, out->new_line(config, ctxp); generic_metric(config, mexp->metric_expr, mexp->metric_events, evsel->name, mexp->metric_name, - avg, cpu, out, st); + mexp->metric_unit, avg, cpu, out, st); } } if (num == 0) From f01642e4912bb80a01d693f4cc6fb0897207a090 Mon Sep 17 00:00:00 2001 From: Jin Yao Date: Wed, 28 Aug 2019 13:59:32 +0800 Subject: [PATCH 40/47] perf metricgroup: Support multiple events for metricgroup Some uncore metrics don't work as expected. For example, on cascadelakex: root@lkp-csl-2sp2:~# perf stat -M UNC_M_PMM_BANDWIDTH.TOTAL -a -- sleep 1 Performance counter stats for 'system wide': 1841092 unc_m_pmm_rpq_inserts 3680816 unc_m_pmm_wpq_inserts 1.001775055 seconds time elapsed root@lkp-csl-2sp2:~# perf stat -M UNC_M_PMM_READ_LATENCY -a -- sleep 1 Performance counter stats for 'system wide': 860649746 unc_m_pmm_rpq_occupancy.all 1840557 unc_m_pmm_rpq_inserts 12790627455 unc_m_clockticks 1.001773348 seconds time elapsed No metrics 'UNC_M_PMM_BANDWIDTH.TOTAL' or 'UNC_M_PMM_READ_LATENCY' are reported. The issue is, the case of an alias expanding to mulitple events is not supported, typically the uncore events. (see comments in find_evsel_group()). For UNC_M_PMM_BANDWIDTH.TOTAL in above example, the expanded event group is '{unc_m_pmm_rpq_inserts,unc_m_pmm_wpq_inserts}:W', but the actual events passed to find_evsel_group are: unc_m_pmm_rpq_inserts unc_m_pmm_rpq_inserts unc_m_pmm_rpq_inserts unc_m_pmm_rpq_inserts unc_m_pmm_rpq_inserts unc_m_pmm_rpq_inserts unc_m_pmm_wpq_inserts unc_m_pmm_wpq_inserts unc_m_pmm_wpq_inserts unc_m_pmm_wpq_inserts unc_m_pmm_wpq_inserts unc_m_pmm_wpq_inserts For this multiple events case, it's not supported well. This patch introduces a new field 'metric_leader' in struct evsel. The first event is considered as a metric leader. For the rest of same events, they point to the first event via it's metric_leader field in struct evsel. This design is for adding the counting results of all same events to the first event in group (the metric_leader). With this patch, root@lkp-csl-2sp2:~# perf stat -M UNC_M_PMM_BANDWIDTH.TOTAL -a -- sleep 1 Performance counter stats for 'system wide': 1842108 unc_m_pmm_rpq_inserts # 337.2 MB/sec UNC_M_PMM_BANDWIDTH.TOTAL 3682209 unc_m_pmm_wpq_inserts 1.001819706 seconds time elapsed root@lkp-csl-2sp2:~# perf stat -M UNC_M_PMM_READ_LATENCY -a -- sleep 1 Performance counter stats for 'system wide': 861970685 unc_m_pmm_rpq_occupancy.all # 219.4 ns UNC_M_PMM_READ_LATENCY 1842772 unc_m_pmm_rpq_inserts 12790196356 unc_m_clockticks 1.001749103 seconds time elapsed Now we can see the correct metrics 'UNC_M_PMM_BANDWIDTH.TOTAL' and 'UNC_M_PMM_READ_LATENCY'. Signed-off-by: Jin Yao Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Kan Liang Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/20190828055932.8269-5-yao.jin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evsel.h | 1 + tools/perf/util/metricgroup.c | 84 ++++++++++++++++++----------------- tools/perf/util/stat-shadow.c | 27 +++++++++-- 3 files changed, 68 insertions(+), 44 deletions(-) diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index fd60caced4fc..68321d10eb2d 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -168,6 +168,7 @@ struct evsel { const char * metric_expr; const char * metric_name; struct evsel **metric_events; + struct evsel *metric_leader; bool collect_stat; bool weak_group; bool percore; diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index f474a29f1b69..a7c0424dbda3 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -90,57 +90,61 @@ struct egroup { const char *metric_unit; }; -static bool record_evsel(int *ind, struct evsel **start, - int idnum, - struct evsel **metric_events, - struct evsel *ev) -{ - metric_events[*ind] = ev; - if (*ind == 0) - *start = ev; - if (++*ind == idnum) { - metric_events[*ind] = NULL; - return true; - } - return false; -} - static struct evsel *find_evsel_group(struct evlist *perf_evlist, const char **ids, int idnum, struct evsel **metric_events) { - struct evsel *ev, *start = NULL; - int ind = 0; + struct evsel *ev; + int i = 0; + bool leader_found; evlist__for_each_entry (perf_evlist, ev) { - if (ev->collect_stat) - continue; - if (!strcmp(ev->name, ids[ind])) { - if (record_evsel(&ind, &start, idnum, - metric_events, ev)) - return start; + if (!strcmp(ev->name, ids[i])) { + if (!metric_events[i]) + metric_events[i] = ev; } else { - /* - * We saw some other event that is not - * in our list of events. Discard - * the whole match and start again. - */ - ind = 0; - start = NULL; - if (!strcmp(ev->name, ids[ind])) { - if (record_evsel(&ind, &start, idnum, - metric_events, ev)) - return start; + if (++i == idnum) { + /* Discard the whole match and start again */ + i = 0; + memset(metric_events, 0, + sizeof(struct evsel *) * idnum); + continue; + } + + if (!strcmp(ev->name, ids[i])) + metric_events[i] = ev; + else { + /* Discard the whole match and start again */ + i = 0; + memset(metric_events, 0, + sizeof(struct evsel *) * idnum); + continue; } } } - /* - * This can happen when an alias expands to multiple - * events, like for uncore events. - * We don't support this case for now. - */ - return NULL; + + if (i != idnum - 1) { + /* Not whole match */ + return NULL; + } + + metric_events[idnum] = NULL; + + for (i = 0; i < idnum; i++) { + leader_found = false; + evlist__for_each_entry(perf_evlist, ev) { + if (!leader_found && (ev == metric_events[i])) + leader_found = true; + + if (leader_found && + !strcmp(ev->name, metric_events[i]->name)) { + ev->metric_leader = metric_events[i]; + } + } + } + + return metric_events[0]; } static int metricgroup__setup_events(struct list_head *groups, diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 696d263f6eb6..70c87fdb2a43 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -31,6 +31,8 @@ struct saved_value { int cpu; struct runtime_stat *stat; struct stats stats; + u64 metric_total; + int metric_other; }; static int saved_value_cmp(struct rb_node *rb_node, const void *entry) @@ -212,6 +214,7 @@ void perf_stat__update_shadow_stats(struct evsel *counter, u64 count, { int ctx = evsel_context(counter); u64 count_ns = count; + struct saved_value *v; count *= counter->scale; @@ -266,9 +269,15 @@ void perf_stat__update_shadow_stats(struct evsel *counter, u64 count, update_runtime_stat(st, STAT_APERF, ctx, cpu, count); if (counter->collect_stat) { - struct saved_value *v = saved_value_lookup(counter, cpu, true, - STAT_NONE, 0, st); + v = saved_value_lookup(counter, cpu, true, STAT_NONE, 0, st); update_stats(&v->stats, count); + if (counter->metric_leader) + v->metric_total += count; + } else if (counter->metric_leader) { + v = saved_value_lookup(counter->metric_leader, + cpu, true, STAT_NONE, 0, st); + v->metric_total += count; + v->metric_other++; } } @@ -729,10 +738,10 @@ static void generic_metric(struct perf_stat_config *config, char *n, *pn; expr__ctx_init(&pctx); - expr__add_id(&pctx, name, avg); for (i = 0; metric_events[i]; i++) { struct saved_value *v; struct stats *stats; + u64 metric_total = 0; if (!strcmp(metric_events[i]->name, "duration_time")) { stats = &walltime_nsecs_stats; @@ -744,6 +753,9 @@ static void generic_metric(struct perf_stat_config *config, break; stats = &v->stats; scale = 1.0; + + if (v->metric_other) + metric_total = v->metric_total; } n = strdup(metric_events[i]->name); @@ -757,8 +769,15 @@ static void generic_metric(struct perf_stat_config *config, pn = strchr(n, ' '); if (pn) *pn = 0; - expr__add_id(&pctx, n, avg_stats(stats)*scale); + + if (metric_total) + expr__add_id(&pctx, n, metric_total); + else + expr__add_id(&pctx, n, avg_stats(stats)*scale); } + + expr__add_id(&pctx, name, avg); + if (!metric_events[i]) { const char *p = metric_expr; From d046b725487a97a3a3b35a00e84ca093963b8b4e Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Thu, 29 Aug 2019 17:41:18 -0500 Subject: [PATCH 41/47] objtool: Move x86 insn decoder to a common location The kernel tree has three identical copies of the x86 instruction decoder. Two of them are in the tools subdir. The tools subdir is supposed to be completely standalone and separate from the kernel. So having at least one copy of the kernel decoder in the tools subdir is unavoidable. However, we don't need *two* of them. Move objtool's copy of the decoder to a shared location, so that perf will also be able to use it. Signed-off-by: Josh Poimboeuf Reviewed-by: Masami Hiramatsu Acked-by: Peter Zijlstra (Intel) Cc: Adrian Hunter Cc: Jiri Olsa Cc: x86@kernel.org Link: http://lore.kernel.org/lkml/55b486b88f6bcd0c9a2a04b34f964860c8390ca8.1567118001.git.jpoimboe@redhat.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/{objtool => }/arch/x86/include/asm/inat.h | 0 .../{objtool => }/arch/x86/include/asm/inat_types.h | 0 tools/{objtool => }/arch/x86/include/asm/insn.h | 0 tools/{objtool => }/arch/x86/include/asm/orc_types.h | 0 tools/{objtool => }/arch/x86/lib/inat.c | 0 tools/{objtool => }/arch/x86/lib/insn.c | 0 tools/{objtool => }/arch/x86/lib/x86-opcode-map.txt | 0 .../arch/x86/tools/gen-insn-attr-x86.awk | 0 tools/objtool/Makefile | 4 ++-- tools/objtool/arch/x86/Build | 4 ++-- tools/objtool/arch/x86/decode.c | 4 ++-- tools/objtool/sync-check.sh | 12 ++++++------ 12 files changed, 12 insertions(+), 12 deletions(-) rename tools/{objtool => }/arch/x86/include/asm/inat.h (100%) rename tools/{objtool => }/arch/x86/include/asm/inat_types.h (100%) rename tools/{objtool => }/arch/x86/include/asm/insn.h (100%) rename tools/{objtool => }/arch/x86/include/asm/orc_types.h (100%) rename tools/{objtool => }/arch/x86/lib/inat.c (100%) rename tools/{objtool => }/arch/x86/lib/insn.c (100%) rename tools/{objtool => }/arch/x86/lib/x86-opcode-map.txt (100%) rename tools/{objtool => }/arch/x86/tools/gen-insn-attr-x86.awk (100%) diff --git a/tools/objtool/arch/x86/include/asm/inat.h b/tools/arch/x86/include/asm/inat.h similarity index 100% rename from tools/objtool/arch/x86/include/asm/inat.h rename to tools/arch/x86/include/asm/inat.h diff --git a/tools/objtool/arch/x86/include/asm/inat_types.h b/tools/arch/x86/include/asm/inat_types.h similarity index 100% rename from tools/objtool/arch/x86/include/asm/inat_types.h rename to tools/arch/x86/include/asm/inat_types.h diff --git a/tools/objtool/arch/x86/include/asm/insn.h b/tools/arch/x86/include/asm/insn.h similarity index 100% rename from tools/objtool/arch/x86/include/asm/insn.h rename to tools/arch/x86/include/asm/insn.h diff --git a/tools/objtool/arch/x86/include/asm/orc_types.h b/tools/arch/x86/include/asm/orc_types.h similarity index 100% rename from tools/objtool/arch/x86/include/asm/orc_types.h rename to tools/arch/x86/include/asm/orc_types.h diff --git a/tools/objtool/arch/x86/lib/inat.c b/tools/arch/x86/lib/inat.c similarity index 100% rename from tools/objtool/arch/x86/lib/inat.c rename to tools/arch/x86/lib/inat.c diff --git a/tools/objtool/arch/x86/lib/insn.c b/tools/arch/x86/lib/insn.c similarity index 100% rename from tools/objtool/arch/x86/lib/insn.c rename to tools/arch/x86/lib/insn.c diff --git a/tools/objtool/arch/x86/lib/x86-opcode-map.txt b/tools/arch/x86/lib/x86-opcode-map.txt similarity index 100% rename from tools/objtool/arch/x86/lib/x86-opcode-map.txt rename to tools/arch/x86/lib/x86-opcode-map.txt diff --git a/tools/objtool/arch/x86/tools/gen-insn-attr-x86.awk b/tools/arch/x86/tools/gen-insn-attr-x86.awk similarity index 100% rename from tools/objtool/arch/x86/tools/gen-insn-attr-x86.awk rename to tools/arch/x86/tools/gen-insn-attr-x86.awk diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index 88158239622b..8c9b9adc67ef 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -33,7 +33,7 @@ all: $(OBJTOOL) INCLUDES := -I$(srctree)/tools/include \ -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ - -I$(srctree)/tools/objtool/arch/$(ARCH)/include + -I$(srctree)/tools/arch/$(ARCH)/include WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) @@ -60,7 +60,7 @@ $(LIBSUBCMD): fixdep FORCE clean: $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL) $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete - $(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep + $(Q)$(RM) $(OUTPUT)arch/x86/inat-tables.c $(OUTPUT)fixdep FORCE: diff --git a/tools/objtool/arch/x86/Build b/tools/objtool/arch/x86/Build index b998412c017d..7c5004008e97 100644 --- a/tools/objtool/arch/x86/Build +++ b/tools/objtool/arch/x86/Build @@ -1,7 +1,7 @@ objtool-y += decode.o -inat_tables_script = arch/x86/tools/gen-insn-attr-x86.awk -inat_tables_maps = arch/x86/lib/x86-opcode-map.txt +inat_tables_script = ../arch/x86/tools/gen-insn-attr-x86.awk +inat_tables_maps = ../arch/x86/lib/x86-opcode-map.txt $(OUTPUT)arch/x86/lib/inat-tables.c: $(inat_tables_script) $(inat_tables_maps) $(call rule_mkdir) diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index 0567c47a91b1..a62e032863a8 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -8,8 +8,8 @@ #define unlikely(cond) (cond) #include -#include "lib/inat.c" -#include "lib/insn.c" +#include "../../../arch/x86/lib/inat.c" +#include "../../../arch/x86/lib/insn.c" #include "../../elf.h" #include "../../arch.h" diff --git a/tools/objtool/sync-check.sh b/tools/objtool/sync-check.sh index 1470e74e9d66..66f1575b80f3 100755 --- a/tools/objtool/sync-check.sh +++ b/tools/objtool/sync-check.sh @@ -2,21 +2,21 @@ # SPDX-License-Identifier: GPL-2.0 FILES=' -arch/x86/lib/insn.c -arch/x86/lib/inat.c -arch/x86/lib/x86-opcode-map.txt -arch/x86/tools/gen-insn-attr-x86.awk -arch/x86/include/asm/insn.h arch/x86/include/asm/inat.h arch/x86/include/asm/inat_types.h +arch/x86/include/asm/insn.h arch/x86/include/asm/orc_types.h +arch/x86/lib/inat.c +arch/x86/lib/insn.c +arch/x86/lib/x86-opcode-map.txt +arch/x86/tools/gen-insn-attr-x86.awk ' check() { local file=$1 - diff $file ../../$file > /dev/null || + diff ../$file ../../$file > /dev/null || echo "Warning: synced file at 'tools/objtool/$file' differs from latest kernel version at '$file'" } From 58993fb2c5115e93c52058e25f9b2ff289374870 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Thu, 29 Aug 2019 17:41:19 -0500 Subject: [PATCH 42/47] perf: Update .gitignore file After a "make tools/perf", git reports the following untracked files: tools/perf/feature/ tools/perf/fixdep tools/perf/libtraceevent-dynamic-list Add these generated files to perf's .gitignore file. Signed-off-by: Josh Poimboeuf Reviewed-by: Masami Hiramatsu Acked-by: Peter Zijlstra Cc: Adrian Hunter Cc: Jiri Olsa Cc: x86@kernel.org Link: http://lore.kernel.org/lkml/03acbc6c2fbc72054861f6c301875db75db33030.1567118001.git.jpoimboe@redhat.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/.gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore index 3e5135dded16..bf1252dc2cb0 100644 --- a/tools/perf/.gitignore +++ b/tools/perf/.gitignore @@ -34,3 +34,6 @@ arch/*/include/generated/ trace/beauty/generated/ pmu-events/pmu-events.c pmu-events/jevents +feature/ +fixdep +libtraceevent-dynamic-list From f1da0a6c136542b9571b30af27bc1e84254f7a47 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Thu, 29 Aug 2019 17:41:20 -0500 Subject: [PATCH 43/47] perf intel-pt: Remove inat.c from build dependency list intel-pt-insn-decoder.c includes inat.c directly, so it already has an implicit dependency on inat.c. The Build file dependency is redundant. Signed-off-by: Josh Poimboeuf Reviewed-by: Masami Hiramatsu Acked-by: Peter Zijlstra Cc: Adrian Hunter Cc: Jiri Olsa Cc: x86@kernel.org Link: http://lore.kernel.org/lkml/53776d6d29bc9eceb571d52df8fa32250c58a0f3.1567118001.git.jpoimboe@redhat.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/intel-pt-decoder/Build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/intel-pt-decoder/Build b/tools/perf/util/intel-pt-decoder/Build index 23bf788f84b9..acb18a3463c3 100644 --- a/tools/perf/util/intel-pt-decoder/Build +++ b/tools/perf/util/intel-pt-decoder/Build @@ -9,7 +9,7 @@ $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_table # Busybox's diff doesn't have -I, avoid warning in the case -$(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/intel-pt-insn-decoder.c util/intel-pt-decoder/inat.c $(OUTPUT)util/intel-pt-decoder/inat-tables.c +$(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/intel-pt-insn-decoder.c $(OUTPUT)util/intel-pt-decoder/inat-tables.c @(diff -I 2>&1 | grep -q 'option requires an argument' && \ test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \ ((diff -B -I'^#include' util/intel-pt-decoder/insn.c ../../arch/x86/lib/insn.c >/dev/null) || \ From 00a263902ac3da886cf275663a938f503a853f68 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Thu, 29 Aug 2019 17:41:21 -0500 Subject: [PATCH 44/47] perf intel-pt: Use shared x86 insn decoder Now that there's a common version of the decoder for all tools, use it instead of the local copy. Also use perf's check-headers.sh script to diff the decoder files to make sure they remain in sync with the kernel version. Objtool has a similar check. Committer notes: Had to keep this all pointing explicitely to x86 headers/files, i.e. instead of asm/isnn.h we had to use ../include/asm/insn.h when the files were in differemt dirs, or just replace "" with "foo.h". This way we continue to be able to process perf.data files with Intel PT traces in distros other than x86. Also fixed up the awk script paths to use $(srcdir)/tools/arch instead or relative directories so that we keep detached tarballs (make help | grep perf) working. For now the include lines in these headers are being ignored so as not to flag false reports of kernel/tools out of sync. Signed-off-by: Josh Poimboeuf Reviewed-by: Masami Hiramatsu Acked-by: Peter Zijlstra (Intel) Cc: Adrian Hunter Cc: Jiri Olsa Cc: x86@kernel.org Link: http://lore.kernel.org/lkml/8a37e615d2880f039505d693d1e068a009358a2b.1567118001.git.jpoimboe@redhat.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/arch/x86/include/asm/inat.h | 2 +- tools/arch/x86/include/asm/insn.h | 2 +- tools/arch/x86/lib/inat.c | 2 +- tools/arch/x86/lib/insn.c | 4 +- tools/perf/arch/x86/tests/insn-x86.c | 2 +- tools/perf/arch/x86/util/archinsn.c | 2 +- tools/perf/check-headers.sh | 11 +- tools/perf/util/intel-pt-decoder/Build | 20 +- .../intel-pt-decoder/gen-insn-attr-x86.awk | 392 ------ tools/perf/util/intel-pt-decoder/inat.c | 82 -- tools/perf/util/intel-pt-decoder/inat.h | 230 ---- tools/perf/util/intel-pt-decoder/inat_types.h | 15 - tools/perf/util/intel-pt-decoder/insn.c | 593 --------- tools/perf/util/intel-pt-decoder/insn.h | 216 ---- .../intel-pt-decoder/intel-pt-insn-decoder.c | 10 +- .../util/intel-pt-decoder/x86-opcode-map.txt | 1072 ----------------- 16 files changed, 23 insertions(+), 2632 deletions(-) delete mode 100644 tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk delete mode 100644 tools/perf/util/intel-pt-decoder/inat.c delete mode 100644 tools/perf/util/intel-pt-decoder/inat.h delete mode 100644 tools/perf/util/intel-pt-decoder/inat_types.h delete mode 100644 tools/perf/util/intel-pt-decoder/insn.c delete mode 100644 tools/perf/util/intel-pt-decoder/insn.h delete mode 100644 tools/perf/util/intel-pt-decoder/x86-opcode-map.txt diff --git a/tools/arch/x86/include/asm/inat.h b/tools/arch/x86/include/asm/inat.h index 4cf2ad521f65..877827b7c2c3 100644 --- a/tools/arch/x86/include/asm/inat.h +++ b/tools/arch/x86/include/asm/inat.h @@ -6,7 +6,7 @@ * * Written by Masami Hiramatsu */ -#include +#include "inat_types.h" /* * Internal bits. Don't use bitmasks directly, because these bits are diff --git a/tools/arch/x86/include/asm/insn.h b/tools/arch/x86/include/asm/insn.h index 154f27be8bfc..37a4c390750b 100644 --- a/tools/arch/x86/include/asm/insn.h +++ b/tools/arch/x86/include/asm/insn.h @@ -8,7 +8,7 @@ */ /* insn_attr_t is defined in inat.h */ -#include +#include "inat.h" struct insn_field { union { diff --git a/tools/arch/x86/lib/inat.c b/tools/arch/x86/lib/inat.c index 12539fca75c4..4f5ed49e1b4e 100644 --- a/tools/arch/x86/lib/inat.c +++ b/tools/arch/x86/lib/inat.c @@ -4,7 +4,7 @@ * * Written by Masami Hiramatsu */ -#include +#include "../include/asm/insn.h" /* Attribute tables are generated from opcode map */ #include "inat-tables.c" diff --git a/tools/arch/x86/lib/insn.c b/tools/arch/x86/lib/insn.c index 0b5862ba6a75..79e048f1d902 100644 --- a/tools/arch/x86/lib/insn.c +++ b/tools/arch/x86/lib/insn.c @@ -10,8 +10,8 @@ #else #include #endif -#include -#include +#include "../include/asm/inat.h" +#include "../include/asm/insn.h" /* Verify next sizeof(t) bytes can be on the same instruction */ #define validate_next(t, insn, n) \ diff --git a/tools/perf/arch/x86/tests/insn-x86.c b/tools/perf/arch/x86/tests/insn-x86.c index d67bc0ffb70a..745f29adb14b 100644 --- a/tools/perf/arch/x86/tests/insn-x86.c +++ b/tools/perf/arch/x86/tests/insn-x86.c @@ -1,12 +1,12 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include "../../../../arch/x86/include/asm/insn.h" #include #include "debug.h" #include "tests/tests.h" #include "arch-tests.h" -#include "intel-pt-decoder/insn.h" #include "intel-pt-decoder/intel-pt-insn-decoder.h" struct test_data { diff --git a/tools/perf/arch/x86/util/archinsn.c b/tools/perf/arch/x86/util/archinsn.c index 62e8e1820132..9876c7a7ed7c 100644 --- a/tools/perf/arch/x86/util/archinsn.c +++ b/tools/perf/arch/x86/util/archinsn.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 +#include "../../../../arch/x86/include/asm/insn.h" #include "archinsn.h" -#include "util/intel-pt-decoder/insn.h" #include "machine.h" #include "thread.h" #include "symbol.h" diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh index 5308b3836278..cbcc3590098c 100755 --- a/tools/perf/check-headers.sh +++ b/tools/perf/check-headers.sh @@ -1,7 +1,7 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 -HEADERS=' +FILES=' include/uapi/linux/const.h include/uapi/drm/drm.h include/uapi/drm/i915_drm.h @@ -26,7 +26,14 @@ include/uapi/linux/hw_breakpoint.h arch/x86/include/asm/disabled-features.h arch/x86/include/asm/required-features.h arch/x86/include/asm/cpufeatures.h +arch/x86/include/asm/inat.h +arch/x86/include/asm/inat_types.h +arch/x86/include/asm/insn.h arch/x86/include/uapi/asm/prctl.h +arch/x86/lib/inat.c +arch/x86/lib/insn.c +arch/x86/lib/x86-opcode-map.txt +arch/x86/tools/gen-insn-attr-x86.awk arch/arm/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h arch/powerpc/include/uapi/asm/perf_regs.h @@ -98,7 +105,7 @@ test -d ../../include || exit 0 cd ../.. # simple diff check -for i in $HEADERS; do +for i in $FILES; do check $i -B done diff --git a/tools/perf/util/intel-pt-decoder/Build b/tools/perf/util/intel-pt-decoder/Build index acb18a3463c3..bc629359826f 100644 --- a/tools/perf/util/intel-pt-decoder/Build +++ b/tools/perf/util/intel-pt-decoder/Build @@ -1,7 +1,7 @@ perf-$(CONFIG_AUXTRACE) += intel-pt-pkt-decoder.o intel-pt-insn-decoder.o intel-pt-log.o intel-pt-decoder.o -inat_tables_script = util/intel-pt-decoder/gen-insn-attr-x86.awk -inat_tables_maps = util/intel-pt-decoder/x86-opcode-map.txt +inat_tables_script = $(srctree)/tools/arch/x86/tools/gen-insn-attr-x86.awk +inat_tables_maps = $(srctree)/tools/arch/x86/lib/x86-opcode-map.txt $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_tables_maps) $(call rule_mkdir) @@ -10,22 +10,6 @@ $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_table # Busybox's diff doesn't have -I, avoid warning in the case $(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/intel-pt-insn-decoder.c $(OUTPUT)util/intel-pt-decoder/inat-tables.c - @(diff -I 2>&1 | grep -q 'option requires an argument' && \ - test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \ - ((diff -B -I'^#include' util/intel-pt-decoder/insn.c ../../arch/x86/lib/insn.c >/dev/null) || \ - (echo "Warning: Intel PT: x86 instruction decoder C file at 'tools/perf/util/intel-pt-decoder/insn.c' differs from latest version at 'arch/x86/lib/insn.c'" >&2)) && \ - ((diff -B -I'^#include' util/intel-pt-decoder/inat.c ../../arch/x86/lib/inat.c >/dev/null) || \ - (echo "Warning: Intel PT: x86 instruction decoder C file at 'tools/perf/util/intel-pt-decoder/inat.c' differs from latest version at 'arch/x86/lib/inat.c'" >&2)) && \ - ((diff -B util/intel-pt-decoder/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null) || \ - (echo "Warning: Intel PT: x86 instruction decoder map file at 'tools/perf/util/intel-pt-decoder/x86-opcode-map.txt' differs from latest version at 'arch/x86/lib/x86-opcode-map.txt'" >&2)) && \ - ((diff -B util/intel-pt-decoder/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null) || \ - (echo "Warning: Intel PT: x86 instruction decoder script at 'tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk' differs from latest version at 'arch/x86/tools/gen-insn-attr-x86.awk'" >&2)) && \ - ((diff -B -I'^#include' util/intel-pt-decoder/insn.h ../../arch/x86/include/asm/insn.h >/dev/null) || \ - (echo "Warning: Intel PT: x86 instruction decoder header at 'tools/perf/util/intel-pt-decoder/insn.h' differs from latest version at 'arch/x86/include/asm/insn.h'" >&2)) && \ - ((diff -B -I'^#include' util/intel-pt-decoder/inat.h ../../arch/x86/include/asm/inat.h >/dev/null) || \ - (echo "Warning: Intel PT: x86 instruction decoder header at 'tools/perf/util/intel-pt-decoder/inat.h' differs from latest version at 'arch/x86/include/asm/inat.h'" >&2)) && \ - ((diff -B -I'^#include' util/intel-pt-decoder/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) || \ - (echo "Warning: Intel PT: x86 instruction decoder header at 'tools/perf/util/intel-pt-decoder/inat_types.h' differs from latest version at 'arch/x86/include/asm/inat_types.h'" >&2)))) || true $(call rule_mkdir) $(call if_changed_dep,cc_o_c) diff --git a/tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk b/tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk deleted file mode 100644 index ddd5c4c21129..000000000000 --- a/tools/perf/util/intel-pt-decoder/gen-insn-attr-x86.awk +++ /dev/null @@ -1,392 +0,0 @@ -#!/bin/awk -f -# SPDX-License-Identifier: GPL-2.0 -# gen-insn-attr-x86.awk: Instruction attribute table generator -# Written by Masami Hiramatsu -# -# Usage: awk -f gen-insn-attr-x86.awk x86-opcode-map.txt > inat-tables.c - -# Awk implementation sanity check -function check_awk_implement() { - if (sprintf("%x", 0) != "0") - return "Your awk has a printf-format problem." - return "" -} - -# Clear working vars -function clear_vars() { - delete table - delete lptable2 - delete lptable1 - delete lptable3 - eid = -1 # escape id - gid = -1 # group id - aid = -1 # AVX id - tname = "" -} - -BEGIN { - # Implementation error checking - awkchecked = check_awk_implement() - if (awkchecked != "") { - print "Error: " awkchecked > "/dev/stderr" - print "Please try to use gawk." > "/dev/stderr" - exit 1 - } - - # Setup generating tables - print "/* x86 opcode map generated from x86-opcode-map.txt */" - print "/* Do not change this code. */\n" - ggid = 1 - geid = 1 - gaid = 0 - delete etable - delete gtable - delete atable - - opnd_expr = "^[A-Za-z/]" - ext_expr = "^\\(" - sep_expr = "^\\|$" - group_expr = "^Grp[0-9A-Za-z]+" - - imm_expr = "^[IJAOL][a-z]" - imm_flag["Ib"] = "INAT_MAKE_IMM(INAT_IMM_BYTE)" - imm_flag["Jb"] = "INAT_MAKE_IMM(INAT_IMM_BYTE)" - imm_flag["Iw"] = "INAT_MAKE_IMM(INAT_IMM_WORD)" - imm_flag["Id"] = "INAT_MAKE_IMM(INAT_IMM_DWORD)" - imm_flag["Iq"] = "INAT_MAKE_IMM(INAT_IMM_QWORD)" - imm_flag["Ap"] = "INAT_MAKE_IMM(INAT_IMM_PTR)" - imm_flag["Iz"] = "INAT_MAKE_IMM(INAT_IMM_VWORD32)" - imm_flag["Jz"] = "INAT_MAKE_IMM(INAT_IMM_VWORD32)" - imm_flag["Iv"] = "INAT_MAKE_IMM(INAT_IMM_VWORD)" - imm_flag["Ob"] = "INAT_MOFFSET" - imm_flag["Ov"] = "INAT_MOFFSET" - imm_flag["Lx"] = "INAT_MAKE_IMM(INAT_IMM_BYTE)" - - modrm_expr = "^([CDEGMNPQRSUVW/][a-z]+|NTA|T[012])" - force64_expr = "\\([df]64\\)" - rex_expr = "^REX(\\.[XRWB]+)*" - fpu_expr = "^ESC" # TODO - - lprefix1_expr = "\\((66|!F3)\\)" - lprefix2_expr = "\\(F3\\)" - lprefix3_expr = "\\((F2|!F3|66\\&F2)\\)" - lprefix_expr = "\\((66|F2|F3)\\)" - max_lprefix = 4 - - # All opcodes starting with lower-case 'v', 'k' or with (v1) superscript - # accepts VEX prefix - vexok_opcode_expr = "^[vk].*" - vexok_expr = "\\(v1\\)" - # All opcodes with (v) superscript supports *only* VEX prefix - vexonly_expr = "\\(v\\)" - # All opcodes with (ev) superscript supports *only* EVEX prefix - evexonly_expr = "\\(ev\\)" - - prefix_expr = "\\(Prefix\\)" - prefix_num["Operand-Size"] = "INAT_PFX_OPNDSZ" - prefix_num["REPNE"] = "INAT_PFX_REPNE" - prefix_num["REP/REPE"] = "INAT_PFX_REPE" - prefix_num["XACQUIRE"] = "INAT_PFX_REPNE" - prefix_num["XRELEASE"] = "INAT_PFX_REPE" - prefix_num["LOCK"] = "INAT_PFX_LOCK" - prefix_num["SEG=CS"] = "INAT_PFX_CS" - prefix_num["SEG=DS"] = "INAT_PFX_DS" - prefix_num["SEG=ES"] = "INAT_PFX_ES" - prefix_num["SEG=FS"] = "INAT_PFX_FS" - prefix_num["SEG=GS"] = "INAT_PFX_GS" - prefix_num["SEG=SS"] = "INAT_PFX_SS" - prefix_num["Address-Size"] = "INAT_PFX_ADDRSZ" - prefix_num["VEX+1byte"] = "INAT_PFX_VEX2" - prefix_num["VEX+2byte"] = "INAT_PFX_VEX3" - prefix_num["EVEX"] = "INAT_PFX_EVEX" - - clear_vars() -} - -function semantic_error(msg) { - print "Semantic error at " NR ": " msg > "/dev/stderr" - exit 1 -} - -function debug(msg) { - print "DEBUG: " msg -} - -function array_size(arr, i,c) { - c = 0 - for (i in arr) - c++ - return c -} - -/^Table:/ { - print "/* " $0 " */" - if (tname != "") - semantic_error("Hit Table: before EndTable:."); -} - -/^Referrer:/ { - if (NF != 1) { - # escape opcode table - ref = "" - for (i = 2; i <= NF; i++) - ref = ref $i - eid = escape[ref] - tname = sprintf("inat_escape_table_%d", eid) - } -} - -/^AVXcode:/ { - if (NF != 1) { - # AVX/escape opcode table - aid = $2 - if (gaid <= aid) - gaid = aid + 1 - if (tname == "") # AVX only opcode table - tname = sprintf("inat_avx_table_%d", $2) - } - if (aid == -1 && eid == -1) # primary opcode table - tname = "inat_primary_table" -} - -/^GrpTable:/ { - print "/* " $0 " */" - if (!($2 in group)) - semantic_error("No group: " $2 ) - gid = group[$2] - tname = "inat_group_table_" gid -} - -function print_table(tbl,name,fmt,n) -{ - print "const insn_attr_t " name " = {" - for (i = 0; i < n; i++) { - id = sprintf(fmt, i) - if (tbl[id]) - print " [" id "] = " tbl[id] "," - } - print "};" -} - -/^EndTable/ { - if (gid != -1) { - # print group tables - if (array_size(table) != 0) { - print_table(table, tname "[INAT_GROUP_TABLE_SIZE]", - "0x%x", 8) - gtable[gid,0] = tname - } - if (array_size(lptable1) != 0) { - print_table(lptable1, tname "_1[INAT_GROUP_TABLE_SIZE]", - "0x%x", 8) - gtable[gid,1] = tname "_1" - } - if (array_size(lptable2) != 0) { - print_table(lptable2, tname "_2[INAT_GROUP_TABLE_SIZE]", - "0x%x", 8) - gtable[gid,2] = tname "_2" - } - if (array_size(lptable3) != 0) { - print_table(lptable3, tname "_3[INAT_GROUP_TABLE_SIZE]", - "0x%x", 8) - gtable[gid,3] = tname "_3" - } - } else { - # print primary/escaped tables - if (array_size(table) != 0) { - print_table(table, tname "[INAT_OPCODE_TABLE_SIZE]", - "0x%02x", 256) - etable[eid,0] = tname - if (aid >= 0) - atable[aid,0] = tname - } - if (array_size(lptable1) != 0) { - print_table(lptable1,tname "_1[INAT_OPCODE_TABLE_SIZE]", - "0x%02x", 256) - etable[eid,1] = tname "_1" - if (aid >= 0) - atable[aid,1] = tname "_1" - } - if (array_size(lptable2) != 0) { - print_table(lptable2,tname "_2[INAT_OPCODE_TABLE_SIZE]", - "0x%02x", 256) - etable[eid,2] = tname "_2" - if (aid >= 0) - atable[aid,2] = tname "_2" - } - if (array_size(lptable3) != 0) { - print_table(lptable3,tname "_3[INAT_OPCODE_TABLE_SIZE]", - "0x%02x", 256) - etable[eid,3] = tname "_3" - if (aid >= 0) - atable[aid,3] = tname "_3" - } - } - print "" - clear_vars() -} - -function add_flags(old,new) { - if (old && new) - return old " | " new - else if (old) - return old - else - return new -} - -# convert operands to flags. -function convert_operands(count,opnd, i,j,imm,mod) -{ - imm = null - mod = null - for (j = 1; j <= count; j++) { - i = opnd[j] - if (match(i, imm_expr) == 1) { - if (!imm_flag[i]) - semantic_error("Unknown imm opnd: " i) - if (imm) { - if (i != "Ib") - semantic_error("Second IMM error") - imm = add_flags(imm, "INAT_SCNDIMM") - } else - imm = imm_flag[i] - } else if (match(i, modrm_expr)) - mod = "INAT_MODRM" - } - return add_flags(imm, mod) -} - -/^[0-9a-f]+\:/ { - if (NR == 1) - next - # get index - idx = "0x" substr($1, 1, index($1,":") - 1) - if (idx in table) - semantic_error("Redefine " idx " in " tname) - - # check if escaped opcode - if ("escape" == $2) { - if ($3 != "#") - semantic_error("No escaped name") - ref = "" - for (i = 4; i <= NF; i++) - ref = ref $i - if (ref in escape) - semantic_error("Redefine escape (" ref ")") - escape[ref] = geid - geid++ - table[idx] = "INAT_MAKE_ESCAPE(" escape[ref] ")" - next - } - - variant = null - # converts - i = 2 - while (i <= NF) { - opcode = $(i++) - delete opnds - ext = null - flags = null - opnd = null - # parse one opcode - if (match($i, opnd_expr)) { - opnd = $i - count = split($(i++), opnds, ",") - flags = convert_operands(count, opnds) - } - if (match($i, ext_expr)) - ext = $(i++) - if (match($i, sep_expr)) - i++ - else if (i < NF) - semantic_error($i " is not a separator") - - # check if group opcode - if (match(opcode, group_expr)) { - if (!(opcode in group)) { - group[opcode] = ggid - ggid++ - } - flags = add_flags(flags, "INAT_MAKE_GROUP(" group[opcode] ")") - } - # check force(or default) 64bit - if (match(ext, force64_expr)) - flags = add_flags(flags, "INAT_FORCE64") - - # check REX prefix - if (match(opcode, rex_expr)) - flags = add_flags(flags, "INAT_MAKE_PREFIX(INAT_PFX_REX)") - - # check coprocessor escape : TODO - if (match(opcode, fpu_expr)) - flags = add_flags(flags, "INAT_MODRM") - - # check VEX codes - if (match(ext, evexonly_expr)) - flags = add_flags(flags, "INAT_VEXOK | INAT_EVEXONLY") - else if (match(ext, vexonly_expr)) - flags = add_flags(flags, "INAT_VEXOK | INAT_VEXONLY") - else if (match(ext, vexok_expr) || match(opcode, vexok_opcode_expr)) - flags = add_flags(flags, "INAT_VEXOK") - - # check prefixes - if (match(ext, prefix_expr)) { - if (!prefix_num[opcode]) - semantic_error("Unknown prefix: " opcode) - flags = add_flags(flags, "INAT_MAKE_PREFIX(" prefix_num[opcode] ")") - } - if (length(flags) == 0) - continue - # check if last prefix - if (match(ext, lprefix1_expr)) { - lptable1[idx] = add_flags(lptable1[idx],flags) - variant = "INAT_VARIANT" - } - if (match(ext, lprefix2_expr)) { - lptable2[idx] = add_flags(lptable2[idx],flags) - variant = "INAT_VARIANT" - } - if (match(ext, lprefix3_expr)) { - lptable3[idx] = add_flags(lptable3[idx],flags) - variant = "INAT_VARIANT" - } - if (!match(ext, lprefix_expr)){ - table[idx] = add_flags(table[idx],flags) - } - } - if (variant) - table[idx] = add_flags(table[idx],variant) -} - -END { - if (awkchecked != "") - exit 1 - # print escape opcode map's array - print "/* Escape opcode map array */" - print "const insn_attr_t * const inat_escape_tables[INAT_ESC_MAX + 1]" \ - "[INAT_LSTPFX_MAX + 1] = {" - for (i = 0; i < geid; i++) - for (j = 0; j < max_lprefix; j++) - if (etable[i,j]) - print " ["i"]["j"] = "etable[i,j]"," - print "};\n" - # print group opcode map's array - print "/* Group opcode map array */" - print "const insn_attr_t * const inat_group_tables[INAT_GRP_MAX + 1]"\ - "[INAT_LSTPFX_MAX + 1] = {" - for (i = 0; i < ggid; i++) - for (j = 0; j < max_lprefix; j++) - if (gtable[i,j]) - print " ["i"]["j"] = "gtable[i,j]"," - print "};\n" - # print AVX opcode map's array - print "/* AVX opcode map array */" - print "const insn_attr_t * const inat_avx_tables[X86_VEX_M_MAX + 1]"\ - "[INAT_LSTPFX_MAX + 1] = {" - for (i = 0; i < gaid; i++) - for (j = 0; j < max_lprefix; j++) - if (atable[i,j]) - print " ["i"]["j"] = "atable[i,j]"," - print "};" -} diff --git a/tools/perf/util/intel-pt-decoder/inat.c b/tools/perf/util/intel-pt-decoder/inat.c deleted file mode 100644 index 446c0413a27c..000000000000 --- a/tools/perf/util/intel-pt-decoder/inat.c +++ /dev/null @@ -1,82 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * x86 instruction attribute tables - * - * Written by Masami Hiramatsu - */ -#include "insn.h" - -/* Attribute tables are generated from opcode map */ -#include "inat-tables.c" - -/* Attribute search APIs */ -insn_attr_t inat_get_opcode_attribute(insn_byte_t opcode) -{ - return inat_primary_table[opcode]; -} - -int inat_get_last_prefix_id(insn_byte_t last_pfx) -{ - insn_attr_t lpfx_attr; - - lpfx_attr = inat_get_opcode_attribute(last_pfx); - return inat_last_prefix_id(lpfx_attr); -} - -insn_attr_t inat_get_escape_attribute(insn_byte_t opcode, int lpfx_id, - insn_attr_t esc_attr) -{ - const insn_attr_t *table; - int n; - - n = inat_escape_id(esc_attr); - - table = inat_escape_tables[n][0]; - if (!table) - return 0; - if (inat_has_variant(table[opcode]) && lpfx_id) { - table = inat_escape_tables[n][lpfx_id]; - if (!table) - return 0; - } - return table[opcode]; -} - -insn_attr_t inat_get_group_attribute(insn_byte_t modrm, int lpfx_id, - insn_attr_t grp_attr) -{ - const insn_attr_t *table; - int n; - - n = inat_group_id(grp_attr); - - table = inat_group_tables[n][0]; - if (!table) - return inat_group_common_attribute(grp_attr); - if (inat_has_variant(table[X86_MODRM_REG(modrm)]) && lpfx_id) { - table = inat_group_tables[n][lpfx_id]; - if (!table) - return inat_group_common_attribute(grp_attr); - } - return table[X86_MODRM_REG(modrm)] | - inat_group_common_attribute(grp_attr); -} - -insn_attr_t inat_get_avx_attribute(insn_byte_t opcode, insn_byte_t vex_m, - insn_byte_t vex_p) -{ - const insn_attr_t *table; - if (vex_m > X86_VEX_M_MAX || vex_p > INAT_LSTPFX_MAX) - return 0; - /* At first, this checks the master table */ - table = inat_avx_tables[vex_m][0]; - if (!table) - return 0; - if (!inat_is_group(table[opcode]) && vex_p) { - /* If this is not a group, get attribute directly */ - table = inat_avx_tables[vex_m][vex_p]; - if (!table) - return 0; - } - return table[opcode]; -} diff --git a/tools/perf/util/intel-pt-decoder/inat.h b/tools/perf/util/intel-pt-decoder/inat.h deleted file mode 100644 index 877827b7c2c3..000000000000 --- a/tools/perf/util/intel-pt-decoder/inat.h +++ /dev/null @@ -1,230 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _ASM_X86_INAT_H -#define _ASM_X86_INAT_H -/* - * x86 instruction attributes - * - * Written by Masami Hiramatsu - */ -#include "inat_types.h" - -/* - * Internal bits. Don't use bitmasks directly, because these bits are - * unstable. You should use checking functions. - */ - -#define INAT_OPCODE_TABLE_SIZE 256 -#define INAT_GROUP_TABLE_SIZE 8 - -/* Legacy last prefixes */ -#define INAT_PFX_OPNDSZ 1 /* 0x66 */ /* LPFX1 */ -#define INAT_PFX_REPE 2 /* 0xF3 */ /* LPFX2 */ -#define INAT_PFX_REPNE 3 /* 0xF2 */ /* LPFX3 */ -/* Other Legacy prefixes */ -#define INAT_PFX_LOCK 4 /* 0xF0 */ -#define INAT_PFX_CS 5 /* 0x2E */ -#define INAT_PFX_DS 6 /* 0x3E */ -#define INAT_PFX_ES 7 /* 0x26 */ -#define INAT_PFX_FS 8 /* 0x64 */ -#define INAT_PFX_GS 9 /* 0x65 */ -#define INAT_PFX_SS 10 /* 0x36 */ -#define INAT_PFX_ADDRSZ 11 /* 0x67 */ -/* x86-64 REX prefix */ -#define INAT_PFX_REX 12 /* 0x4X */ -/* AVX VEX prefixes */ -#define INAT_PFX_VEX2 13 /* 2-bytes VEX prefix */ -#define INAT_PFX_VEX3 14 /* 3-bytes VEX prefix */ -#define INAT_PFX_EVEX 15 /* EVEX prefix */ - -#define INAT_LSTPFX_MAX 3 -#define INAT_LGCPFX_MAX 11 - -/* Immediate size */ -#define INAT_IMM_BYTE 1 -#define INAT_IMM_WORD 2 -#define INAT_IMM_DWORD 3 -#define INAT_IMM_QWORD 4 -#define INAT_IMM_PTR 5 -#define INAT_IMM_VWORD32 6 -#define INAT_IMM_VWORD 7 - -/* Legacy prefix */ -#define INAT_PFX_OFFS 0 -#define INAT_PFX_BITS 4 -#define INAT_PFX_MAX ((1 << INAT_PFX_BITS) - 1) -#define INAT_PFX_MASK (INAT_PFX_MAX << INAT_PFX_OFFS) -/* Escape opcodes */ -#define INAT_ESC_OFFS (INAT_PFX_OFFS + INAT_PFX_BITS) -#define INAT_ESC_BITS 2 -#define INAT_ESC_MAX ((1 << INAT_ESC_BITS) - 1) -#define INAT_ESC_MASK (INAT_ESC_MAX << INAT_ESC_OFFS) -/* Group opcodes (1-16) */ -#define INAT_GRP_OFFS (INAT_ESC_OFFS + INAT_ESC_BITS) -#define INAT_GRP_BITS 5 -#define INAT_GRP_MAX ((1 << INAT_GRP_BITS) - 1) -#define INAT_GRP_MASK (INAT_GRP_MAX << INAT_GRP_OFFS) -/* Immediates */ -#define INAT_IMM_OFFS (INAT_GRP_OFFS + INAT_GRP_BITS) -#define INAT_IMM_BITS 3 -#define INAT_IMM_MASK (((1 << INAT_IMM_BITS) - 1) << INAT_IMM_OFFS) -/* Flags */ -#define INAT_FLAG_OFFS (INAT_IMM_OFFS + INAT_IMM_BITS) -#define INAT_MODRM (1 << (INAT_FLAG_OFFS)) -#define INAT_FORCE64 (1 << (INAT_FLAG_OFFS + 1)) -#define INAT_SCNDIMM (1 << (INAT_FLAG_OFFS + 2)) -#define INAT_MOFFSET (1 << (INAT_FLAG_OFFS + 3)) -#define INAT_VARIANT (1 << (INAT_FLAG_OFFS + 4)) -#define INAT_VEXOK (1 << (INAT_FLAG_OFFS + 5)) -#define INAT_VEXONLY (1 << (INAT_FLAG_OFFS + 6)) -#define INAT_EVEXONLY (1 << (INAT_FLAG_OFFS + 7)) -/* Attribute making macros for attribute tables */ -#define INAT_MAKE_PREFIX(pfx) (pfx << INAT_PFX_OFFS) -#define INAT_MAKE_ESCAPE(esc) (esc << INAT_ESC_OFFS) -#define INAT_MAKE_GROUP(grp) ((grp << INAT_GRP_OFFS) | INAT_MODRM) -#define INAT_MAKE_IMM(imm) (imm << INAT_IMM_OFFS) - -/* Identifiers for segment registers */ -#define INAT_SEG_REG_IGNORE 0 -#define INAT_SEG_REG_DEFAULT 1 -#define INAT_SEG_REG_CS 2 -#define INAT_SEG_REG_SS 3 -#define INAT_SEG_REG_DS 4 -#define INAT_SEG_REG_ES 5 -#define INAT_SEG_REG_FS 6 -#define INAT_SEG_REG_GS 7 - -/* Attribute search APIs */ -extern insn_attr_t inat_get_opcode_attribute(insn_byte_t opcode); -extern int inat_get_last_prefix_id(insn_byte_t last_pfx); -extern insn_attr_t inat_get_escape_attribute(insn_byte_t opcode, - int lpfx_id, - insn_attr_t esc_attr); -extern insn_attr_t inat_get_group_attribute(insn_byte_t modrm, - int lpfx_id, - insn_attr_t esc_attr); -extern insn_attr_t inat_get_avx_attribute(insn_byte_t opcode, - insn_byte_t vex_m, - insn_byte_t vex_pp); - -/* Attribute checking functions */ -static inline int inat_is_legacy_prefix(insn_attr_t attr) -{ - attr &= INAT_PFX_MASK; - return attr && attr <= INAT_LGCPFX_MAX; -} - -static inline int inat_is_address_size_prefix(insn_attr_t attr) -{ - return (attr & INAT_PFX_MASK) == INAT_PFX_ADDRSZ; -} - -static inline int inat_is_operand_size_prefix(insn_attr_t attr) -{ - return (attr & INAT_PFX_MASK) == INAT_PFX_OPNDSZ; -} - -static inline int inat_is_rex_prefix(insn_attr_t attr) -{ - return (attr & INAT_PFX_MASK) == INAT_PFX_REX; -} - -static inline int inat_last_prefix_id(insn_attr_t attr) -{ - if ((attr & INAT_PFX_MASK) > INAT_LSTPFX_MAX) - return 0; - else - return attr & INAT_PFX_MASK; -} - -static inline int inat_is_vex_prefix(insn_attr_t attr) -{ - attr &= INAT_PFX_MASK; - return attr == INAT_PFX_VEX2 || attr == INAT_PFX_VEX3 || - attr == INAT_PFX_EVEX; -} - -static inline int inat_is_evex_prefix(insn_attr_t attr) -{ - return (attr & INAT_PFX_MASK) == INAT_PFX_EVEX; -} - -static inline int inat_is_vex3_prefix(insn_attr_t attr) -{ - return (attr & INAT_PFX_MASK) == INAT_PFX_VEX3; -} - -static inline int inat_is_escape(insn_attr_t attr) -{ - return attr & INAT_ESC_MASK; -} - -static inline int inat_escape_id(insn_attr_t attr) -{ - return (attr & INAT_ESC_MASK) >> INAT_ESC_OFFS; -} - -static inline int inat_is_group(insn_attr_t attr) -{ - return attr & INAT_GRP_MASK; -} - -static inline int inat_group_id(insn_attr_t attr) -{ - return (attr & INAT_GRP_MASK) >> INAT_GRP_OFFS; -} - -static inline int inat_group_common_attribute(insn_attr_t attr) -{ - return attr & ~INAT_GRP_MASK; -} - -static inline int inat_has_immediate(insn_attr_t attr) -{ - return attr & INAT_IMM_MASK; -} - -static inline int inat_immediate_size(insn_attr_t attr) -{ - return (attr & INAT_IMM_MASK) >> INAT_IMM_OFFS; -} - -static inline int inat_has_modrm(insn_attr_t attr) -{ - return attr & INAT_MODRM; -} - -static inline int inat_is_force64(insn_attr_t attr) -{ - return attr & INAT_FORCE64; -} - -static inline int inat_has_second_immediate(insn_attr_t attr) -{ - return attr & INAT_SCNDIMM; -} - -static inline int inat_has_moffset(insn_attr_t attr) -{ - return attr & INAT_MOFFSET; -} - -static inline int inat_has_variant(insn_attr_t attr) -{ - return attr & INAT_VARIANT; -} - -static inline int inat_accept_vex(insn_attr_t attr) -{ - return attr & INAT_VEXOK; -} - -static inline int inat_must_vex(insn_attr_t attr) -{ - return attr & (INAT_VEXONLY | INAT_EVEXONLY); -} - -static inline int inat_must_evex(insn_attr_t attr) -{ - return attr & INAT_EVEXONLY; -} -#endif diff --git a/tools/perf/util/intel-pt-decoder/inat_types.h b/tools/perf/util/intel-pt-decoder/inat_types.h deleted file mode 100644 index b047efa9ddc2..000000000000 --- a/tools/perf/util/intel-pt-decoder/inat_types.h +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _ASM_X86_INAT_TYPES_H -#define _ASM_X86_INAT_TYPES_H -/* - * x86 instruction attributes - * - * Written by Masami Hiramatsu - */ - -/* Instruction attributes */ -typedef unsigned int insn_attr_t; -typedef unsigned char insn_byte_t; -typedef signed int insn_value_t; - -#endif diff --git a/tools/perf/util/intel-pt-decoder/insn.c b/tools/perf/util/intel-pt-decoder/insn.c deleted file mode 100644 index 82783bf43b74..000000000000 --- a/tools/perf/util/intel-pt-decoder/insn.c +++ /dev/null @@ -1,593 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * x86 instruction analysis - * - * Copyright (C) IBM Corporation, 2002, 2004, 2009 - */ - -#ifdef __KERNEL__ -#include -#else -#include -#endif -#include "inat.h" -#include "insn.h" - -/* Verify next sizeof(t) bytes can be on the same instruction */ -#define validate_next(t, insn, n) \ - ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr) - -#define __get_next(t, insn) \ - ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; }) - -#define __peek_nbyte_next(t, insn, n) \ - ({ t r = *(t*)((insn)->next_byte + n); r; }) - -#define get_next(t, insn) \ - ({ if (unlikely(!validate_next(t, insn, 0))) goto err_out; __get_next(t, insn); }) - -#define peek_nbyte_next(t, insn, n) \ - ({ if (unlikely(!validate_next(t, insn, n))) goto err_out; __peek_nbyte_next(t, insn, n); }) - -#define peek_next(t, insn) peek_nbyte_next(t, insn, 0) - -/** - * insn_init() - initialize struct insn - * @insn: &struct insn to be initialized - * @kaddr: address (in kernel memory) of instruction (or copy thereof) - * @x86_64: !0 for 64-bit kernel or 64-bit app - */ -void insn_init(struct insn *insn, const void *kaddr, int buf_len, int x86_64) -{ - /* - * Instructions longer than MAX_INSN_SIZE (15 bytes) are invalid - * even if the input buffer is long enough to hold them. - */ - if (buf_len > MAX_INSN_SIZE) - buf_len = MAX_INSN_SIZE; - - memset(insn, 0, sizeof(*insn)); - insn->kaddr = kaddr; - insn->end_kaddr = kaddr + buf_len; - insn->next_byte = kaddr; - insn->x86_64 = x86_64 ? 1 : 0; - insn->opnd_bytes = 4; - if (x86_64) - insn->addr_bytes = 8; - else - insn->addr_bytes = 4; -} - -/** - * insn_get_prefixes - scan x86 instruction prefix bytes - * @insn: &struct insn containing instruction - * - * Populates the @insn->prefixes bitmap, and updates @insn->next_byte - * to point to the (first) opcode. No effect if @insn->prefixes.got - * is already set. - */ -void insn_get_prefixes(struct insn *insn) -{ - struct insn_field *prefixes = &insn->prefixes; - insn_attr_t attr; - insn_byte_t b, lb; - int i, nb; - - if (prefixes->got) - return; - - nb = 0; - lb = 0; - b = peek_next(insn_byte_t, insn); - attr = inat_get_opcode_attribute(b); - while (inat_is_legacy_prefix(attr)) { - /* Skip if same prefix */ - for (i = 0; i < nb; i++) - if (prefixes->bytes[i] == b) - goto found; - if (nb == 4) - /* Invalid instruction */ - break; - prefixes->bytes[nb++] = b; - if (inat_is_address_size_prefix(attr)) { - /* address size switches 2/4 or 4/8 */ - if (insn->x86_64) - insn->addr_bytes ^= 12; - else - insn->addr_bytes ^= 6; - } else if (inat_is_operand_size_prefix(attr)) { - /* oprand size switches 2/4 */ - insn->opnd_bytes ^= 6; - } -found: - prefixes->nbytes++; - insn->next_byte++; - lb = b; - b = peek_next(insn_byte_t, insn); - attr = inat_get_opcode_attribute(b); - } - /* Set the last prefix */ - if (lb && lb != insn->prefixes.bytes[3]) { - if (unlikely(insn->prefixes.bytes[3])) { - /* Swap the last prefix */ - b = insn->prefixes.bytes[3]; - for (i = 0; i < nb; i++) - if (prefixes->bytes[i] == lb) - prefixes->bytes[i] = b; - } - insn->prefixes.bytes[3] = lb; - } - - /* Decode REX prefix */ - if (insn->x86_64) { - b = peek_next(insn_byte_t, insn); - attr = inat_get_opcode_attribute(b); - if (inat_is_rex_prefix(attr)) { - insn->rex_prefix.value = b; - insn->rex_prefix.nbytes = 1; - insn->next_byte++; - if (X86_REX_W(b)) - /* REX.W overrides opnd_size */ - insn->opnd_bytes = 8; - } - } - insn->rex_prefix.got = 1; - - /* Decode VEX prefix */ - b = peek_next(insn_byte_t, insn); - attr = inat_get_opcode_attribute(b); - if (inat_is_vex_prefix(attr)) { - insn_byte_t b2 = peek_nbyte_next(insn_byte_t, insn, 1); - if (!insn->x86_64) { - /* - * In 32-bits mode, if the [7:6] bits (mod bits of - * ModRM) on the second byte are not 11b, it is - * LDS or LES or BOUND. - */ - if (X86_MODRM_MOD(b2) != 3) - goto vex_end; - } - insn->vex_prefix.bytes[0] = b; - insn->vex_prefix.bytes[1] = b2; - if (inat_is_evex_prefix(attr)) { - b2 = peek_nbyte_next(insn_byte_t, insn, 2); - insn->vex_prefix.bytes[2] = b2; - b2 = peek_nbyte_next(insn_byte_t, insn, 3); - insn->vex_prefix.bytes[3] = b2; - insn->vex_prefix.nbytes = 4; - insn->next_byte += 4; - if (insn->x86_64 && X86_VEX_W(b2)) - /* VEX.W overrides opnd_size */ - insn->opnd_bytes = 8; - } else if (inat_is_vex3_prefix(attr)) { - b2 = peek_nbyte_next(insn_byte_t, insn, 2); - insn->vex_prefix.bytes[2] = b2; - insn->vex_prefix.nbytes = 3; - insn->next_byte += 3; - if (insn->x86_64 && X86_VEX_W(b2)) - /* VEX.W overrides opnd_size */ - insn->opnd_bytes = 8; - } else { - /* - * For VEX2, fake VEX3-like byte#2. - * Makes it easier to decode vex.W, vex.vvvv, - * vex.L and vex.pp. Masking with 0x7f sets vex.W == 0. - */ - insn->vex_prefix.bytes[2] = b2 & 0x7f; - insn->vex_prefix.nbytes = 2; - insn->next_byte += 2; - } - } -vex_end: - insn->vex_prefix.got = 1; - - prefixes->got = 1; - -err_out: - return; -} - -/** - * insn_get_opcode - collect opcode(s) - * @insn: &struct insn containing instruction - * - * Populates @insn->opcode, updates @insn->next_byte to point past the - * opcode byte(s), and set @insn->attr (except for groups). - * If necessary, first collects any preceding (prefix) bytes. - * Sets @insn->opcode.value = opcode1. No effect if @insn->opcode.got - * is already 1. - */ -void insn_get_opcode(struct insn *insn) -{ - struct insn_field *opcode = &insn->opcode; - insn_byte_t op; - int pfx_id; - if (opcode->got) - return; - if (!insn->prefixes.got) - insn_get_prefixes(insn); - - /* Get first opcode */ - op = get_next(insn_byte_t, insn); - opcode->bytes[0] = op; - opcode->nbytes = 1; - - /* Check if there is VEX prefix or not */ - if (insn_is_avx(insn)) { - insn_byte_t m, p; - m = insn_vex_m_bits(insn); - p = insn_vex_p_bits(insn); - insn->attr = inat_get_avx_attribute(op, m, p); - if ((inat_must_evex(insn->attr) && !insn_is_evex(insn)) || - (!inat_accept_vex(insn->attr) && - !inat_is_group(insn->attr))) - insn->attr = 0; /* This instruction is bad */ - goto end; /* VEX has only 1 byte for opcode */ - } - - insn->attr = inat_get_opcode_attribute(op); - while (inat_is_escape(insn->attr)) { - /* Get escaped opcode */ - op = get_next(insn_byte_t, insn); - opcode->bytes[opcode->nbytes++] = op; - pfx_id = insn_last_prefix_id(insn); - insn->attr = inat_get_escape_attribute(op, pfx_id, insn->attr); - } - if (inat_must_vex(insn->attr)) - insn->attr = 0; /* This instruction is bad */ -end: - opcode->got = 1; - -err_out: - return; -} - -/** - * insn_get_modrm - collect ModRM byte, if any - * @insn: &struct insn containing instruction - * - * Populates @insn->modrm and updates @insn->next_byte to point past the - * ModRM byte, if any. If necessary, first collects the preceding bytes - * (prefixes and opcode(s)). No effect if @insn->modrm.got is already 1. - */ -void insn_get_modrm(struct insn *insn) -{ - struct insn_field *modrm = &insn->modrm; - insn_byte_t pfx_id, mod; - if (modrm->got) - return; - if (!insn->opcode.got) - insn_get_opcode(insn); - - if (inat_has_modrm(insn->attr)) { - mod = get_next(insn_byte_t, insn); - modrm->value = mod; - modrm->nbytes = 1; - if (inat_is_group(insn->attr)) { - pfx_id = insn_last_prefix_id(insn); - insn->attr = inat_get_group_attribute(mod, pfx_id, - insn->attr); - if (insn_is_avx(insn) && !inat_accept_vex(insn->attr)) - insn->attr = 0; /* This is bad */ - } - } - - if (insn->x86_64 && inat_is_force64(insn->attr)) - insn->opnd_bytes = 8; - modrm->got = 1; - -err_out: - return; -} - - -/** - * insn_rip_relative() - Does instruction use RIP-relative addressing mode? - * @insn: &struct insn containing instruction - * - * If necessary, first collects the instruction up to and including the - * ModRM byte. No effect if @insn->x86_64 is 0. - */ -int insn_rip_relative(struct insn *insn) -{ - struct insn_field *modrm = &insn->modrm; - - if (!insn->x86_64) - return 0; - if (!modrm->got) - insn_get_modrm(insn); - /* - * For rip-relative instructions, the mod field (top 2 bits) - * is zero and the r/m field (bottom 3 bits) is 0x5. - */ - return (modrm->nbytes && (modrm->value & 0xc7) == 0x5); -} - -/** - * insn_get_sib() - Get the SIB byte of instruction - * @insn: &struct insn containing instruction - * - * If necessary, first collects the instruction up to and including the - * ModRM byte. - */ -void insn_get_sib(struct insn *insn) -{ - insn_byte_t modrm; - - if (insn->sib.got) - return; - if (!insn->modrm.got) - insn_get_modrm(insn); - if (insn->modrm.nbytes) { - modrm = (insn_byte_t)insn->modrm.value; - if (insn->addr_bytes != 2 && - X86_MODRM_MOD(modrm) != 3 && X86_MODRM_RM(modrm) == 4) { - insn->sib.value = get_next(insn_byte_t, insn); - insn->sib.nbytes = 1; - } - } - insn->sib.got = 1; - -err_out: - return; -} - - -/** - * insn_get_displacement() - Get the displacement of instruction - * @insn: &struct insn containing instruction - * - * If necessary, first collects the instruction up to and including the - * SIB byte. - * Displacement value is sign-expanded. - */ -void insn_get_displacement(struct insn *insn) -{ - insn_byte_t mod, rm, base; - - if (insn->displacement.got) - return; - if (!insn->sib.got) - insn_get_sib(insn); - if (insn->modrm.nbytes) { - /* - * Interpreting the modrm byte: - * mod = 00 - no displacement fields (exceptions below) - * mod = 01 - 1-byte displacement field - * mod = 10 - displacement field is 4 bytes, or 2 bytes if - * address size = 2 (0x67 prefix in 32-bit mode) - * mod = 11 - no memory operand - * - * If address size = 2... - * mod = 00, r/m = 110 - displacement field is 2 bytes - * - * If address size != 2... - * mod != 11, r/m = 100 - SIB byte exists - * mod = 00, SIB base = 101 - displacement field is 4 bytes - * mod = 00, r/m = 101 - rip-relative addressing, displacement - * field is 4 bytes - */ - mod = X86_MODRM_MOD(insn->modrm.value); - rm = X86_MODRM_RM(insn->modrm.value); - base = X86_SIB_BASE(insn->sib.value); - if (mod == 3) - goto out; - if (mod == 1) { - insn->displacement.value = get_next(signed char, insn); - insn->displacement.nbytes = 1; - } else if (insn->addr_bytes == 2) { - if ((mod == 0 && rm == 6) || mod == 2) { - insn->displacement.value = - get_next(short, insn); - insn->displacement.nbytes = 2; - } - } else { - if ((mod == 0 && rm == 5) || mod == 2 || - (mod == 0 && base == 5)) { - insn->displacement.value = get_next(int, insn); - insn->displacement.nbytes = 4; - } - } - } -out: - insn->displacement.got = 1; - -err_out: - return; -} - -/* Decode moffset16/32/64. Return 0 if failed */ -static int __get_moffset(struct insn *insn) -{ - switch (insn->addr_bytes) { - case 2: - insn->moffset1.value = get_next(short, insn); - insn->moffset1.nbytes = 2; - break; - case 4: - insn->moffset1.value = get_next(int, insn); - insn->moffset1.nbytes = 4; - break; - case 8: - insn->moffset1.value = get_next(int, insn); - insn->moffset1.nbytes = 4; - insn->moffset2.value = get_next(int, insn); - insn->moffset2.nbytes = 4; - break; - default: /* opnd_bytes must be modified manually */ - goto err_out; - } - insn->moffset1.got = insn->moffset2.got = 1; - - return 1; - -err_out: - return 0; -} - -/* Decode imm v32(Iz). Return 0 if failed */ -static int __get_immv32(struct insn *insn) -{ - switch (insn->opnd_bytes) { - case 2: - insn->immediate.value = get_next(short, insn); - insn->immediate.nbytes = 2; - break; - case 4: - case 8: - insn->immediate.value = get_next(int, insn); - insn->immediate.nbytes = 4; - break; - default: /* opnd_bytes must be modified manually */ - goto err_out; - } - - return 1; - -err_out: - return 0; -} - -/* Decode imm v64(Iv/Ov), Return 0 if failed */ -static int __get_immv(struct insn *insn) -{ - switch (insn->opnd_bytes) { - case 2: - insn->immediate1.value = get_next(short, insn); - insn->immediate1.nbytes = 2; - break; - case 4: - insn->immediate1.value = get_next(int, insn); - insn->immediate1.nbytes = 4; - break; - case 8: - insn->immediate1.value = get_next(int, insn); - insn->immediate1.nbytes = 4; - insn->immediate2.value = get_next(int, insn); - insn->immediate2.nbytes = 4; - break; - default: /* opnd_bytes must be modified manually */ - goto err_out; - } - insn->immediate1.got = insn->immediate2.got = 1; - - return 1; -err_out: - return 0; -} - -/* Decode ptr16:16/32(Ap) */ -static int __get_immptr(struct insn *insn) -{ - switch (insn->opnd_bytes) { - case 2: - insn->immediate1.value = get_next(short, insn); - insn->immediate1.nbytes = 2; - break; - case 4: - insn->immediate1.value = get_next(int, insn); - insn->immediate1.nbytes = 4; - break; - case 8: - /* ptr16:64 is not exist (no segment) */ - return 0; - default: /* opnd_bytes must be modified manually */ - goto err_out; - } - insn->immediate2.value = get_next(unsigned short, insn); - insn->immediate2.nbytes = 2; - insn->immediate1.got = insn->immediate2.got = 1; - - return 1; -err_out: - return 0; -} - -/** - * insn_get_immediate() - Get the immediates of instruction - * @insn: &struct insn containing instruction - * - * If necessary, first collects the instruction up to and including the - * displacement bytes. - * Basically, most of immediates are sign-expanded. Unsigned-value can be - * get by bit masking with ((1 << (nbytes * 8)) - 1) - */ -void insn_get_immediate(struct insn *insn) -{ - if (insn->immediate.got) - return; - if (!insn->displacement.got) - insn_get_displacement(insn); - - if (inat_has_moffset(insn->attr)) { - if (!__get_moffset(insn)) - goto err_out; - goto done; - } - - if (!inat_has_immediate(insn->attr)) - /* no immediates */ - goto done; - - switch (inat_immediate_size(insn->attr)) { - case INAT_IMM_BYTE: - insn->immediate.value = get_next(signed char, insn); - insn->immediate.nbytes = 1; - break; - case INAT_IMM_WORD: - insn->immediate.value = get_next(short, insn); - insn->immediate.nbytes = 2; - break; - case INAT_IMM_DWORD: - insn->immediate.value = get_next(int, insn); - insn->immediate.nbytes = 4; - break; - case INAT_IMM_QWORD: - insn->immediate1.value = get_next(int, insn); - insn->immediate1.nbytes = 4; - insn->immediate2.value = get_next(int, insn); - insn->immediate2.nbytes = 4; - break; - case INAT_IMM_PTR: - if (!__get_immptr(insn)) - goto err_out; - break; - case INAT_IMM_VWORD32: - if (!__get_immv32(insn)) - goto err_out; - break; - case INAT_IMM_VWORD: - if (!__get_immv(insn)) - goto err_out; - break; - default: - /* Here, insn must have an immediate, but failed */ - goto err_out; - } - if (inat_has_second_immediate(insn->attr)) { - insn->immediate2.value = get_next(signed char, insn); - insn->immediate2.nbytes = 1; - } -done: - insn->immediate.got = 1; - -err_out: - return; -} - -/** - * insn_get_length() - Get the length of instruction - * @insn: &struct insn containing instruction - * - * If necessary, first collects the instruction up to and including the - * immediates bytes. - */ -void insn_get_length(struct insn *insn) -{ - if (insn->length) - return; - if (!insn->immediate.got) - insn_get_immediate(insn); - insn->length = (unsigned char)((unsigned long)insn->next_byte - - (unsigned long)insn->kaddr); -} diff --git a/tools/perf/util/intel-pt-decoder/insn.h b/tools/perf/util/intel-pt-decoder/insn.h deleted file mode 100644 index 37a4c390750b..000000000000 --- a/tools/perf/util/intel-pt-decoder/insn.h +++ /dev/null @@ -1,216 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _ASM_X86_INSN_H -#define _ASM_X86_INSN_H -/* - * x86 instruction analysis - * - * Copyright (C) IBM Corporation, 2009 - */ - -/* insn_attr_t is defined in inat.h */ -#include "inat.h" - -struct insn_field { - union { - insn_value_t value; - insn_byte_t bytes[4]; - }; - /* !0 if we've run insn_get_xxx() for this field */ - unsigned char got; - unsigned char nbytes; -}; - -struct insn { - struct insn_field prefixes; /* - * Prefixes - * prefixes.bytes[3]: last prefix - */ - struct insn_field rex_prefix; /* REX prefix */ - struct insn_field vex_prefix; /* VEX prefix */ - struct insn_field opcode; /* - * opcode.bytes[0]: opcode1 - * opcode.bytes[1]: opcode2 - * opcode.bytes[2]: opcode3 - */ - struct insn_field modrm; - struct insn_field sib; - struct insn_field displacement; - union { - struct insn_field immediate; - struct insn_field moffset1; /* for 64bit MOV */ - struct insn_field immediate1; /* for 64bit imm or off16/32 */ - }; - union { - struct insn_field moffset2; /* for 64bit MOV */ - struct insn_field immediate2; /* for 64bit imm or seg16 */ - }; - - insn_attr_t attr; - unsigned char opnd_bytes; - unsigned char addr_bytes; - unsigned char length; - unsigned char x86_64; - - const insn_byte_t *kaddr; /* kernel address of insn to analyze */ - const insn_byte_t *end_kaddr; /* kernel address of last insn in buffer */ - const insn_byte_t *next_byte; -}; - -#define MAX_INSN_SIZE 15 - -#define X86_MODRM_MOD(modrm) (((modrm) & 0xc0) >> 6) -#define X86_MODRM_REG(modrm) (((modrm) & 0x38) >> 3) -#define X86_MODRM_RM(modrm) ((modrm) & 0x07) - -#define X86_SIB_SCALE(sib) (((sib) & 0xc0) >> 6) -#define X86_SIB_INDEX(sib) (((sib) & 0x38) >> 3) -#define X86_SIB_BASE(sib) ((sib) & 0x07) - -#define X86_REX_W(rex) ((rex) & 8) -#define X86_REX_R(rex) ((rex) & 4) -#define X86_REX_X(rex) ((rex) & 2) -#define X86_REX_B(rex) ((rex) & 1) - -/* VEX bit flags */ -#define X86_VEX_W(vex) ((vex) & 0x80) /* VEX3 Byte2 */ -#define X86_VEX_R(vex) ((vex) & 0x80) /* VEX2/3 Byte1 */ -#define X86_VEX_X(vex) ((vex) & 0x40) /* VEX3 Byte1 */ -#define X86_VEX_B(vex) ((vex) & 0x20) /* VEX3 Byte1 */ -#define X86_VEX_L(vex) ((vex) & 0x04) /* VEX3 Byte2, VEX2 Byte1 */ -/* VEX bit fields */ -#define X86_EVEX_M(vex) ((vex) & 0x03) /* EVEX Byte1 */ -#define X86_VEX3_M(vex) ((vex) & 0x1f) /* VEX3 Byte1 */ -#define X86_VEX2_M 1 /* VEX2.M always 1 */ -#define X86_VEX_V(vex) (((vex) & 0x78) >> 3) /* VEX3 Byte2, VEX2 Byte1 */ -#define X86_VEX_P(vex) ((vex) & 0x03) /* VEX3 Byte2, VEX2 Byte1 */ -#define X86_VEX_M_MAX 0x1f /* VEX3.M Maximum value */ - -extern void insn_init(struct insn *insn, const void *kaddr, int buf_len, int x86_64); -extern void insn_get_prefixes(struct insn *insn); -extern void insn_get_opcode(struct insn *insn); -extern void insn_get_modrm(struct insn *insn); -extern void insn_get_sib(struct insn *insn); -extern void insn_get_displacement(struct insn *insn); -extern void insn_get_immediate(struct insn *insn); -extern void insn_get_length(struct insn *insn); - -/* Attribute will be determined after getting ModRM (for opcode groups) */ -static inline void insn_get_attribute(struct insn *insn) -{ - insn_get_modrm(insn); -} - -/* Instruction uses RIP-relative addressing */ -extern int insn_rip_relative(struct insn *insn); - -/* Init insn for kernel text */ -static inline void kernel_insn_init(struct insn *insn, - const void *kaddr, int buf_len) -{ -#ifdef CONFIG_X86_64 - insn_init(insn, kaddr, buf_len, 1); -#else /* CONFIG_X86_32 */ - insn_init(insn, kaddr, buf_len, 0); -#endif -} - -static inline int insn_is_avx(struct insn *insn) -{ - if (!insn->prefixes.got) - insn_get_prefixes(insn); - return (insn->vex_prefix.value != 0); -} - -static inline int insn_is_evex(struct insn *insn) -{ - if (!insn->prefixes.got) - insn_get_prefixes(insn); - return (insn->vex_prefix.nbytes == 4); -} - -/* Ensure this instruction is decoded completely */ -static inline int insn_complete(struct insn *insn) -{ - return insn->opcode.got && insn->modrm.got && insn->sib.got && - insn->displacement.got && insn->immediate.got; -} - -static inline insn_byte_t insn_vex_m_bits(struct insn *insn) -{ - if (insn->vex_prefix.nbytes == 2) /* 2 bytes VEX */ - return X86_VEX2_M; - else if (insn->vex_prefix.nbytes == 3) /* 3 bytes VEX */ - return X86_VEX3_M(insn->vex_prefix.bytes[1]); - else /* EVEX */ - return X86_EVEX_M(insn->vex_prefix.bytes[1]); -} - -static inline insn_byte_t insn_vex_p_bits(struct insn *insn) -{ - if (insn->vex_prefix.nbytes == 2) /* 2 bytes VEX */ - return X86_VEX_P(insn->vex_prefix.bytes[1]); - else - return X86_VEX_P(insn->vex_prefix.bytes[2]); -} - -/* Get the last prefix id from last prefix or VEX prefix */ -static inline int insn_last_prefix_id(struct insn *insn) -{ - if (insn_is_avx(insn)) - return insn_vex_p_bits(insn); /* VEX_p is a SIMD prefix id */ - - if (insn->prefixes.bytes[3]) - return inat_get_last_prefix_id(insn->prefixes.bytes[3]); - - return 0; -} - -/* Offset of each field from kaddr */ -static inline int insn_offset_rex_prefix(struct insn *insn) -{ - return insn->prefixes.nbytes; -} -static inline int insn_offset_vex_prefix(struct insn *insn) -{ - return insn_offset_rex_prefix(insn) + insn->rex_prefix.nbytes; -} -static inline int insn_offset_opcode(struct insn *insn) -{ - return insn_offset_vex_prefix(insn) + insn->vex_prefix.nbytes; -} -static inline int insn_offset_modrm(struct insn *insn) -{ - return insn_offset_opcode(insn) + insn->opcode.nbytes; -} -static inline int insn_offset_sib(struct insn *insn) -{ - return insn_offset_modrm(insn) + insn->modrm.nbytes; -} -static inline int insn_offset_displacement(struct insn *insn) -{ - return insn_offset_sib(insn) + insn->sib.nbytes; -} -static inline int insn_offset_immediate(struct insn *insn) -{ - return insn_offset_displacement(insn) + insn->displacement.nbytes; -} - -#define POP_SS_OPCODE 0x1f -#define MOV_SREG_OPCODE 0x8e - -/* - * Intel SDM Vol.3A 6.8.3 states; - * "Any single-step trap that would be delivered following the MOV to SS - * instruction or POP to SS instruction (because EFLAGS.TF is 1) is - * suppressed." - * This function returns true if @insn is MOV SS or POP SS. On these - * instructions, single stepping is suppressed. - */ -static inline int insn_masking_exception(struct insn *insn) -{ - return insn->opcode.bytes[0] == POP_SS_OPCODE || - (insn->opcode.bytes[0] == MOV_SREG_OPCODE && - X86_MODRM_REG(insn->modrm.bytes[0]) == 2); -} - -#endif /* _ASM_X86_INSN_H */ diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c index 598f56be9f17..fb8a3558d3d5 100644 --- a/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c +++ b/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c @@ -4,18 +4,18 @@ * Copyright (c) 2013-2014, Intel Corporation. */ +#include #include #include #include #include +#include "../../../arch/x86/include/asm/insn.h" + +#include "../../../arch/x86/lib/inat.c" +#include "../../../arch/x86/lib/insn.c" #include "event.h" -#include "insn.h" - -#include "inat.c" -#include "insn.c" - #include "intel-pt-insn-decoder.h" #include "dump-insn.h" diff --git a/tools/perf/util/intel-pt-decoder/x86-opcode-map.txt b/tools/perf/util/intel-pt-decoder/x86-opcode-map.txt deleted file mode 100644 index e0b85930dd77..000000000000 --- a/tools/perf/util/intel-pt-decoder/x86-opcode-map.txt +++ /dev/null @@ -1,1072 +0,0 @@ -# x86 Opcode Maps -# -# This is (mostly) based on following documentations. -# - Intel(R) 64 and IA-32 Architectures Software Developer's Manual Vol.2C -# (#326018-047US, June 2013) -# -# -# Table: table-name -# Referrer: escaped-name -# AVXcode: avx-code -# opcode: mnemonic|GrpXXX [operand1[,operand2...]] [(extra1)[,(extra2)...] [| 2nd-mnemonic ...] -# (or) -# opcode: escape # escaped-name -# EndTable -# -# mnemonics that begin with lowercase 'v' accept a VEX or EVEX prefix -# mnemonics that begin with lowercase 'k' accept a VEX prefix -# -# -# GrpTable: GrpXXX -# reg: mnemonic [operand1[,operand2...]] [(extra1)[,(extra2)...] [| 2nd-mnemonic ...] -# EndTable -# -# AVX Superscripts -# (ev): this opcode requires EVEX prefix. -# (evo): this opcode is changed by EVEX prefix (EVEX opcode) -# (v): this opcode requires VEX prefix. -# (v1): this opcode only supports 128bit VEX. -# -# Last Prefix Superscripts -# - (66): the last prefix is 0x66 -# - (F3): the last prefix is 0xF3 -# - (F2): the last prefix is 0xF2 -# - (!F3) : the last prefix is not 0xF3 (including non-last prefix case) -# - (66&F2): Both 0x66 and 0xF2 prefixes are specified. - -Table: one byte opcode -Referrer: -AVXcode: -# 0x00 - 0x0f -00: ADD Eb,Gb -01: ADD Ev,Gv -02: ADD Gb,Eb -03: ADD Gv,Ev -04: ADD AL,Ib -05: ADD rAX,Iz -06: PUSH ES (i64) -07: POP ES (i64) -08: OR Eb,Gb -09: OR Ev,Gv -0a: OR Gb,Eb -0b: OR Gv,Ev -0c: OR AL,Ib -0d: OR rAX,Iz -0e: PUSH CS (i64) -0f: escape # 2-byte escape -# 0x10 - 0x1f -10: ADC Eb,Gb -11: ADC Ev,Gv -12: ADC Gb,Eb -13: ADC Gv,Ev -14: ADC AL,Ib -15: ADC rAX,Iz -16: PUSH SS (i64) -17: POP SS (i64) -18: SBB Eb,Gb -19: SBB Ev,Gv -1a: SBB Gb,Eb -1b: SBB Gv,Ev -1c: SBB AL,Ib -1d: SBB rAX,Iz -1e: PUSH DS (i64) -1f: POP DS (i64) -# 0x20 - 0x2f -20: AND Eb,Gb -21: AND Ev,Gv -22: AND Gb,Eb -23: AND Gv,Ev -24: AND AL,Ib -25: AND rAx,Iz -26: SEG=ES (Prefix) -27: DAA (i64) -28: SUB Eb,Gb -29: SUB Ev,Gv -2a: SUB Gb,Eb -2b: SUB Gv,Ev -2c: SUB AL,Ib -2d: SUB rAX,Iz -2e: SEG=CS (Prefix) -2f: DAS (i64) -# 0x30 - 0x3f -30: XOR Eb,Gb -31: XOR Ev,Gv -32: XOR Gb,Eb -33: XOR Gv,Ev -34: XOR AL,Ib -35: XOR rAX,Iz -36: SEG=SS (Prefix) -37: AAA (i64) -38: CMP Eb,Gb -39: CMP Ev,Gv -3a: CMP Gb,Eb -3b: CMP Gv,Ev -3c: CMP AL,Ib -3d: CMP rAX,Iz -3e: SEG=DS (Prefix) -3f: AAS (i64) -# 0x40 - 0x4f -40: INC eAX (i64) | REX (o64) -41: INC eCX (i64) | REX.B (o64) -42: INC eDX (i64) | REX.X (o64) -43: INC eBX (i64) | REX.XB (o64) -44: INC eSP (i64) | REX.R (o64) -45: INC eBP (i64) | REX.RB (o64) -46: INC eSI (i64) | REX.RX (o64) -47: INC eDI (i64) | REX.RXB (o64) -48: DEC eAX (i64) | REX.W (o64) -49: DEC eCX (i64) | REX.WB (o64) -4a: DEC eDX (i64) | REX.WX (o64) -4b: DEC eBX (i64) | REX.WXB (o64) -4c: DEC eSP (i64) | REX.WR (o64) -4d: DEC eBP (i64) | REX.WRB (o64) -4e: DEC eSI (i64) | REX.WRX (o64) -4f: DEC eDI (i64) | REX.WRXB (o64) -# 0x50 - 0x5f -50: PUSH rAX/r8 (d64) -51: PUSH rCX/r9 (d64) -52: PUSH rDX/r10 (d64) -53: PUSH rBX/r11 (d64) -54: PUSH rSP/r12 (d64) -55: PUSH rBP/r13 (d64) -56: PUSH rSI/r14 (d64) -57: PUSH rDI/r15 (d64) -58: POP rAX/r8 (d64) -59: POP rCX/r9 (d64) -5a: POP rDX/r10 (d64) -5b: POP rBX/r11 (d64) -5c: POP rSP/r12 (d64) -5d: POP rBP/r13 (d64) -5e: POP rSI/r14 (d64) -5f: POP rDI/r15 (d64) -# 0x60 - 0x6f -60: PUSHA/PUSHAD (i64) -61: POPA/POPAD (i64) -62: BOUND Gv,Ma (i64) | EVEX (Prefix) -63: ARPL Ew,Gw (i64) | MOVSXD Gv,Ev (o64) -64: SEG=FS (Prefix) -65: SEG=GS (Prefix) -66: Operand-Size (Prefix) -67: Address-Size (Prefix) -68: PUSH Iz (d64) -69: IMUL Gv,Ev,Iz -6a: PUSH Ib (d64) -6b: IMUL Gv,Ev,Ib -6c: INS/INSB Yb,DX -6d: INS/INSW/INSD Yz,DX -6e: OUTS/OUTSB DX,Xb -6f: OUTS/OUTSW/OUTSD DX,Xz -# 0x70 - 0x7f -70: JO Jb -71: JNO Jb -72: JB/JNAE/JC Jb -73: JNB/JAE/JNC Jb -74: JZ/JE Jb -75: JNZ/JNE Jb -76: JBE/JNA Jb -77: JNBE/JA Jb -78: JS Jb -79: JNS Jb -7a: JP/JPE Jb -7b: JNP/JPO Jb -7c: JL/JNGE Jb -7d: JNL/JGE Jb -7e: JLE/JNG Jb -7f: JNLE/JG Jb -# 0x80 - 0x8f -80: Grp1 Eb,Ib (1A) -81: Grp1 Ev,Iz (1A) -82: Grp1 Eb,Ib (1A),(i64) -83: Grp1 Ev,Ib (1A) -84: TEST Eb,Gb -85: TEST Ev,Gv -86: XCHG Eb,Gb -87: XCHG Ev,Gv -88: MOV Eb,Gb -89: MOV Ev,Gv -8a: MOV Gb,Eb -8b: MOV Gv,Ev -8c: MOV Ev,Sw -8d: LEA Gv,M -8e: MOV Sw,Ew -8f: Grp1A (1A) | POP Ev (d64) -# 0x90 - 0x9f -90: NOP | PAUSE (F3) | XCHG r8,rAX -91: XCHG rCX/r9,rAX -92: XCHG rDX/r10,rAX -93: XCHG rBX/r11,rAX -94: XCHG rSP/r12,rAX -95: XCHG rBP/r13,rAX -96: XCHG rSI/r14,rAX -97: XCHG rDI/r15,rAX -98: CBW/CWDE/CDQE -99: CWD/CDQ/CQO -9a: CALLF Ap (i64) -9b: FWAIT/WAIT -9c: PUSHF/D/Q Fv (d64) -9d: POPF/D/Q Fv (d64) -9e: SAHF -9f: LAHF -# 0xa0 - 0xaf -a0: MOV AL,Ob -a1: MOV rAX,Ov -a2: MOV Ob,AL -a3: MOV Ov,rAX -a4: MOVS/B Yb,Xb -a5: MOVS/W/D/Q Yv,Xv -a6: CMPS/B Xb,Yb -a7: CMPS/W/D Xv,Yv -a8: TEST AL,Ib -a9: TEST rAX,Iz -aa: STOS/B Yb,AL -ab: STOS/W/D/Q Yv,rAX -ac: LODS/B AL,Xb -ad: LODS/W/D/Q rAX,Xv -ae: SCAS/B AL,Yb -# Note: The May 2011 Intel manual shows Xv for the second parameter of the -# next instruction but Yv is correct -af: SCAS/W/D/Q rAX,Yv -# 0xb0 - 0xbf -b0: MOV AL/R8L,Ib -b1: MOV CL/R9L,Ib -b2: MOV DL/R10L,Ib -b3: MOV BL/R11L,Ib -b4: MOV AH/R12L,Ib -b5: MOV CH/R13L,Ib -b6: MOV DH/R14L,Ib -b7: MOV BH/R15L,Ib -b8: MOV rAX/r8,Iv -b9: MOV rCX/r9,Iv -ba: MOV rDX/r10,Iv -bb: MOV rBX/r11,Iv -bc: MOV rSP/r12,Iv -bd: MOV rBP/r13,Iv -be: MOV rSI/r14,Iv -bf: MOV rDI/r15,Iv -# 0xc0 - 0xcf -c0: Grp2 Eb,Ib (1A) -c1: Grp2 Ev,Ib (1A) -c2: RETN Iw (f64) -c3: RETN -c4: LES Gz,Mp (i64) | VEX+2byte (Prefix) -c5: LDS Gz,Mp (i64) | VEX+1byte (Prefix) -c6: Grp11A Eb,Ib (1A) -c7: Grp11B Ev,Iz (1A) -c8: ENTER Iw,Ib -c9: LEAVE (d64) -ca: RETF Iw -cb: RETF -cc: INT3 -cd: INT Ib -ce: INTO (i64) -cf: IRET/D/Q -# 0xd0 - 0xdf -d0: Grp2 Eb,1 (1A) -d1: Grp2 Ev,1 (1A) -d2: Grp2 Eb,CL (1A) -d3: Grp2 Ev,CL (1A) -d4: AAM Ib (i64) -d5: AAD Ib (i64) -d6: -d7: XLAT/XLATB -d8: ESC -d9: ESC -da: ESC -db: ESC -dc: ESC -dd: ESC -de: ESC -df: ESC -# 0xe0 - 0xef -# Note: "forced64" is Intel CPU behavior: they ignore 0x66 prefix -# in 64-bit mode. AMD CPUs accept 0x66 prefix, it causes RIP truncation -# to 16 bits. In 32-bit mode, 0x66 is accepted by both Intel and AMD. -e0: LOOPNE/LOOPNZ Jb (f64) -e1: LOOPE/LOOPZ Jb (f64) -e2: LOOP Jb (f64) -e3: JrCXZ Jb (f64) -e4: IN AL,Ib -e5: IN eAX,Ib -e6: OUT Ib,AL -e7: OUT Ib,eAX -# With 0x66 prefix in 64-bit mode, for AMD CPUs immediate offset -# in "near" jumps and calls is 16-bit. For CALL, -# push of return address is 16-bit wide, RSP is decremented by 2 -# but is not truncated to 16 bits, unlike RIP. -e8: CALL Jz (f64) -e9: JMP-near Jz (f64) -ea: JMP-far Ap (i64) -eb: JMP-short Jb (f64) -ec: IN AL,DX -ed: IN eAX,DX -ee: OUT DX,AL -ef: OUT DX,eAX -# 0xf0 - 0xff -f0: LOCK (Prefix) -f1: -f2: REPNE (Prefix) | XACQUIRE (Prefix) -f3: REP/REPE (Prefix) | XRELEASE (Prefix) -f4: HLT -f5: CMC -f6: Grp3_1 Eb (1A) -f7: Grp3_2 Ev (1A) -f8: CLC -f9: STC -fa: CLI -fb: STI -fc: CLD -fd: STD -fe: Grp4 (1A) -ff: Grp5 (1A) -EndTable - -Table: 2-byte opcode (0x0f) -Referrer: 2-byte escape -AVXcode: 1 -# 0x0f 0x00-0x0f -00: Grp6 (1A) -01: Grp7 (1A) -02: LAR Gv,Ew -03: LSL Gv,Ew -04: -05: SYSCALL (o64) -06: CLTS -07: SYSRET (o64) -08: INVD -09: WBINVD -0a: -0b: UD2 (1B) -0c: -# AMD's prefetch group. Intel supports prefetchw(/1) only. -0d: GrpP -0e: FEMMS -# 3DNow! uses the last imm byte as opcode extension. -0f: 3DNow! Pq,Qq,Ib -# 0x0f 0x10-0x1f -# NOTE: According to Intel SDM opcode map, vmovups and vmovupd has no operands -# but it actually has operands. And also, vmovss and vmovsd only accept 128bit. -# MOVSS/MOVSD has too many forms(3) on SDM. This map just shows a typical form. -# Many AVX instructions lack v1 superscript, according to Intel AVX-Prgramming -# Reference A.1 -10: vmovups Vps,Wps | vmovupd Vpd,Wpd (66) | vmovss Vx,Hx,Wss (F3),(v1) | vmovsd Vx,Hx,Wsd (F2),(v1) -11: vmovups Wps,Vps | vmovupd Wpd,Vpd (66) | vmovss Wss,Hx,Vss (F3),(v1) | vmovsd Wsd,Hx,Vsd (F2),(v1) -12: vmovlps Vq,Hq,Mq (v1) | vmovhlps Vq,Hq,Uq (v1) | vmovlpd Vq,Hq,Mq (66),(v1) | vmovsldup Vx,Wx (F3) | vmovddup Vx,Wx (F2) -13: vmovlps Mq,Vq (v1) | vmovlpd Mq,Vq (66),(v1) -14: vunpcklps Vx,Hx,Wx | vunpcklpd Vx,Hx,Wx (66) -15: vunpckhps Vx,Hx,Wx | vunpckhpd Vx,Hx,Wx (66) -16: vmovhps Vdq,Hq,Mq (v1) | vmovlhps Vdq,Hq,Uq (v1) | vmovhpd Vdq,Hq,Mq (66),(v1) | vmovshdup Vx,Wx (F3) -17: vmovhps Mq,Vq (v1) | vmovhpd Mq,Vq (66),(v1) -18: Grp16 (1A) -19: -# Intel SDM opcode map does not list MPX instructions. For now using Gv for -# bnd registers and Ev for everything else is OK because the instruction -# decoder does not use the information except as an indication that there is -# a ModR/M byte. -1a: BNDCL Gv,Ev (F3) | BNDCU Gv,Ev (F2) | BNDMOV Gv,Ev (66) | BNDLDX Gv,Ev -1b: BNDCN Gv,Ev (F2) | BNDMOV Ev,Gv (66) | BNDMK Gv,Ev (F3) | BNDSTX Ev,Gv -1c: -1d: -1e: -1f: NOP Ev -# 0x0f 0x20-0x2f -20: MOV Rd,Cd -21: MOV Rd,Dd -22: MOV Cd,Rd -23: MOV Dd,Rd -24: -25: -26: -27: -28: vmovaps Vps,Wps | vmovapd Vpd,Wpd (66) -29: vmovaps Wps,Vps | vmovapd Wpd,Vpd (66) -2a: cvtpi2ps Vps,Qpi | cvtpi2pd Vpd,Qpi (66) | vcvtsi2ss Vss,Hss,Ey (F3),(v1) | vcvtsi2sd Vsd,Hsd,Ey (F2),(v1) -2b: vmovntps Mps,Vps | vmovntpd Mpd,Vpd (66) -2c: cvttps2pi Ppi,Wps | cvttpd2pi Ppi,Wpd (66) | vcvttss2si Gy,Wss (F3),(v1) | vcvttsd2si Gy,Wsd (F2),(v1) -2d: cvtps2pi Ppi,Wps | cvtpd2pi Qpi,Wpd (66) | vcvtss2si Gy,Wss (F3),(v1) | vcvtsd2si Gy,Wsd (F2),(v1) -2e: vucomiss Vss,Wss (v1) | vucomisd Vsd,Wsd (66),(v1) -2f: vcomiss Vss,Wss (v1) | vcomisd Vsd,Wsd (66),(v1) -# 0x0f 0x30-0x3f -30: WRMSR -31: RDTSC -32: RDMSR -33: RDPMC -34: SYSENTER -35: SYSEXIT -36: -37: GETSEC -38: escape # 3-byte escape 1 -39: -3a: escape # 3-byte escape 2 -3b: -3c: -3d: -3e: -3f: -# 0x0f 0x40-0x4f -40: CMOVO Gv,Ev -41: CMOVNO Gv,Ev | kandw/q Vk,Hk,Uk | kandb/d Vk,Hk,Uk (66) -42: CMOVB/C/NAE Gv,Ev | kandnw/q Vk,Hk,Uk | kandnb/d Vk,Hk,Uk (66) -43: CMOVAE/NB/NC Gv,Ev -44: CMOVE/Z Gv,Ev | knotw/q Vk,Uk | knotb/d Vk,Uk (66) -45: CMOVNE/NZ Gv,Ev | korw/q Vk,Hk,Uk | korb/d Vk,Hk,Uk (66) -46: CMOVBE/NA Gv,Ev | kxnorw/q Vk,Hk,Uk | kxnorb/d Vk,Hk,Uk (66) -47: CMOVA/NBE Gv,Ev | kxorw/q Vk,Hk,Uk | kxorb/d Vk,Hk,Uk (66) -48: CMOVS Gv,Ev -49: CMOVNS Gv,Ev -4a: CMOVP/PE Gv,Ev | kaddw/q Vk,Hk,Uk | kaddb/d Vk,Hk,Uk (66) -4b: CMOVNP/PO Gv,Ev | kunpckbw Vk,Hk,Uk (66) | kunpckwd/dq Vk,Hk,Uk -4c: CMOVL/NGE Gv,Ev -4d: CMOVNL/GE Gv,Ev -4e: CMOVLE/NG Gv,Ev -4f: CMOVNLE/G Gv,Ev -# 0x0f 0x50-0x5f -50: vmovmskps Gy,Ups | vmovmskpd Gy,Upd (66) -51: vsqrtps Vps,Wps | vsqrtpd Vpd,Wpd (66) | vsqrtss Vss,Hss,Wss (F3),(v1) | vsqrtsd Vsd,Hsd,Wsd (F2),(v1) -52: vrsqrtps Vps,Wps | vrsqrtss Vss,Hss,Wss (F3),(v1) -53: vrcpps Vps,Wps | vrcpss Vss,Hss,Wss (F3),(v1) -54: vandps Vps,Hps,Wps | vandpd Vpd,Hpd,Wpd (66) -55: vandnps Vps,Hps,Wps | vandnpd Vpd,Hpd,Wpd (66) -56: vorps Vps,Hps,Wps | vorpd Vpd,Hpd,Wpd (66) -57: vxorps Vps,Hps,Wps | vxorpd Vpd,Hpd,Wpd (66) -58: vaddps Vps,Hps,Wps | vaddpd Vpd,Hpd,Wpd (66) | vaddss Vss,Hss,Wss (F3),(v1) | vaddsd Vsd,Hsd,Wsd (F2),(v1) -59: vmulps Vps,Hps,Wps | vmulpd Vpd,Hpd,Wpd (66) | vmulss Vss,Hss,Wss (F3),(v1) | vmulsd Vsd,Hsd,Wsd (F2),(v1) -5a: vcvtps2pd Vpd,Wps | vcvtpd2ps Vps,Wpd (66) | vcvtss2sd Vsd,Hx,Wss (F3),(v1) | vcvtsd2ss Vss,Hx,Wsd (F2),(v1) -5b: vcvtdq2ps Vps,Wdq | vcvtqq2ps Vps,Wqq (evo) | vcvtps2dq Vdq,Wps (66) | vcvttps2dq Vdq,Wps (F3) -5c: vsubps Vps,Hps,Wps | vsubpd Vpd,Hpd,Wpd (66) | vsubss Vss,Hss,Wss (F3),(v1) | vsubsd Vsd,Hsd,Wsd (F2),(v1) -5d: vminps Vps,Hps,Wps | vminpd Vpd,Hpd,Wpd (66) | vminss Vss,Hss,Wss (F3),(v1) | vminsd Vsd,Hsd,Wsd (F2),(v1) -5e: vdivps Vps,Hps,Wps | vdivpd Vpd,Hpd,Wpd (66) | vdivss Vss,Hss,Wss (F3),(v1) | vdivsd Vsd,Hsd,Wsd (F2),(v1) -5f: vmaxps Vps,Hps,Wps | vmaxpd Vpd,Hpd,Wpd (66) | vmaxss Vss,Hss,Wss (F3),(v1) | vmaxsd Vsd,Hsd,Wsd (F2),(v1) -# 0x0f 0x60-0x6f -60: punpcklbw Pq,Qd | vpunpcklbw Vx,Hx,Wx (66),(v1) -61: punpcklwd Pq,Qd | vpunpcklwd Vx,Hx,Wx (66),(v1) -62: punpckldq Pq,Qd | vpunpckldq Vx,Hx,Wx (66),(v1) -63: packsswb Pq,Qq | vpacksswb Vx,Hx,Wx (66),(v1) -64: pcmpgtb Pq,Qq | vpcmpgtb Vx,Hx,Wx (66),(v1) -65: pcmpgtw Pq,Qq | vpcmpgtw Vx,Hx,Wx (66),(v1) -66: pcmpgtd Pq,Qq | vpcmpgtd Vx,Hx,Wx (66),(v1) -67: packuswb Pq,Qq | vpackuswb Vx,Hx,Wx (66),(v1) -68: punpckhbw Pq,Qd | vpunpckhbw Vx,Hx,Wx (66),(v1) -69: punpckhwd Pq,Qd | vpunpckhwd Vx,Hx,Wx (66),(v1) -6a: punpckhdq Pq,Qd | vpunpckhdq Vx,Hx,Wx (66),(v1) -6b: packssdw Pq,Qd | vpackssdw Vx,Hx,Wx (66),(v1) -6c: vpunpcklqdq Vx,Hx,Wx (66),(v1) -6d: vpunpckhqdq Vx,Hx,Wx (66),(v1) -6e: movd/q Pd,Ey | vmovd/q Vy,Ey (66),(v1) -6f: movq Pq,Qq | vmovdqa Vx,Wx (66) | vmovdqa32/64 Vx,Wx (66),(evo) | vmovdqu Vx,Wx (F3) | vmovdqu32/64 Vx,Wx (F3),(evo) | vmovdqu8/16 Vx,Wx (F2),(ev) -# 0x0f 0x70-0x7f -70: pshufw Pq,Qq,Ib | vpshufd Vx,Wx,Ib (66),(v1) | vpshufhw Vx,Wx,Ib (F3),(v1) | vpshuflw Vx,Wx,Ib (F2),(v1) -71: Grp12 (1A) -72: Grp13 (1A) -73: Grp14 (1A) -74: pcmpeqb Pq,Qq | vpcmpeqb Vx,Hx,Wx (66),(v1) -75: pcmpeqw Pq,Qq | vpcmpeqw Vx,Hx,Wx (66),(v1) -76: pcmpeqd Pq,Qq | vpcmpeqd Vx,Hx,Wx (66),(v1) -# Note: Remove (v), because vzeroall and vzeroupper becomes emms without VEX. -77: emms | vzeroupper | vzeroall -78: VMREAD Ey,Gy | vcvttps2udq/pd2udq Vx,Wpd (evo) | vcvttsd2usi Gv,Wx (F2),(ev) | vcvttss2usi Gv,Wx (F3),(ev) | vcvttps2uqq/pd2uqq Vx,Wx (66),(ev) -79: VMWRITE Gy,Ey | vcvtps2udq/pd2udq Vx,Wpd (evo) | vcvtsd2usi Gv,Wx (F2),(ev) | vcvtss2usi Gv,Wx (F3),(ev) | vcvtps2uqq/pd2uqq Vx,Wx (66),(ev) -7a: vcvtudq2pd/uqq2pd Vpd,Wx (F3),(ev) | vcvtudq2ps/uqq2ps Vpd,Wx (F2),(ev) | vcvttps2qq/pd2qq Vx,Wx (66),(ev) -7b: vcvtusi2sd Vpd,Hpd,Ev (F2),(ev) | vcvtusi2ss Vps,Hps,Ev (F3),(ev) | vcvtps2qq/pd2qq Vx,Wx (66),(ev) -7c: vhaddpd Vpd,Hpd,Wpd (66) | vhaddps Vps,Hps,Wps (F2) -7d: vhsubpd Vpd,Hpd,Wpd (66) | vhsubps Vps,Hps,Wps (F2) -7e: movd/q Ey,Pd | vmovd/q Ey,Vy (66),(v1) | vmovq Vq,Wq (F3),(v1) -7f: movq Qq,Pq | vmovdqa Wx,Vx (66) | vmovdqa32/64 Wx,Vx (66),(evo) | vmovdqu Wx,Vx (F3) | vmovdqu32/64 Wx,Vx (F3),(evo) | vmovdqu8/16 Wx,Vx (F2),(ev) -# 0x0f 0x80-0x8f -# Note: "forced64" is Intel CPU behavior (see comment about CALL insn). -80: JO Jz (f64) -81: JNO Jz (f64) -82: JB/JC/JNAE Jz (f64) -83: JAE/JNB/JNC Jz (f64) -84: JE/JZ Jz (f64) -85: JNE/JNZ Jz (f64) -86: JBE/JNA Jz (f64) -87: JA/JNBE Jz (f64) -88: JS Jz (f64) -89: JNS Jz (f64) -8a: JP/JPE Jz (f64) -8b: JNP/JPO Jz (f64) -8c: JL/JNGE Jz (f64) -8d: JNL/JGE Jz (f64) -8e: JLE/JNG Jz (f64) -8f: JNLE/JG Jz (f64) -# 0x0f 0x90-0x9f -90: SETO Eb | kmovw/q Vk,Wk | kmovb/d Vk,Wk (66) -91: SETNO Eb | kmovw/q Mv,Vk | kmovb/d Mv,Vk (66) -92: SETB/C/NAE Eb | kmovw Vk,Rv | kmovb Vk,Rv (66) | kmovq/d Vk,Rv (F2) -93: SETAE/NB/NC Eb | kmovw Gv,Uk | kmovb Gv,Uk (66) | kmovq/d Gv,Uk (F2) -94: SETE/Z Eb -95: SETNE/NZ Eb -96: SETBE/NA Eb -97: SETA/NBE Eb -98: SETS Eb | kortestw/q Vk,Uk | kortestb/d Vk,Uk (66) -99: SETNS Eb | ktestw/q Vk,Uk | ktestb/d Vk,Uk (66) -9a: SETP/PE Eb -9b: SETNP/PO Eb -9c: SETL/NGE Eb -9d: SETNL/GE Eb -9e: SETLE/NG Eb -9f: SETNLE/G Eb -# 0x0f 0xa0-0xaf -a0: PUSH FS (d64) -a1: POP FS (d64) -a2: CPUID -a3: BT Ev,Gv -a4: SHLD Ev,Gv,Ib -a5: SHLD Ev,Gv,CL -a6: GrpPDLK -a7: GrpRNG -a8: PUSH GS (d64) -a9: POP GS (d64) -aa: RSM -ab: BTS Ev,Gv -ac: SHRD Ev,Gv,Ib -ad: SHRD Ev,Gv,CL -ae: Grp15 (1A),(1C) -af: IMUL Gv,Ev -# 0x0f 0xb0-0xbf -b0: CMPXCHG Eb,Gb -b1: CMPXCHG Ev,Gv -b2: LSS Gv,Mp -b3: BTR Ev,Gv -b4: LFS Gv,Mp -b5: LGS Gv,Mp -b6: MOVZX Gv,Eb -b7: MOVZX Gv,Ew -b8: JMPE (!F3) | POPCNT Gv,Ev (F3) -b9: Grp10 (1A) -ba: Grp8 Ev,Ib (1A) -bb: BTC Ev,Gv -bc: BSF Gv,Ev (!F3) | TZCNT Gv,Ev (F3) -bd: BSR Gv,Ev (!F3) | LZCNT Gv,Ev (F3) -be: MOVSX Gv,Eb -bf: MOVSX Gv,Ew -# 0x0f 0xc0-0xcf -c0: XADD Eb,Gb -c1: XADD Ev,Gv -c2: vcmpps Vps,Hps,Wps,Ib | vcmppd Vpd,Hpd,Wpd,Ib (66) | vcmpss Vss,Hss,Wss,Ib (F3),(v1) | vcmpsd Vsd,Hsd,Wsd,Ib (F2),(v1) -c3: movnti My,Gy -c4: pinsrw Pq,Ry/Mw,Ib | vpinsrw Vdq,Hdq,Ry/Mw,Ib (66),(v1) -c5: pextrw Gd,Nq,Ib | vpextrw Gd,Udq,Ib (66),(v1) -c6: vshufps Vps,Hps,Wps,Ib | vshufpd Vpd,Hpd,Wpd,Ib (66) -c7: Grp9 (1A) -c8: BSWAP RAX/EAX/R8/R8D -c9: BSWAP RCX/ECX/R9/R9D -ca: BSWAP RDX/EDX/R10/R10D -cb: BSWAP RBX/EBX/R11/R11D -cc: BSWAP RSP/ESP/R12/R12D -cd: BSWAP RBP/EBP/R13/R13D -ce: BSWAP RSI/ESI/R14/R14D -cf: BSWAP RDI/EDI/R15/R15D -# 0x0f 0xd0-0xdf -d0: vaddsubpd Vpd,Hpd,Wpd (66) | vaddsubps Vps,Hps,Wps (F2) -d1: psrlw Pq,Qq | vpsrlw Vx,Hx,Wx (66),(v1) -d2: psrld Pq,Qq | vpsrld Vx,Hx,Wx (66),(v1) -d3: psrlq Pq,Qq | vpsrlq Vx,Hx,Wx (66),(v1) -d4: paddq Pq,Qq | vpaddq Vx,Hx,Wx (66),(v1) -d5: pmullw Pq,Qq | vpmullw Vx,Hx,Wx (66),(v1) -d6: vmovq Wq,Vq (66),(v1) | movq2dq Vdq,Nq (F3) | movdq2q Pq,Uq (F2) -d7: pmovmskb Gd,Nq | vpmovmskb Gd,Ux (66),(v1) -d8: psubusb Pq,Qq | vpsubusb Vx,Hx,Wx (66),(v1) -d9: psubusw Pq,Qq | vpsubusw Vx,Hx,Wx (66),(v1) -da: pminub Pq,Qq | vpminub Vx,Hx,Wx (66),(v1) -db: pand Pq,Qq | vpand Vx,Hx,Wx (66),(v1) | vpandd/q Vx,Hx,Wx (66),(evo) -dc: paddusb Pq,Qq | vpaddusb Vx,Hx,Wx (66),(v1) -dd: paddusw Pq,Qq | vpaddusw Vx,Hx,Wx (66),(v1) -de: pmaxub Pq,Qq | vpmaxub Vx,Hx,Wx (66),(v1) -df: pandn Pq,Qq | vpandn Vx,Hx,Wx (66),(v1) | vpandnd/q Vx,Hx,Wx (66),(evo) -# 0x0f 0xe0-0xef -e0: pavgb Pq,Qq | vpavgb Vx,Hx,Wx (66),(v1) -e1: psraw Pq,Qq | vpsraw Vx,Hx,Wx (66),(v1) -e2: psrad Pq,Qq | vpsrad Vx,Hx,Wx (66),(v1) -e3: pavgw Pq,Qq | vpavgw Vx,Hx,Wx (66),(v1) -e4: pmulhuw Pq,Qq | vpmulhuw Vx,Hx,Wx (66),(v1) -e5: pmulhw Pq,Qq | vpmulhw Vx,Hx,Wx (66),(v1) -e6: vcvttpd2dq Vx,Wpd (66) | vcvtdq2pd Vx,Wdq (F3) | vcvtdq2pd/qq2pd Vx,Wdq (F3),(evo) | vcvtpd2dq Vx,Wpd (F2) -e7: movntq Mq,Pq | vmovntdq Mx,Vx (66) -e8: psubsb Pq,Qq | vpsubsb Vx,Hx,Wx (66),(v1) -e9: psubsw Pq,Qq | vpsubsw Vx,Hx,Wx (66),(v1) -ea: pminsw Pq,Qq | vpminsw Vx,Hx,Wx (66),(v1) -eb: por Pq,Qq | vpor Vx,Hx,Wx (66),(v1) | vpord/q Vx,Hx,Wx (66),(evo) -ec: paddsb Pq,Qq | vpaddsb Vx,Hx,Wx (66),(v1) -ed: paddsw Pq,Qq | vpaddsw Vx,Hx,Wx (66),(v1) -ee: pmaxsw Pq,Qq | vpmaxsw Vx,Hx,Wx (66),(v1) -ef: pxor Pq,Qq | vpxor Vx,Hx,Wx (66),(v1) | vpxord/q Vx,Hx,Wx (66),(evo) -# 0x0f 0xf0-0xff -f0: vlddqu Vx,Mx (F2) -f1: psllw Pq,Qq | vpsllw Vx,Hx,Wx (66),(v1) -f2: pslld Pq,Qq | vpslld Vx,Hx,Wx (66),(v1) -f3: psllq Pq,Qq | vpsllq Vx,Hx,Wx (66),(v1) -f4: pmuludq Pq,Qq | vpmuludq Vx,Hx,Wx (66),(v1) -f5: pmaddwd Pq,Qq | vpmaddwd Vx,Hx,Wx (66),(v1) -f6: psadbw Pq,Qq | vpsadbw Vx,Hx,Wx (66),(v1) -f7: maskmovq Pq,Nq | vmaskmovdqu Vx,Ux (66),(v1) -f8: psubb Pq,Qq | vpsubb Vx,Hx,Wx (66),(v1) -f9: psubw Pq,Qq | vpsubw Vx,Hx,Wx (66),(v1) -fa: psubd Pq,Qq | vpsubd Vx,Hx,Wx (66),(v1) -fb: psubq Pq,Qq | vpsubq Vx,Hx,Wx (66),(v1) -fc: paddb Pq,Qq | vpaddb Vx,Hx,Wx (66),(v1) -fd: paddw Pq,Qq | vpaddw Vx,Hx,Wx (66),(v1) -fe: paddd Pq,Qq | vpaddd Vx,Hx,Wx (66),(v1) -ff: UD0 -EndTable - -Table: 3-byte opcode 1 (0x0f 0x38) -Referrer: 3-byte escape 1 -AVXcode: 2 -# 0x0f 0x38 0x00-0x0f -00: pshufb Pq,Qq | vpshufb Vx,Hx,Wx (66),(v1) -01: phaddw Pq,Qq | vphaddw Vx,Hx,Wx (66),(v1) -02: phaddd Pq,Qq | vphaddd Vx,Hx,Wx (66),(v1) -03: phaddsw Pq,Qq | vphaddsw Vx,Hx,Wx (66),(v1) -04: pmaddubsw Pq,Qq | vpmaddubsw Vx,Hx,Wx (66),(v1) -05: phsubw Pq,Qq | vphsubw Vx,Hx,Wx (66),(v1) -06: phsubd Pq,Qq | vphsubd Vx,Hx,Wx (66),(v1) -07: phsubsw Pq,Qq | vphsubsw Vx,Hx,Wx (66),(v1) -08: psignb Pq,Qq | vpsignb Vx,Hx,Wx (66),(v1) -09: psignw Pq,Qq | vpsignw Vx,Hx,Wx (66),(v1) -0a: psignd Pq,Qq | vpsignd Vx,Hx,Wx (66),(v1) -0b: pmulhrsw Pq,Qq | vpmulhrsw Vx,Hx,Wx (66),(v1) -0c: vpermilps Vx,Hx,Wx (66),(v) -0d: vpermilpd Vx,Hx,Wx (66),(v) -0e: vtestps Vx,Wx (66),(v) -0f: vtestpd Vx,Wx (66),(v) -# 0x0f 0x38 0x10-0x1f -10: pblendvb Vdq,Wdq (66) | vpsrlvw Vx,Hx,Wx (66),(evo) | vpmovuswb Wx,Vx (F3),(ev) -11: vpmovusdb Wx,Vd (F3),(ev) | vpsravw Vx,Hx,Wx (66),(ev) -12: vpmovusqb Wx,Vq (F3),(ev) | vpsllvw Vx,Hx,Wx (66),(ev) -13: vcvtph2ps Vx,Wx (66),(v) | vpmovusdw Wx,Vd (F3),(ev) -14: blendvps Vdq,Wdq (66) | vpmovusqw Wx,Vq (F3),(ev) | vprorvd/q Vx,Hx,Wx (66),(evo) -15: blendvpd Vdq,Wdq (66) | vpmovusqd Wx,Vq (F3),(ev) | vprolvd/q Vx,Hx,Wx (66),(evo) -16: vpermps Vqq,Hqq,Wqq (66),(v) | vpermps/d Vqq,Hqq,Wqq (66),(evo) -17: vptest Vx,Wx (66) -18: vbroadcastss Vx,Wd (66),(v) -19: vbroadcastsd Vqq,Wq (66),(v) | vbroadcastf32x2 Vqq,Wq (66),(evo) -1a: vbroadcastf128 Vqq,Mdq (66),(v) | vbroadcastf32x4/64x2 Vqq,Wq (66),(evo) -1b: vbroadcastf32x8/64x4 Vqq,Mdq (66),(ev) -1c: pabsb Pq,Qq | vpabsb Vx,Wx (66),(v1) -1d: pabsw Pq,Qq | vpabsw Vx,Wx (66),(v1) -1e: pabsd Pq,Qq | vpabsd Vx,Wx (66),(v1) -1f: vpabsq Vx,Wx (66),(ev) -# 0x0f 0x38 0x20-0x2f -20: vpmovsxbw Vx,Ux/Mq (66),(v1) | vpmovswb Wx,Vx (F3),(ev) -21: vpmovsxbd Vx,Ux/Md (66),(v1) | vpmovsdb Wx,Vd (F3),(ev) -22: vpmovsxbq Vx,Ux/Mw (66),(v1) | vpmovsqb Wx,Vq (F3),(ev) -23: vpmovsxwd Vx,Ux/Mq (66),(v1) | vpmovsdw Wx,Vd (F3),(ev) -24: vpmovsxwq Vx,Ux/Md (66),(v1) | vpmovsqw Wx,Vq (F3),(ev) -25: vpmovsxdq Vx,Ux/Mq (66),(v1) | vpmovsqd Wx,Vq (F3),(ev) -26: vptestmb/w Vk,Hx,Wx (66),(ev) | vptestnmb/w Vk,Hx,Wx (F3),(ev) -27: vptestmd/q Vk,Hx,Wx (66),(ev) | vptestnmd/q Vk,Hx,Wx (F3),(ev) -28: vpmuldq Vx,Hx,Wx (66),(v1) | vpmovm2b/w Vx,Uk (F3),(ev) -29: vpcmpeqq Vx,Hx,Wx (66),(v1) | vpmovb2m/w2m Vk,Ux (F3),(ev) -2a: vmovntdqa Vx,Mx (66),(v1) | vpbroadcastmb2q Vx,Uk (F3),(ev) -2b: vpackusdw Vx,Hx,Wx (66),(v1) -2c: vmaskmovps Vx,Hx,Mx (66),(v) | vscalefps/d Vx,Hx,Wx (66),(evo) -2d: vmaskmovpd Vx,Hx,Mx (66),(v) | vscalefss/d Vx,Hx,Wx (66),(evo) -2e: vmaskmovps Mx,Hx,Vx (66),(v) -2f: vmaskmovpd Mx,Hx,Vx (66),(v) -# 0x0f 0x38 0x30-0x3f -30: vpmovzxbw Vx,Ux/Mq (66),(v1) | vpmovwb Wx,Vx (F3),(ev) -31: vpmovzxbd Vx,Ux/Md (66),(v1) | vpmovdb Wx,Vd (F3),(ev) -32: vpmovzxbq Vx,Ux/Mw (66),(v1) | vpmovqb Wx,Vq (F3),(ev) -33: vpmovzxwd Vx,Ux/Mq (66),(v1) | vpmovdw Wx,Vd (F3),(ev) -34: vpmovzxwq Vx,Ux/Md (66),(v1) | vpmovqw Wx,Vq (F3),(ev) -35: vpmovzxdq Vx,Ux/Mq (66),(v1) | vpmovqd Wx,Vq (F3),(ev) -36: vpermd Vqq,Hqq,Wqq (66),(v) | vpermd/q Vqq,Hqq,Wqq (66),(evo) -37: vpcmpgtq Vx,Hx,Wx (66),(v1) -38: vpminsb Vx,Hx,Wx (66),(v1) | vpmovm2d/q Vx,Uk (F3),(ev) -39: vpminsd Vx,Hx,Wx (66),(v1) | vpminsd/q Vx,Hx,Wx (66),(evo) | vpmovd2m/q2m Vk,Ux (F3),(ev) -3a: vpminuw Vx,Hx,Wx (66),(v1) | vpbroadcastmw2d Vx,Uk (F3),(ev) -3b: vpminud Vx,Hx,Wx (66),(v1) | vpminud/q Vx,Hx,Wx (66),(evo) -3c: vpmaxsb Vx,Hx,Wx (66),(v1) -3d: vpmaxsd Vx,Hx,Wx (66),(v1) | vpmaxsd/q Vx,Hx,Wx (66),(evo) -3e: vpmaxuw Vx,Hx,Wx (66),(v1) -3f: vpmaxud Vx,Hx,Wx (66),(v1) | vpmaxud/q Vx,Hx,Wx (66),(evo) -# 0x0f 0x38 0x40-0x8f -40: vpmulld Vx,Hx,Wx (66),(v1) | vpmulld/q Vx,Hx,Wx (66),(evo) -41: vphminposuw Vdq,Wdq (66),(v1) -42: vgetexpps/d Vx,Wx (66),(ev) -43: vgetexpss/d Vx,Hx,Wx (66),(ev) -44: vplzcntd/q Vx,Wx (66),(ev) -45: vpsrlvd/q Vx,Hx,Wx (66),(v) -46: vpsravd Vx,Hx,Wx (66),(v) | vpsravd/q Vx,Hx,Wx (66),(evo) -47: vpsllvd/q Vx,Hx,Wx (66),(v) -# Skip 0x48-0x4b -4c: vrcp14ps/d Vpd,Wpd (66),(ev) -4d: vrcp14ss/d Vsd,Hpd,Wsd (66),(ev) -4e: vrsqrt14ps/d Vpd,Wpd (66),(ev) -4f: vrsqrt14ss/d Vsd,Hsd,Wsd (66),(ev) -# Skip 0x50-0x57 -58: vpbroadcastd Vx,Wx (66),(v) -59: vpbroadcastq Vx,Wx (66),(v) | vbroadcasti32x2 Vx,Wx (66),(evo) -5a: vbroadcasti128 Vqq,Mdq (66),(v) | vbroadcasti32x4/64x2 Vx,Wx (66),(evo) -5b: vbroadcasti32x8/64x4 Vqq,Mdq (66),(ev) -# Skip 0x5c-0x63 -64: vpblendmd/q Vx,Hx,Wx (66),(ev) -65: vblendmps/d Vx,Hx,Wx (66),(ev) -66: vpblendmb/w Vx,Hx,Wx (66),(ev) -# Skip 0x67-0x74 -75: vpermi2b/w Vx,Hx,Wx (66),(ev) -76: vpermi2d/q Vx,Hx,Wx (66),(ev) -77: vpermi2ps/d Vx,Hx,Wx (66),(ev) -78: vpbroadcastb Vx,Wx (66),(v) -79: vpbroadcastw Vx,Wx (66),(v) -7a: vpbroadcastb Vx,Rv (66),(ev) -7b: vpbroadcastw Vx,Rv (66),(ev) -7c: vpbroadcastd/q Vx,Rv (66),(ev) -7d: vpermt2b/w Vx,Hx,Wx (66),(ev) -7e: vpermt2d/q Vx,Hx,Wx (66),(ev) -7f: vpermt2ps/d Vx,Hx,Wx (66),(ev) -80: INVEPT Gy,Mdq (66) -81: INVVPID Gy,Mdq (66) -82: INVPCID Gy,Mdq (66) -83: vpmultishiftqb Vx,Hx,Wx (66),(ev) -88: vexpandps/d Vpd,Wpd (66),(ev) -89: vpexpandd/q Vx,Wx (66),(ev) -8a: vcompressps/d Wx,Vx (66),(ev) -8b: vpcompressd/q Wx,Vx (66),(ev) -8c: vpmaskmovd/q Vx,Hx,Mx (66),(v) -8d: vpermb/w Vx,Hx,Wx (66),(ev) -8e: vpmaskmovd/q Mx,Vx,Hx (66),(v) -# 0x0f 0x38 0x90-0xbf (FMA) -90: vgatherdd/q Vx,Hx,Wx (66),(v) | vpgatherdd/q Vx,Wx (66),(evo) -91: vgatherqd/q Vx,Hx,Wx (66),(v) | vpgatherqd/q Vx,Wx (66),(evo) -92: vgatherdps/d Vx,Hx,Wx (66),(v) -93: vgatherqps/d Vx,Hx,Wx (66),(v) -94: -95: -96: vfmaddsub132ps/d Vx,Hx,Wx (66),(v) -97: vfmsubadd132ps/d Vx,Hx,Wx (66),(v) -98: vfmadd132ps/d Vx,Hx,Wx (66),(v) -99: vfmadd132ss/d Vx,Hx,Wx (66),(v),(v1) -9a: vfmsub132ps/d Vx,Hx,Wx (66),(v) -9b: vfmsub132ss/d Vx,Hx,Wx (66),(v),(v1) -9c: vfnmadd132ps/d Vx,Hx,Wx (66),(v) -9d: vfnmadd132ss/d Vx,Hx,Wx (66),(v),(v1) -9e: vfnmsub132ps/d Vx,Hx,Wx (66),(v) -9f: vfnmsub132ss/d Vx,Hx,Wx (66),(v),(v1) -a0: vpscatterdd/q Wx,Vx (66),(ev) -a1: vpscatterqd/q Wx,Vx (66),(ev) -a2: vscatterdps/d Wx,Vx (66),(ev) -a3: vscatterqps/d Wx,Vx (66),(ev) -a6: vfmaddsub213ps/d Vx,Hx,Wx (66),(v) -a7: vfmsubadd213ps/d Vx,Hx,Wx (66),(v) -a8: vfmadd213ps/d Vx,Hx,Wx (66),(v) -a9: vfmadd213ss/d Vx,Hx,Wx (66),(v),(v1) -aa: vfmsub213ps/d Vx,Hx,Wx (66),(v) -ab: vfmsub213ss/d Vx,Hx,Wx (66),(v),(v1) -ac: vfnmadd213ps/d Vx,Hx,Wx (66),(v) -ad: vfnmadd213ss/d Vx,Hx,Wx (66),(v),(v1) -ae: vfnmsub213ps/d Vx,Hx,Wx (66),(v) -af: vfnmsub213ss/d Vx,Hx,Wx (66),(v),(v1) -b4: vpmadd52luq Vx,Hx,Wx (66),(ev) -b5: vpmadd52huq Vx,Hx,Wx (66),(ev) -b6: vfmaddsub231ps/d Vx,Hx,Wx (66),(v) -b7: vfmsubadd231ps/d Vx,Hx,Wx (66),(v) -b8: vfmadd231ps/d Vx,Hx,Wx (66),(v) -b9: vfmadd231ss/d Vx,Hx,Wx (66),(v),(v1) -ba: vfmsub231ps/d Vx,Hx,Wx (66),(v) -bb: vfmsub231ss/d Vx,Hx,Wx (66),(v),(v1) -bc: vfnmadd231ps/d Vx,Hx,Wx (66),(v) -bd: vfnmadd231ss/d Vx,Hx,Wx (66),(v),(v1) -be: vfnmsub231ps/d Vx,Hx,Wx (66),(v) -bf: vfnmsub231ss/d Vx,Hx,Wx (66),(v),(v1) -# 0x0f 0x38 0xc0-0xff -c4: vpconflictd/q Vx,Wx (66),(ev) -c6: Grp18 (1A) -c7: Grp19 (1A) -c8: sha1nexte Vdq,Wdq | vexp2ps/d Vx,Wx (66),(ev) -c9: sha1msg1 Vdq,Wdq -ca: sha1msg2 Vdq,Wdq | vrcp28ps/d Vx,Wx (66),(ev) -cb: sha256rnds2 Vdq,Wdq | vrcp28ss/d Vx,Hx,Wx (66),(ev) -cc: sha256msg1 Vdq,Wdq | vrsqrt28ps/d Vx,Wx (66),(ev) -cd: sha256msg2 Vdq,Wdq | vrsqrt28ss/d Vx,Hx,Wx (66),(ev) -db: VAESIMC Vdq,Wdq (66),(v1) -dc: VAESENC Vdq,Hdq,Wdq (66),(v1) -dd: VAESENCLAST Vdq,Hdq,Wdq (66),(v1) -de: VAESDEC Vdq,Hdq,Wdq (66),(v1) -df: VAESDECLAST Vdq,Hdq,Wdq (66),(v1) -f0: MOVBE Gy,My | MOVBE Gw,Mw (66) | CRC32 Gd,Eb (F2) | CRC32 Gd,Eb (66&F2) -f1: MOVBE My,Gy | MOVBE Mw,Gw (66) | CRC32 Gd,Ey (F2) | CRC32 Gd,Ew (66&F2) -f2: ANDN Gy,By,Ey (v) -f3: Grp17 (1A) -f5: BZHI Gy,Ey,By (v) | PEXT Gy,By,Ey (F3),(v) | PDEP Gy,By,Ey (F2),(v) -f6: ADCX Gy,Ey (66) | ADOX Gy,Ey (F3) | MULX By,Gy,rDX,Ey (F2),(v) -f7: BEXTR Gy,Ey,By (v) | SHLX Gy,Ey,By (66),(v) | SARX Gy,Ey,By (F3),(v) | SHRX Gy,Ey,By (F2),(v) -EndTable - -Table: 3-byte opcode 2 (0x0f 0x3a) -Referrer: 3-byte escape 2 -AVXcode: 3 -# 0x0f 0x3a 0x00-0xff -00: vpermq Vqq,Wqq,Ib (66),(v) -01: vpermpd Vqq,Wqq,Ib (66),(v) -02: vpblendd Vx,Hx,Wx,Ib (66),(v) -03: valignd/q Vx,Hx,Wx,Ib (66),(ev) -04: vpermilps Vx,Wx,Ib (66),(v) -05: vpermilpd Vx,Wx,Ib (66),(v) -06: vperm2f128 Vqq,Hqq,Wqq,Ib (66),(v) -07: -08: vroundps Vx,Wx,Ib (66) | vrndscaleps Vx,Wx,Ib (66),(evo) -09: vroundpd Vx,Wx,Ib (66) | vrndscalepd Vx,Wx,Ib (66),(evo) -0a: vroundss Vss,Wss,Ib (66),(v1) | vrndscaless Vx,Hx,Wx,Ib (66),(evo) -0b: vroundsd Vsd,Wsd,Ib (66),(v1) | vrndscalesd Vx,Hx,Wx,Ib (66),(evo) -0c: vblendps Vx,Hx,Wx,Ib (66) -0d: vblendpd Vx,Hx,Wx,Ib (66) -0e: vpblendw Vx,Hx,Wx,Ib (66),(v1) -0f: palignr Pq,Qq,Ib | vpalignr Vx,Hx,Wx,Ib (66),(v1) -14: vpextrb Rd/Mb,Vdq,Ib (66),(v1) -15: vpextrw Rd/Mw,Vdq,Ib (66),(v1) -16: vpextrd/q Ey,Vdq,Ib (66),(v1) -17: vextractps Ed,Vdq,Ib (66),(v1) -18: vinsertf128 Vqq,Hqq,Wqq,Ib (66),(v) | vinsertf32x4/64x2 Vqq,Hqq,Wqq,Ib (66),(evo) -19: vextractf128 Wdq,Vqq,Ib (66),(v) | vextractf32x4/64x2 Wdq,Vqq,Ib (66),(evo) -1a: vinsertf32x8/64x4 Vqq,Hqq,Wqq,Ib (66),(ev) -1b: vextractf32x8/64x4 Wdq,Vqq,Ib (66),(ev) -1d: vcvtps2ph Wx,Vx,Ib (66),(v) -1e: vpcmpud/q Vk,Hd,Wd,Ib (66),(ev) -1f: vpcmpd/q Vk,Hd,Wd,Ib (66),(ev) -20: vpinsrb Vdq,Hdq,Ry/Mb,Ib (66),(v1) -21: vinsertps Vdq,Hdq,Udq/Md,Ib (66),(v1) -22: vpinsrd/q Vdq,Hdq,Ey,Ib (66),(v1) -23: vshuff32x4/64x2 Vx,Hx,Wx,Ib (66),(ev) -25: vpternlogd/q Vx,Hx,Wx,Ib (66),(ev) -26: vgetmantps/d Vx,Wx,Ib (66),(ev) -27: vgetmantss/d Vx,Hx,Wx,Ib (66),(ev) -30: kshiftrb/w Vk,Uk,Ib (66),(v) -31: kshiftrd/q Vk,Uk,Ib (66),(v) -32: kshiftlb/w Vk,Uk,Ib (66),(v) -33: kshiftld/q Vk,Uk,Ib (66),(v) -38: vinserti128 Vqq,Hqq,Wqq,Ib (66),(v) | vinserti32x4/64x2 Vqq,Hqq,Wqq,Ib (66),(evo) -39: vextracti128 Wdq,Vqq,Ib (66),(v) | vextracti32x4/64x2 Wdq,Vqq,Ib (66),(evo) -3a: vinserti32x8/64x4 Vqq,Hqq,Wqq,Ib (66),(ev) -3b: vextracti32x8/64x4 Wdq,Vqq,Ib (66),(ev) -3e: vpcmpub/w Vk,Hk,Wx,Ib (66),(ev) -3f: vpcmpb/w Vk,Hk,Wx,Ib (66),(ev) -40: vdpps Vx,Hx,Wx,Ib (66) -41: vdppd Vdq,Hdq,Wdq,Ib (66),(v1) -42: vmpsadbw Vx,Hx,Wx,Ib (66),(v1) | vdbpsadbw Vx,Hx,Wx,Ib (66),(evo) -43: vshufi32x4/64x2 Vx,Hx,Wx,Ib (66),(ev) -44: vpclmulqdq Vdq,Hdq,Wdq,Ib (66),(v1) -46: vperm2i128 Vqq,Hqq,Wqq,Ib (66),(v) -4a: vblendvps Vx,Hx,Wx,Lx (66),(v) -4b: vblendvpd Vx,Hx,Wx,Lx (66),(v) -4c: vpblendvb Vx,Hx,Wx,Lx (66),(v1) -50: vrangeps/d Vx,Hx,Wx,Ib (66),(ev) -51: vrangess/d Vx,Hx,Wx,Ib (66),(ev) -54: vfixupimmps/d Vx,Hx,Wx,Ib (66),(ev) -55: vfixupimmss/d Vx,Hx,Wx,Ib (66),(ev) -56: vreduceps/d Vx,Wx,Ib (66),(ev) -57: vreducess/d Vx,Hx,Wx,Ib (66),(ev) -60: vpcmpestrm Vdq,Wdq,Ib (66),(v1) -61: vpcmpestri Vdq,Wdq,Ib (66),(v1) -62: vpcmpistrm Vdq,Wdq,Ib (66),(v1) -63: vpcmpistri Vdq,Wdq,Ib (66),(v1) -66: vfpclassps/d Vk,Wx,Ib (66),(ev) -67: vfpclassss/d Vk,Wx,Ib (66),(ev) -cc: sha1rnds4 Vdq,Wdq,Ib -df: VAESKEYGEN Vdq,Wdq,Ib (66),(v1) -f0: RORX Gy,Ey,Ib (F2),(v) -EndTable - -GrpTable: Grp1 -0: ADD -1: OR -2: ADC -3: SBB -4: AND -5: SUB -6: XOR -7: CMP -EndTable - -GrpTable: Grp1A -0: POP -EndTable - -GrpTable: Grp2 -0: ROL -1: ROR -2: RCL -3: RCR -4: SHL/SAL -5: SHR -6: -7: SAR -EndTable - -GrpTable: Grp3_1 -0: TEST Eb,Ib -1: TEST Eb,Ib -2: NOT Eb -3: NEG Eb -4: MUL AL,Eb -5: IMUL AL,Eb -6: DIV AL,Eb -7: IDIV AL,Eb -EndTable - -GrpTable: Grp3_2 -0: TEST Ev,Iz -1: -2: NOT Ev -3: NEG Ev -4: MUL rAX,Ev -5: IMUL rAX,Ev -6: DIV rAX,Ev -7: IDIV rAX,Ev -EndTable - -GrpTable: Grp4 -0: INC Eb -1: DEC Eb -EndTable - -GrpTable: Grp5 -0: INC Ev -1: DEC Ev -# Note: "forced64" is Intel CPU behavior (see comment about CALL insn). -2: CALLN Ev (f64) -3: CALLF Ep -4: JMPN Ev (f64) -5: JMPF Mp -6: PUSH Ev (d64) -7: -EndTable - -GrpTable: Grp6 -0: SLDT Rv/Mw -1: STR Rv/Mw -2: LLDT Ew -3: LTR Ew -4: VERR Ew -5: VERW Ew -EndTable - -GrpTable: Grp7 -0: SGDT Ms | VMCALL (001),(11B) | VMLAUNCH (010),(11B) | VMRESUME (011),(11B) | VMXOFF (100),(11B) -1: SIDT Ms | MONITOR (000),(11B) | MWAIT (001),(11B) | CLAC (010),(11B) | STAC (011),(11B) -2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B) -3: LIDT Ms -4: SMSW Mw/Rv -5: rdpkru (110),(11B) | wrpkru (111),(11B) -6: LMSW Ew -7: INVLPG Mb | SWAPGS (o64),(000),(11B) | RDTSCP (001),(11B) -EndTable - -GrpTable: Grp8 -4: BT -5: BTS -6: BTR -7: BTC -EndTable - -GrpTable: Grp9 -1: CMPXCHG8B/16B Mq/Mdq -3: xrstors -4: xsavec -5: xsaves -6: VMPTRLD Mq | VMCLEAR Mq (66) | VMXON Mq (F3) | RDRAND Rv (11B) -7: VMPTRST Mq | VMPTRST Mq (F3) | RDSEED Rv (11B) -EndTable - -GrpTable: Grp10 -# all are UD1 -0: UD1 -1: UD1 -2: UD1 -3: UD1 -4: UD1 -5: UD1 -6: UD1 -7: UD1 -EndTable - -# Grp11A and Grp11B are expressed as Grp11 in Intel SDM -GrpTable: Grp11A -0: MOV Eb,Ib -7: XABORT Ib (000),(11B) -EndTable - -GrpTable: Grp11B -0: MOV Eb,Iz -7: XBEGIN Jz (000),(11B) -EndTable - -GrpTable: Grp12 -2: psrlw Nq,Ib (11B) | vpsrlw Hx,Ux,Ib (66),(11B),(v1) -4: psraw Nq,Ib (11B) | vpsraw Hx,Ux,Ib (66),(11B),(v1) -6: psllw Nq,Ib (11B) | vpsllw Hx,Ux,Ib (66),(11B),(v1) -EndTable - -GrpTable: Grp13 -0: vprord/q Hx,Wx,Ib (66),(ev) -1: vprold/q Hx,Wx,Ib (66),(ev) -2: psrld Nq,Ib (11B) | vpsrld Hx,Ux,Ib (66),(11B),(v1) -4: psrad Nq,Ib (11B) | vpsrad Hx,Ux,Ib (66),(11B),(v1) | vpsrad/q Hx,Ux,Ib (66),(evo) -6: pslld Nq,Ib (11B) | vpslld Hx,Ux,Ib (66),(11B),(v1) -EndTable - -GrpTable: Grp14 -2: psrlq Nq,Ib (11B) | vpsrlq Hx,Ux,Ib (66),(11B),(v1) -3: vpsrldq Hx,Ux,Ib (66),(11B),(v1) -6: psllq Nq,Ib (11B) | vpsllq Hx,Ux,Ib (66),(11B),(v1) -7: vpslldq Hx,Ux,Ib (66),(11B),(v1) -EndTable - -GrpTable: Grp15 -0: fxsave | RDFSBASE Ry (F3),(11B) -1: fxstor | RDGSBASE Ry (F3),(11B) -2: vldmxcsr Md (v1) | WRFSBASE Ry (F3),(11B) -3: vstmxcsr Md (v1) | WRGSBASE Ry (F3),(11B) -4: XSAVE | ptwrite Ey (F3),(11B) -5: XRSTOR | lfence (11B) -6: XSAVEOPT | clwb (66) | mfence (11B) -7: clflush | clflushopt (66) | sfence (11B) -EndTable - -GrpTable: Grp16 -0: prefetch NTA -1: prefetch T0 -2: prefetch T1 -3: prefetch T2 -EndTable - -GrpTable: Grp17 -1: BLSR By,Ey (v) -2: BLSMSK By,Ey (v) -3: BLSI By,Ey (v) -EndTable - -GrpTable: Grp18 -1: vgatherpf0dps/d Wx (66),(ev) -2: vgatherpf1dps/d Wx (66),(ev) -5: vscatterpf0dps/d Wx (66),(ev) -6: vscatterpf1dps/d Wx (66),(ev) -EndTable - -GrpTable: Grp19 -1: vgatherpf0qps/d Wx (66),(ev) -2: vgatherpf1qps/d Wx (66),(ev) -5: vscatterpf0qps/d Wx (66),(ev) -6: vscatterpf1qps/d Wx (66),(ev) -EndTable - -# AMD's Prefetch Group -GrpTable: GrpP -0: PREFETCH -1: PREFETCHW -EndTable - -GrpTable: GrpPDLK -0: MONTMUL -1: XSHA1 -2: XSHA2 -EndTable - -GrpTable: GrpRNG -0: xstore-rng -1: xcrypt-ecb -2: xcrypt-cbc -4: xcrypt-cfb -5: xcrypt-ofb -EndTable From 87a682a7c4e719d238d1839098375470b55e2097 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Sat, 31 Aug 2019 17:14:19 -0300 Subject: [PATCH 45/47] perf build: Ignore intentional differences for the x86 insn decoder Since we need to build this in !x86, we need to explicitely use the x86 files, not things like asm/insn.h, so we intentionally differ from the master copy in the kernel sources, add -I diff directives to ignore just these differences when checking for drift. Acked-by: Josh Poimboeuf Acked-by: Masami Hiramatsu Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/n/tip-9qziqjjt120mmz6kyepka9p7@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/check-headers.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh index cbcc3590098c..e2e0f06c97d0 100755 --- a/tools/perf/check-headers.sh +++ b/tools/perf/check-headers.sh @@ -26,12 +26,8 @@ include/uapi/linux/hw_breakpoint.h arch/x86/include/asm/disabled-features.h arch/x86/include/asm/required-features.h arch/x86/include/asm/cpufeatures.h -arch/x86/include/asm/inat.h arch/x86/include/asm/inat_types.h -arch/x86/include/asm/insn.h arch/x86/include/uapi/asm/prctl.h -arch/x86/lib/inat.c -arch/x86/lib/insn.c arch/x86/lib/x86-opcode-map.txt arch/x86/tools/gen-insn-attr-x86.awk arch/arm/include/uapi/asm/perf_regs.h @@ -116,6 +112,10 @@ check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"' check include/linux/ctype.h '-I "isdigit("' check lib/ctype.c '-I "^EXPORT_SYMBOL" -I "^#include " -B' +check arch/x86/include/asm/inat.h '-I "^#include [\"<]\(asm/\)*inat_types.h[\">]"' +check arch/x86/include/asm/insn.h '-I "^#include [\"<]\(asm/\)*inat.h[\">]"' +check arch/x86/lib/inat.c '-I "^#include [\"<]\(../include/\)*asm/insn.h[\">]"' +check arch/x86/lib/insn.c '-I "^#include [\"<]\(../include/\)*asm/in\(at\|sn\).h[\">]"' # diff non-symmetric files check_2 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl From 2ffd84ae973b5ad16be96840574bb1142fda268a Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Sat, 31 Aug 2019 17:29:47 -0300 Subject: [PATCH 46/47] objtool: Update sync-check.sh from perf's check-headers.sh To allow using the -I trick that will be needed for checking the x86 insn decoder files. Without the specific -I lines we still get the same warnings as before: $ make -C tools/objtool/ clean ; make -C tools/objtool/ make: Entering directory '/home/acme/git/perf/tools/objtool' CLEAN objtool find -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete rm -f arch/x86/inat-tables.c fixdep LD objtool-in.o make[1]: Leaving directory '/home/acme/git/perf/tools/objtool' Warning: Kernel ABI header at 'tools/arch/x86/include/asm/inat.h' differs from latest version at 'arch/x86/include/asm/inat.h' diff -u tools/arch/x86/include/asm/inat.h arch/x86/include/asm/inat.h Warning: Kernel ABI header at 'tools/arch/x86/include/asm/insn.h' differs from latest version at 'arch/x86/include/asm/insn.h' diff -u tools/arch/x86/include/asm/insn.h arch/x86/include/asm/insn.h Warning: Kernel ABI header at 'tools/arch/x86/lib/inat.c' differs from latest version at 'arch/x86/lib/inat.c' diff -u tools/arch/x86/lib/inat.c arch/x86/lib/inat.c Warning: Kernel ABI header at 'tools/arch/x86/lib/insn.c' differs from latest version at 'arch/x86/lib/insn.c' diff -u tools/arch/x86/lib/insn.c arch/x86/lib/insn.c /home/acme/git/perf/tools/objtool LINK objtool make: Leaving directory '/home/acme/git/perf/tools/objtool' $ The next patch will add the -I lines for those files. Acked-by: Josh Poimboeuf Link: http://lore.kernel.org/lkml/20190830193109.p7jagidsrahoa4pn@treble Acked-by: Masami Hiramatsu Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/n/tip-vu3p38mnxlwd80rlsnjkqcf2@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/objtool/sync-check.sh | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tools/objtool/sync-check.sh b/tools/objtool/sync-check.sh index 66f1575b80f3..6fa87de1c765 100755 --- a/tools/objtool/sync-check.sh +++ b/tools/objtool/sync-check.sh @@ -12,18 +12,39 @@ arch/x86/lib/x86-opcode-map.txt arch/x86/tools/gen-insn-attr-x86.awk ' -check() -{ - local file=$1 +check_2 () { + file1=$1 + file2=$2 - diff ../$file ../../$file > /dev/null || - echo "Warning: synced file at 'tools/objtool/$file' differs from latest kernel version at '$file'" + shift + shift + + cmd="diff $* $file1 $file2 > /dev/null" + + test -f $file2 && { + eval $cmd || { + echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2 + echo diff -u $file1 $file2 + } + } +} + +check () { + file=$1 + + shift + + check_2 tools/$file $file $* } if [ ! -d ../../kernel ] || [ ! -d ../../tools ] || [ ! -d ../objtool ]; then exit 0 fi +cd ../.. + for i in $FILES; do check $i done + +cd - From ae31a514a134d9e4ca1d7b0f0a19b5934747d79f Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Sat, 31 Aug 2019 17:35:53 -0300 Subject: [PATCH 47/47] objtool: Ignore intentional differences for the x86 insn decoder Since we need to build this in !x86, we need to explicitely use the x86 files, not things like asm/insn.h, so we intentionally differ from the master copy in the kernel sources, add -I diff directives to ignore just these differences when checking for drift. Acked-by: Josh Poimboeuf Link: http://lore.kernel.org/lkml/20190830193109.p7jagidsrahoa4pn@treble Acked-by: Masami Hiramatsu Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/n/tip-j965m9b7xtdc83em3twfkh9o@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/objtool/sync-check.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/objtool/sync-check.sh b/tools/objtool/sync-check.sh index 6fa87de1c765..0a832e265a50 100755 --- a/tools/objtool/sync-check.sh +++ b/tools/objtool/sync-check.sh @@ -2,12 +2,8 @@ # SPDX-License-Identifier: GPL-2.0 FILES=' -arch/x86/include/asm/inat.h arch/x86/include/asm/inat_types.h -arch/x86/include/asm/insn.h arch/x86/include/asm/orc_types.h -arch/x86/lib/inat.c -arch/x86/lib/insn.c arch/x86/lib/x86-opcode-map.txt arch/x86/tools/gen-insn-attr-x86.awk ' @@ -47,4 +43,9 @@ for i in $FILES; do check $i done +check arch/x86/include/asm/inat.h '-I "^#include [\"<]\(asm/\)*inat_types.h[\">]"' +check arch/x86/include/asm/insn.h '-I "^#include [\"<]\(asm/\)*inat.h[\">]"' +check arch/x86/lib/inat.c '-I "^#include [\"<]\(../include/\)*asm/insn.h[\">]"' +check arch/x86/lib/insn.c '-I "^#include [\"<]\(../include/\)*asm/in\(at\|sn\).h[\">]"' + cd -