diff options
author | Ingo Molnar <mingo@kernel.org> | 2017-02-16 14:53:13 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-02-16 14:53:13 -0500 |
commit | 0c8967c9df230d2c4dde6649f410b62e01806c22 (patch) | |
tree | 7a0909ee1d9551640aa0427cdad610d8d1dacd4f | |
parent | 277d6f1dcae09aed63cd4c7900a280b0e18cf2ca (diff) | |
parent | 34a0548f01626b01c9e98d9627812c3c9f6b6f7d (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>
-rw-r--r-- | tools/lib/api/Makefile | 8 | ||||
-rw-r--r-- | tools/lib/subcmd/Makefile | 8 | ||||
-rw-r--r-- | tools/lib/subcmd/parse-options.c | 4 | ||||
-rw-r--r-- | tools/perf/Makefile.config | 4 | ||||
-rw-r--r-- | tools/perf/bench/futex-hash.c | 4 | ||||
-rw-r--r-- | tools/perf/bench/futex-lock-pi.c | 3 | ||||
-rw-r--r-- | tools/perf/bench/futex-requeue.c | 2 | ||||
-rw-r--r-- | tools/perf/bench/futex-wake-parallel.c | 4 | ||||
-rw-r--r-- | tools/perf/bench/futex-wake.c | 3 | ||||
-rw-r--r-- | tools/perf/bench/futex.h | 4 | ||||
-rw-r--r-- | tools/perf/bench/numa.c | 1 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 17 | ||||
-rw-r--r-- | tools/perf/tests/parse-no-sample-id-all.c | 19 | ||||
-rw-r--r-- | tools/perf/util/evsel.c | 62 | ||||
-rw-r--r-- | tools/perf/util/intel-pt-decoder/Build | 6 | ||||
-rw-r--r-- | tools/perf/util/machine.c | 4 | ||||
-rw-r--r-- | tools/perf/util/parse-events.c | 15 | ||||
-rw-r--r-- | tools/perf/util/parse-events.y | 2 | ||||
-rw-r--r-- | tools/perf/util/pmu.c | 4 | ||||
-rw-r--r-- | tools/perf/util/probe-event.c | 2 | ||||
-rw-r--r-- | tools/perf/util/session.c | 2 | ||||
-rw-r--r-- | tools/scripts/Makefile.include | 5 |
22 files changed, 91 insertions, 92 deletions
diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile index adba83b325d5..eb6e0b36bfc1 100644 --- a/tools/lib/api/Makefile +++ b/tools/lib/api/Makefile | |||
@@ -17,7 +17,13 @@ MAKEFLAGS += --no-print-directory | |||
17 | LIBFILE = $(OUTPUT)libapi.a | 17 | LIBFILE = $(OUTPUT)libapi.a |
18 | 18 | ||
19 | CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) | 19 | CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) |
20 | CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC | 20 | CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC |
21 | |||
22 | ifeq ($(CC), clang) | ||
23 | CFLAGS += -O3 | ||
24 | else | ||
25 | CFLAGS += -O6 | ||
26 | endif | ||
21 | 27 | ||
22 | # Treat warnings as errors unless directed not to | 28 | # Treat warnings as errors unless directed not to |
23 | ifneq ($(WERROR),0) | 29 | ifneq ($(WERROR),0) |
diff --git a/tools/lib/subcmd/Makefile b/tools/lib/subcmd/Makefile index 3f8cc44a0dbd..3d1c3b5b5150 100644 --- a/tools/lib/subcmd/Makefile +++ b/tools/lib/subcmd/Makefile | |||
@@ -19,7 +19,13 @@ MAKEFLAGS += --no-print-directory | |||
19 | LIBFILE = $(OUTPUT)libsubcmd.a | 19 | LIBFILE = $(OUTPUT)libsubcmd.a |
20 | 20 | ||
21 | CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) | 21 | CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) |
22 | CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC | 22 | CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC |
23 | |||
24 | ifeq ($(CC), clang) | ||
25 | CFLAGS += -O3 | ||
26 | else | ||
27 | CFLAGS += -O6 | ||
28 | endif | ||
23 | 29 | ||
24 | # Treat warnings as errors unless directed not to | 30 | # Treat warnings as errors unless directed not to |
25 | ifneq ($(WERROR),0) | 31 | ifneq ($(WERROR),0) |
diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c index 8aad81151d50..6bc24025d054 100644 --- a/tools/lib/subcmd/parse-options.c +++ b/tools/lib/subcmd/parse-options.c | |||
@@ -270,6 +270,8 @@ static int get_value(struct parse_opt_ctx_t *p, | |||
270 | } | 270 | } |
271 | if (get_arg(p, opt, flags, &arg)) | 271 | if (get_arg(p, opt, flags, &arg)) |
272 | return -1; | 272 | return -1; |
273 | if (arg[0] == '-') | ||
274 | return opterror(opt, "expects an unsigned numerical value", flags); | ||
273 | *(unsigned int *)opt->value = strtol(arg, (char **)&s, 10); | 275 | *(unsigned int *)opt->value = strtol(arg, (char **)&s, 10); |
274 | if (*s) | 276 | if (*s) |
275 | return opterror(opt, "expects a numerical value", flags); | 277 | return opterror(opt, "expects a numerical value", flags); |
@@ -302,6 +304,8 @@ static int get_value(struct parse_opt_ctx_t *p, | |||
302 | } | 304 | } |
303 | if (get_arg(p, opt, flags, &arg)) | 305 | if (get_arg(p, opt, flags, &arg)) |
304 | return -1; | 306 | return -1; |
307 | if (arg[0] == '-') | ||
308 | return opterror(opt, "expects an unsigned numerical value", flags); | ||
305 | *(u64 *)opt->value = strtoull(arg, (char **)&s, 10); | 309 | *(u64 *)opt->value = strtoull(arg, (char **)&s, 10); |
306 | if (*s) | 310 | if (*s) |
307 | return opterror(opt, "expects a numerical value", flags); | 311 | return opterror(opt, "expects a numerical value", flags); |
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 03cf947755b9..2b941efadb04 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config | |||
@@ -144,8 +144,12 @@ ifndef DEBUG | |||
144 | endif | 144 | endif |
145 | 145 | ||
146 | ifeq ($(DEBUG),0) | 146 | ifeq ($(DEBUG),0) |
147 | ifeq ($(CC), clang) | ||
148 | CFLAGS += -O3 | ||
149 | else | ||
147 | CFLAGS += -O6 | 150 | CFLAGS += -O6 |
148 | endif | 151 | endif |
152 | endif | ||
149 | 153 | ||
150 | ifdef PARSER_DEBUG | 154 | ifdef PARSER_DEBUG |
151 | PARSER_DEBUG_BISON := -t | 155 | PARSER_DEBUG_BISON := -t |
diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c index bfbb6b5f609c..da04b8c5568a 100644 --- a/tools/perf/bench/futex-hash.c +++ b/tools/perf/bench/futex-hash.c | |||
@@ -130,8 +130,6 @@ int bench_futex_hash(int argc, const char **argv, | |||
130 | } | 130 | } |
131 | 131 | ||
132 | ncpus = sysconf(_SC_NPROCESSORS_ONLN); | 132 | ncpus = sysconf(_SC_NPROCESSORS_ONLN); |
133 | nsecs = futexbench_sanitize_numeric(nsecs); | ||
134 | nfutexes = futexbench_sanitize_numeric(nfutexes); | ||
135 | 133 | ||
136 | sigfillset(&act.sa_mask); | 134 | sigfillset(&act.sa_mask); |
137 | act.sa_sigaction = toggle_done; | 135 | act.sa_sigaction = toggle_done; |
@@ -139,8 +137,6 @@ int bench_futex_hash(int argc, const char **argv, | |||
139 | 137 | ||
140 | if (!nthreads) /* default to the number of CPUs */ | 138 | if (!nthreads) /* default to the number of CPUs */ |
141 | nthreads = ncpus; | 139 | nthreads = ncpus; |
142 | else | ||
143 | nthreads = futexbench_sanitize_numeric(nthreads); | ||
144 | 140 | ||
145 | worker = calloc(nthreads, sizeof(*worker)); | 141 | worker = calloc(nthreads, sizeof(*worker)); |
146 | if (!worker) | 142 | if (!worker) |
diff --git a/tools/perf/bench/futex-lock-pi.c b/tools/perf/bench/futex-lock-pi.c index 6d9d6c40a916..91877777ec6e 100644 --- a/tools/perf/bench/futex-lock-pi.c +++ b/tools/perf/bench/futex-lock-pi.c | |||
@@ -152,7 +152,6 @@ int bench_futex_lock_pi(int argc, const char **argv, | |||
152 | goto err; | 152 | goto err; |
153 | 153 | ||
154 | ncpus = sysconf(_SC_NPROCESSORS_ONLN); | 154 | ncpus = sysconf(_SC_NPROCESSORS_ONLN); |
155 | nsecs = futexbench_sanitize_numeric(nsecs); | ||
156 | 155 | ||
157 | sigfillset(&act.sa_mask); | 156 | sigfillset(&act.sa_mask); |
158 | act.sa_sigaction = toggle_done; | 157 | act.sa_sigaction = toggle_done; |
@@ -160,8 +159,6 @@ int bench_futex_lock_pi(int argc, const char **argv, | |||
160 | 159 | ||
161 | if (!nthreads) | 160 | if (!nthreads) |
162 | nthreads = ncpus; | 161 | nthreads = ncpus; |
163 | else | ||
164 | nthreads = futexbench_sanitize_numeric(nthreads); | ||
165 | 162 | ||
166 | worker = calloc(nthreads, sizeof(*worker)); | 163 | worker = calloc(nthreads, sizeof(*worker)); |
167 | if (!worker) | 164 | if (!worker) |
diff --git a/tools/perf/bench/futex-requeue.c b/tools/perf/bench/futex-requeue.c index fd4ee95b689a..2b9705a8734c 100644 --- a/tools/perf/bench/futex-requeue.c +++ b/tools/perf/bench/futex-requeue.c | |||
@@ -128,8 +128,6 @@ int bench_futex_requeue(int argc, const char **argv, | |||
128 | 128 | ||
129 | if (!nthreads) | 129 | if (!nthreads) |
130 | nthreads = ncpus; | 130 | nthreads = ncpus; |
131 | else | ||
132 | nthreads = futexbench_sanitize_numeric(nthreads); | ||
133 | 131 | ||
134 | worker = calloc(nthreads, sizeof(*worker)); | 132 | worker = calloc(nthreads, sizeof(*worker)); |
135 | if (!worker) | 133 | if (!worker) |
diff --git a/tools/perf/bench/futex-wake-parallel.c b/tools/perf/bench/futex-wake-parallel.c index beaa6c142477..2c8fa67ad537 100644 --- a/tools/perf/bench/futex-wake-parallel.c +++ b/tools/perf/bench/futex-wake-parallel.c | |||
@@ -217,12 +217,8 @@ int bench_futex_wake_parallel(int argc, const char **argv, | |||
217 | sigaction(SIGINT, &act, NULL); | 217 | sigaction(SIGINT, &act, NULL); |
218 | 218 | ||
219 | ncpus = sysconf(_SC_NPROCESSORS_ONLN); | 219 | ncpus = sysconf(_SC_NPROCESSORS_ONLN); |
220 | nwaking_threads = futexbench_sanitize_numeric(nwaking_threads); | ||
221 | |||
222 | if (!nblocked_threads) | 220 | if (!nblocked_threads) |
223 | nblocked_threads = ncpus; | 221 | nblocked_threads = ncpus; |
224 | else | ||
225 | nblocked_threads = futexbench_sanitize_numeric(nblocked_threads); | ||
226 | 222 | ||
227 | /* some sanity checks */ | 223 | /* some sanity checks */ |
228 | if (nwaking_threads > nblocked_threads || !nwaking_threads) | 224 | if (nwaking_threads > nblocked_threads || !nwaking_threads) |
diff --git a/tools/perf/bench/futex-wake.c b/tools/perf/bench/futex-wake.c index 46efcb98b5a4..e246b1b8388a 100644 --- a/tools/perf/bench/futex-wake.c +++ b/tools/perf/bench/futex-wake.c | |||
@@ -129,7 +129,6 @@ int bench_futex_wake(int argc, const char **argv, | |||
129 | } | 129 | } |
130 | 130 | ||
131 | ncpus = sysconf(_SC_NPROCESSORS_ONLN); | 131 | ncpus = sysconf(_SC_NPROCESSORS_ONLN); |
132 | nwakes = futexbench_sanitize_numeric(nwakes); | ||
133 | 132 | ||
134 | sigfillset(&act.sa_mask); | 133 | sigfillset(&act.sa_mask); |
135 | act.sa_sigaction = toggle_done; | 134 | act.sa_sigaction = toggle_done; |
@@ -137,8 +136,6 @@ int bench_futex_wake(int argc, const char **argv, | |||
137 | 136 | ||
138 | if (!nthreads) | 137 | if (!nthreads) |
139 | nthreads = ncpus; | 138 | nthreads = ncpus; |
140 | else | ||
141 | nthreads = futexbench_sanitize_numeric(nthreads); | ||
142 | 139 | ||
143 | worker = calloc(nthreads, sizeof(*worker)); | 140 | worker = calloc(nthreads, sizeof(*worker)); |
144 | if (!worker) | 141 | if (!worker) |
diff --git a/tools/perf/bench/futex.h b/tools/perf/bench/futex.h index ba7c735c0c62..b2e06d1190d0 100644 --- a/tools/perf/bench/futex.h +++ b/tools/perf/bench/futex.h | |||
@@ -7,7 +7,6 @@ | |||
7 | #ifndef _FUTEX_H | 7 | #ifndef _FUTEX_H |
8 | #define _FUTEX_H | 8 | #define _FUTEX_H |
9 | 9 | ||
10 | #include <stdlib.h> | ||
11 | #include <unistd.h> | 10 | #include <unistd.h> |
12 | #include <sys/syscall.h> | 11 | #include <sys/syscall.h> |
13 | #include <sys/types.h> | 12 | #include <sys/types.h> |
@@ -100,7 +99,4 @@ static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr, | |||
100 | } | 99 | } |
101 | #endif | 100 | #endif |
102 | 101 | ||
103 | /* User input sanitation */ | ||
104 | #define futexbench_sanitize_numeric(__n) abs((__n)) | ||
105 | |||
106 | #endif /* _FUTEX_H */ | 102 | #endif /* _FUTEX_H */ |
diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c index 9e5a02d6b9a9..3083fc36282b 100644 --- a/tools/perf/bench/numa.c +++ b/tools/perf/bench/numa.c | |||
@@ -43,6 +43,7 @@ | |||
43 | /* | 43 | /* |
44 | * Debug printf: | 44 | * Debug printf: |
45 | */ | 45 | */ |
46 | #undef dprintf | ||
46 | #define dprintf(x...) do { if (g && g->p.show_details >= 1) printf(x); } while (0) | 47 | #define dprintf(x...) do { if (g && g->p.show_details >= 1) printf(x); } while (0) |
47 | 48 | ||
48 | struct thread_data { | 49 | struct thread_data { |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 2ddf189968dc..6cd6776052e7 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -655,22 +655,23 @@ record__finish_output(struct record *rec) | |||
655 | 655 | ||
656 | static int record__synthesize_workload(struct record *rec, bool tail) | 656 | static int record__synthesize_workload(struct record *rec, bool tail) |
657 | { | 657 | { |
658 | struct { | 658 | int err; |
659 | struct thread_map map; | 659 | struct thread_map *thread_map; |
660 | struct thread_map_data map_data; | ||
661 | } thread_map; | ||
662 | 660 | ||
663 | if (rec->opts.tail_synthesize != tail) | 661 | if (rec->opts.tail_synthesize != tail) |
664 | return 0; | 662 | return 0; |
665 | 663 | ||
666 | thread_map.map.nr = 1; | 664 | thread_map = thread_map__new_by_tid(rec->evlist->workload.pid); |
667 | thread_map.map.map[0].pid = rec->evlist->workload.pid; | 665 | if (thread_map == NULL) |
668 | thread_map.map.map[0].comm = NULL; | 666 | return -1; |
669 | return perf_event__synthesize_thread_map(&rec->tool, &thread_map.map, | 667 | |
668 | err = perf_event__synthesize_thread_map(&rec->tool, thread_map, | ||
670 | process_synthesized_event, | 669 | process_synthesized_event, |
671 | &rec->session->machines.host, | 670 | &rec->session->machines.host, |
672 | rec->opts.sample_address, | 671 | rec->opts.sample_address, |
673 | rec->opts.proc_map_timeout); | 672 | rec->opts.proc_map_timeout); |
673 | thread_map__put(thread_map); | ||
674 | return err; | ||
674 | } | 675 | } |
675 | 676 | ||
676 | static int record__synthesize(struct record *rec, bool tail); | 677 | static int record__synthesize(struct record *rec, bool tail); |
diff --git a/tools/perf/tests/parse-no-sample-id-all.c b/tools/perf/tests/parse-no-sample-id-all.c index 81c6eeaca0f5..65dcf48a92fb 100644 --- a/tools/perf/tests/parse-no-sample-id-all.c +++ b/tools/perf/tests/parse-no-sample-id-all.c | |||
@@ -50,7 +50,8 @@ static int process_events(union perf_event **events, size_t count) | |||
50 | } | 50 | } |
51 | 51 | ||
52 | struct test_attr_event { | 52 | struct test_attr_event { |
53 | struct attr_event attr; | 53 | struct perf_event_header header; |
54 | struct perf_event_attr attr; | ||
54 | u64 id; | 55 | u64 id; |
55 | }; | 56 | }; |
56 | 57 | ||
@@ -71,20 +72,16 @@ int test__parse_no_sample_id_all(int subtest __maybe_unused) | |||
71 | int err; | 72 | int err; |
72 | 73 | ||
73 | struct test_attr_event event1 = { | 74 | struct test_attr_event event1 = { |
74 | .attr = { | 75 | .header = { |
75 | .header = { | 76 | .type = PERF_RECORD_HEADER_ATTR, |
76 | .type = PERF_RECORD_HEADER_ATTR, | 77 | .size = sizeof(struct test_attr_event), |
77 | .size = sizeof(struct test_attr_event), | ||
78 | }, | ||
79 | }, | 78 | }, |
80 | .id = 1, | 79 | .id = 1, |
81 | }; | 80 | }; |
82 | struct test_attr_event event2 = { | 81 | struct test_attr_event event2 = { |
83 | .attr = { | 82 | .header = { |
84 | .header = { | 83 | .type = PERF_RECORD_HEADER_ATTR, |
85 | .type = PERF_RECORD_HEADER_ATTR, | 84 | .size = sizeof(struct test_attr_event), |
86 | .size = sizeof(struct test_attr_event), | ||
87 | }, | ||
88 | }, | 85 | }, |
89 | .id = 2, | 86 | .id = 2, |
90 | }; | 87 | }; |
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 | ||
1451 | static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, | 1451 | int 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 | ||
1658 | static struct { | ||
1659 | struct cpu_map map; | ||
1660 | int cpus[1]; | ||
1661 | } empty_cpu_map = { | ||
1662 | .map.nr = 1, | ||
1663 | .cpus = { -1, }, | ||
1664 | }; | ||
1665 | |||
1666 | static struct { | ||
1667 | struct thread_map map; | ||
1668 | int threads[1]; | ||
1669 | } empty_thread_map = { | ||
1670 | .map.nr = 1, | ||
1671 | .threads = { -1, }, | ||
1672 | }; | ||
1673 | |||
1674 | int 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 | |||
1688 | int perf_evsel__open_per_cpu(struct perf_evsel *evsel, | 1682 | int 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 | ||
1694 | int perf_evsel__open_per_thread(struct perf_evsel *evsel, | 1688 | int 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 | ||
1700 | static int perf_evsel__parse_id_sample(const struct perf_evsel *evsel, | 1694 | static 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 | ||
26 | CFLAGS_intel-pt-insn-decoder.o += -I$(OUTPUT)util/intel-pt-decoder -Wno-override-init | 26 | CFLAGS_intel-pt-insn-decoder.o += -I$(OUTPUT)util/intel-pt-decoder |
27 | |||
28 | ifneq ($(CC), clang) | ||
29 | CFLAGS_intel-pt-insn-decoder.o += -Wno-override-init | ||
30 | endif | ||
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 | ||
783 | int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) | 783 | int __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 | ||
814 | void machine__destroy_kernel_maps(struct machine *machine) | 814 | void 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 | ||
20 | void parse_events_error(YYLTYPE *loc, void *data, void *scanner, char const *msg); | ||
21 | |||
20 | #define ABORT_ON(val) \ | 22 | #define ABORT_ON(val) \ |
21 | do { \ | 23 | do { \ |
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)); |
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index 19edc1a7a232..621578aa12d6 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include | |||
@@ -32,7 +32,6 @@ EXTRA_WARNINGS += -Wold-style-definition | |||
32 | EXTRA_WARNINGS += -Wpacked | 32 | EXTRA_WARNINGS += -Wpacked |
33 | EXTRA_WARNINGS += -Wredundant-decls | 33 | EXTRA_WARNINGS += -Wredundant-decls |
34 | EXTRA_WARNINGS += -Wshadow | 34 | EXTRA_WARNINGS += -Wshadow |
35 | EXTRA_WARNINGS += -Wstrict-aliasing=3 | ||
36 | EXTRA_WARNINGS += -Wstrict-prototypes | 35 | EXTRA_WARNINGS += -Wstrict-prototypes |
37 | EXTRA_WARNINGS += -Wswitch-default | 36 | EXTRA_WARNINGS += -Wswitch-default |
38 | EXTRA_WARNINGS += -Wswitch-enum | 37 | EXTRA_WARNINGS += -Wswitch-enum |
@@ -40,6 +39,10 @@ EXTRA_WARNINGS += -Wundef | |||
40 | EXTRA_WARNINGS += -Wwrite-strings | 39 | EXTRA_WARNINGS += -Wwrite-strings |
41 | EXTRA_WARNINGS += -Wformat | 40 | EXTRA_WARNINGS += -Wformat |
42 | 41 | ||
42 | ifneq ($(CC), clang) | ||
43 | EXTRA_WARNINGS += -Wstrict-aliasing=3 | ||
44 | endif | ||
45 | |||
43 | ifneq ($(findstring $(MAKEFLAGS), w),w) | 46 | ifneq ($(findstring $(MAKEFLAGS), w),w) |
44 | PRINT_DIR = --no-print-directory | 47 | PRINT_DIR = --no-print-directory |
45 | else | 48 | else |