aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2017-02-16 14:53:13 -0500
committerIngo Molnar <mingo@kernel.org>2017-02-16 14:53:13 -0500
commit0c8967c9df230d2c4dde6649f410b62e01806c22 (patch)
tree7a0909ee1d9551640aa0427cdad610d8d1dacd4f /tools/perf/util
parent277d6f1dcae09aed63cd4c7900a280b0e18cf2ca (diff)
parent34a0548f01626b01c9e98d9627812c3c9f6b6f7d (diff)
Merge tag 'perf-core-for-mingo-4.11-20170215' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core clang fixes from Arnaldo Carvalho de Melo: Changes to make tools/{perf,lib/{bpf,traceevent,api}} build with CC=clang, to, for instance, take advantage of warnings (Arnaldo Carvalho de Melo): - Conditionally request some warning options not available on clang - Set the maximum optimization level to -O3 when using CC=clang, leave the previous setting of -O6 otherwise. - Make it an error to pass a signed value to OPTION_UINTEGER, so that we can remove abs(unsigned int) calls in 'perf bench futex'. - Make sure dprintf() is not defined before using that name in 'perf bench numa' - Avoid using field after variable sized type, its a GNU extension, use equivalent code. - Fix some bugs where some variables could be used unitialized, something not caught by gcc. - Fix some spots where we were testing struct->array[] members against NULL, it will always evaluate to 'true'. - Add missing parse_events_error() prototype in the bison file. There are still one problem when trying to build the python support, but this are the 'size' outputs for 'make -C tools/perf NO_LIBPYTHON' for gcc and clang builds: DW_AT_producer: clang version 4.0.0 (http://llvm.org/git/clang.git f5be8ba13adc4ba1011a7ccd60c844bd60427c1c) (ht $ size ~/bin/perf text data bss dec hex filename 3447514 831320 23901696 28180530 1ae0032 /home/acme/bin/perf DW_AT_producer: GNU C99 6.3.1 20161221 (Red Hat 6.3.1-1) -mtune=generic -march=x86-64 -ggdb3 -O6 -std=gnu99 +-fno-omit-frame-pointer -funwind-tables -fstack-protector-all $ size ~/bin/perf text data bss dec hex filename 3671662 836480 23902752 28410894 1b1840e /home/acme/bin/perf Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/evsel.c62
-rw-r--r--tools/perf/util/intel-pt-decoder/Build6
-rw-r--r--tools/perf/util/machine.c4
-rw-r--r--tools/perf/util/parse-events.c15
-rw-r--r--tools/perf/util/parse-events.y2
-rw-r--r--tools/perf/util/pmu.c4
-rw-r--r--tools/perf/util/probe-event.c2
-rw-r--r--tools/perf/util/session.c2
8 files changed, 47 insertions, 50 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index cd2fb42e5dd4..ac59710b79e0 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1448,8 +1448,8 @@ static bool ignore_missing_thread(struct perf_evsel *evsel,
1448 return true; 1448 return true;
1449} 1449}
1450 1450
1451static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, 1451int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
1452 struct thread_map *threads) 1452 struct thread_map *threads)
1453{ 1453{
1454 int cpu, thread, nthreads; 1454 int cpu, thread, nthreads;
1455 unsigned long flags = PERF_FLAG_FD_CLOEXEC; 1455 unsigned long flags = PERF_FLAG_FD_CLOEXEC;
@@ -1459,6 +1459,30 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
1459 if (perf_missing_features.write_backward && evsel->attr.write_backward) 1459 if (perf_missing_features.write_backward && evsel->attr.write_backward)
1460 return -EINVAL; 1460 return -EINVAL;
1461 1461
1462 if (cpus == NULL) {
1463 static struct cpu_map *empty_cpu_map;
1464
1465 if (empty_cpu_map == NULL) {
1466 empty_cpu_map = cpu_map__dummy_new();
1467 if (empty_cpu_map == NULL)
1468 return -ENOMEM;
1469 }
1470
1471 cpus = empty_cpu_map;
1472 }
1473
1474 if (threads == NULL) {
1475 static struct thread_map *empty_thread_map;
1476
1477 if (empty_thread_map == NULL) {
1478 empty_thread_map = thread_map__new_by_tid(-1);
1479 if (empty_thread_map == NULL)
1480 return -ENOMEM;
1481 }
1482
1483 threads = empty_thread_map;
1484 }
1485
1462 if (evsel->system_wide) 1486 if (evsel->system_wide)
1463 nthreads = 1; 1487 nthreads = 1;
1464 else 1488 else
@@ -1655,46 +1679,16 @@ void perf_evsel__close(struct perf_evsel *evsel, int ncpus, int nthreads)
1655 perf_evsel__free_fd(evsel); 1679 perf_evsel__free_fd(evsel);
1656} 1680}
1657 1681
1658static struct {
1659 struct cpu_map map;
1660 int cpus[1];
1661} empty_cpu_map = {
1662 .map.nr = 1,
1663 .cpus = { -1, },
1664};
1665
1666static struct {
1667 struct thread_map map;
1668 int threads[1];
1669} empty_thread_map = {
1670 .map.nr = 1,
1671 .threads = { -1, },
1672};
1673
1674int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
1675 struct thread_map *threads)
1676{
1677 if (cpus == NULL) {
1678 /* Work around old compiler warnings about strict aliasing */
1679 cpus = &empty_cpu_map.map;
1680 }
1681
1682 if (threads == NULL)
1683 threads = &empty_thread_map.map;
1684
1685 return __perf_evsel__open(evsel, cpus, threads);
1686}
1687
1688int perf_evsel__open_per_cpu(struct perf_evsel *evsel, 1682int perf_evsel__open_per_cpu(struct perf_evsel *evsel,
1689 struct cpu_map *cpus) 1683 struct cpu_map *cpus)
1690{ 1684{
1691 return __perf_evsel__open(evsel, cpus, &empty_thread_map.map); 1685 return perf_evsel__open(evsel, cpus, NULL);
1692} 1686}
1693 1687
1694int perf_evsel__open_per_thread(struct perf_evsel *evsel, 1688int perf_evsel__open_per_thread(struct perf_evsel *evsel,
1695 struct thread_map *threads) 1689 struct thread_map *threads)
1696{ 1690{
1697 return __perf_evsel__open(evsel, &empty_cpu_map.map, threads); 1691 return perf_evsel__open(evsel, NULL, threads);
1698} 1692}
1699 1693
1700static int perf_evsel__parse_id_sample(const struct perf_evsel *evsel, 1694static int perf_evsel__parse_id_sample(const struct perf_evsel *evsel,
diff --git a/tools/perf/util/intel-pt-decoder/Build b/tools/perf/util/intel-pt-decoder/Build
index 9b742ea8bfe8..7aca5d6d7e1f 100644
--- a/tools/perf/util/intel-pt-decoder/Build
+++ b/tools/perf/util/intel-pt-decoder/Build
@@ -23,4 +23,8 @@ $(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/in
23 $(call rule_mkdir) 23 $(call rule_mkdir)
24 $(call if_changed_dep,cc_o_c) 24 $(call if_changed_dep,cc_o_c)
25 25
26CFLAGS_intel-pt-insn-decoder.o += -I$(OUTPUT)util/intel-pt-decoder -Wno-override-init 26CFLAGS_intel-pt-insn-decoder.o += -I$(OUTPUT)util/intel-pt-decoder
27
28ifneq ($(CC), clang)
29 CFLAGS_intel-pt-insn-decoder.o += -Wno-override-init
30endif
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index a1043cf9b89c..71c9720d4973 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -782,7 +782,7 @@ static u64 machine__get_running_kernel_start(struct machine *machine,
782 782
783int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) 783int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
784{ 784{
785 enum map_type type; 785 int type;
786 u64 start = machine__get_running_kernel_start(machine, NULL); 786 u64 start = machine__get_running_kernel_start(machine, NULL);
787 787
788 /* In case of renewal the kernel map, destroy previous one */ 788 /* In case of renewal the kernel map, destroy previous one */
@@ -813,7 +813,7 @@ int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
813 813
814void machine__destroy_kernel_maps(struct machine *machine) 814void machine__destroy_kernel_maps(struct machine *machine)
815{ 815{
816 enum map_type type; 816 int type;
817 817
818 for (type = 0; type < MAP__NR_TYPES; ++type) { 818 for (type = 0; type < MAP__NR_TYPES; ++type) {
819 struct kmap *kmap; 819 struct kmap *kmap;
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 07be0762e53e..281e44af31e2 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2020,17 +2020,14 @@ static bool is_event_supported(u8 type, unsigned config)
2020 .config = config, 2020 .config = config,
2021 .disabled = 1, 2021 .disabled = 1,
2022 }; 2022 };
2023 struct { 2023 struct thread_map *tmap = thread_map__new_by_tid(0);
2024 struct thread_map map; 2024
2025 int threads[1]; 2025 if (tmap == NULL)
2026 } tmap = { 2026 return false;
2027 .map.nr = 1,
2028 .threads = { 0 },
2029 };
2030 2027
2031 evsel = perf_evsel__new(&attr); 2028 evsel = perf_evsel__new(&attr);
2032 if (evsel) { 2029 if (evsel) {
2033 open_return = perf_evsel__open(evsel, NULL, &tmap.map); 2030 open_return = perf_evsel__open(evsel, NULL, tmap);
2034 ret = open_return >= 0; 2031 ret = open_return >= 0;
2035 2032
2036 if (open_return == -EACCES) { 2033 if (open_return == -EACCES) {
@@ -2042,7 +2039,7 @@ static bool is_event_supported(u8 type, unsigned config)
2042 * 2039 *
2043 */ 2040 */
2044 evsel->attr.exclude_kernel = 1; 2041 evsel->attr.exclude_kernel = 1;
2045 ret = perf_evsel__open(evsel, NULL, &tmap.map) >= 0; 2042 ret = perf_evsel__open(evsel, NULL, tmap) >= 0;
2046 } 2043 }
2047 perf_evsel__delete(evsel); 2044 perf_evsel__delete(evsel);
2048 } 2045 }
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 3a5196380609..a14b47ab3879 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -17,6 +17,8 @@
17#include "parse-events.h" 17#include "parse-events.h"
18#include "parse-events-bison.h" 18#include "parse-events-bison.h"
19 19
20void parse_events_error(YYLTYPE *loc, void *data, void *scanner, char const *msg);
21
20#define ABORT_ON(val) \ 22#define ABORT_ON(val) \
21do { \ 23do { \
22 if (val) \ 24 if (val) \
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 82a654dec666..49bfee0e3d9e 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -945,12 +945,12 @@ static int check_info_data(struct perf_pmu_alias *alias,
945 * define unit, scale and snapshot, fail 945 * define unit, scale and snapshot, fail
946 * if there's more than one. 946 * if there's more than one.
947 */ 947 */
948 if ((info->unit && alias->unit) || 948 if ((info->unit && alias->unit[0]) ||
949 (info->scale && alias->scale) || 949 (info->scale && alias->scale) ||
950 (info->snapshot && alias->snapshot)) 950 (info->snapshot && alias->snapshot))
951 return -EINVAL; 951 return -EINVAL;
952 952
953 if (alias->unit) 953 if (alias->unit[0])
954 info->unit = alias->unit; 954 info->unit = alias->unit;
955 955
956 if (alias->scale) 956 if (alias->scale)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 2c1bca240597..35f5b7b7715c 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2061,7 +2061,7 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp,
2061 bool is_kprobe) 2061 bool is_kprobe)
2062{ 2062{
2063 struct symbol *sym = NULL; 2063 struct symbol *sym = NULL;
2064 struct map *map; 2064 struct map *map = NULL;
2065 u64 addr = tp->address; 2065 u64 addr = tp->address;
2066 int ret = -ENOENT; 2066 int ret = -ENOENT;
2067 2067
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 349c68144e55..4cdbc8f5f14d 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1901,7 +1901,7 @@ int maps__set_kallsyms_ref_reloc_sym(struct map **maps,
1901 const char *symbol_name, u64 addr) 1901 const char *symbol_name, u64 addr)
1902{ 1902{
1903 char *bracket; 1903 char *bracket;
1904 enum map_type i; 1904 int i;
1905 struct ref_reloc_sym *ref; 1905 struct ref_reloc_sym *ref;
1906 1906
1907 ref = zalloc(sizeof(struct ref_reloc_sym)); 1907 ref = zalloc(sizeof(struct ref_reloc_sym));