aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2012-03-19 12:41:24 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-03-19 12:41:24 -0400
commit9ce28d827f74d0acdd058bded8bab5309b0f5c8f (patch)
tree634f22e8df9c7fd3966b3639e3e997436751ca50 /tools
parentf074ff92b5b26f3a559fab1203c36e140ea8d067 (diff)
parentc16fa4f2ad19908a47c63d8fa436a1178438c7e7 (diff)
Merge tag 'v3.3' into staging/for_v3.4
* tag 'v3.3': (1646 commits) Linux 3.3 Don't limit non-nested epoll paths netfilter: ctnetlink: fix race between delete and timeout expiration ipv6: Don't dev_hold(dev) in ip6_mc_find_dev_rcu. nilfs2: fix NULL pointer dereference in nilfs_load_super_block() nilfs2: clamp ns_r_segments_percentage to [1, 99] afs: Remote abort can cause BUG in rxrpc code afs: Read of file returns EBADMSG C6X: remove dead code from entry.S wimax/i2400m: fix erroneous NETDEV_TX_BUSY use net/hyperv: fix erroneous NETDEV_TX_BUSY use net/usbnet: reserve headroom on rx skbs bnx2x: fix memory leak in bnx2x_init_firmware() bnx2x: fix a crash on corrupt firmware file sch_sfq: revert dont put new flow at the end of flows ipv6: fix icmp6_dst_alloc() MAINTAINERS: Add Serge as maintainer of capabilities drivers/video/backlight/s6e63m0.c: fix corruption storing gamma mode MAINTAINERS: add entry for exynos mipi display drivers MAINTAINERS: fix link to Gustavo Padovans tree ...
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Makefile9
-rw-r--r--tools/perf/arch/powerpc/util/header.c2
-rw-r--r--tools/perf/arch/x86/util/header.c2
-rw-r--r--tools/perf/bench/mem-memcpy-x86-64-asm.S6
-rw-r--r--tools/perf/builtin-probe.c2
-rw-r--r--tools/perf/builtin-record.c33
-rw-r--r--tools/perf/builtin-top.c36
-rw-r--r--tools/perf/perf.h7
-rw-r--r--tools/perf/util/color.c9
-rw-r--r--tools/perf/util/event.c3
-rw-r--r--tools/perf/util/evlist.c4
-rw-r--r--tools/perf/util/evsel.c1
-rw-r--r--tools/perf/util/header.c6
-rw-r--r--tools/perf/util/hist.c30
-rw-r--r--tools/perf/util/include/asm/unistd_32.h1
-rw-r--r--tools/perf/util/include/asm/unistd_64.h1
-rw-r--r--tools/perf/util/parse-events.c2
-rw-r--r--tools/perf/util/probe-event.c8
-rw-r--r--tools/perf/util/probe-finder.c12
-rw-r--r--tools/perf/util/sort.c3
-rw-r--r--tools/perf/util/strbuf.c7
-rw-r--r--tools/perf/util/symbol.c1
-rw-r--r--tools/perf/util/top.h1
-rw-r--r--tools/perf/util/trace-event-parse.c3
-rw-r--r--tools/perf/util/ui/browsers/hists.c14
-rw-r--r--tools/perf/util/ui/helpline.c3
-rw-r--r--tools/perf/util/util.c2
-rw-r--r--tools/perf/util/util.h1
-rwxr-xr-xtools/testing/ktest/ktest.pl8
29 files changed, 140 insertions, 77 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index ac86d67b636e..8a4b9bccf8b2 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -104,7 +104,7 @@ endif
104 104
105CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) 105CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
106EXTLIBS = -lpthread -lrt -lelf -lm 106EXTLIBS = -lpthread -lrt -lelf -lm
107ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 107ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
108ALL_LDFLAGS = $(LDFLAGS) 108ALL_LDFLAGS = $(LDFLAGS)
109STRIP ?= strip 109STRIP ?= strip
110 110
@@ -168,10 +168,7 @@ endif
168 168
169### --- END CONFIGURATION SECTION --- 169### --- END CONFIGURATION SECTION ---
170 170
171# Those must not be GNU-specific; they are shared with perl/ which may 171BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
172# be built by a different compiler. (Note that this is an artifact now
173# but it still might be nice to keep that distinction.)
174BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include
175BASIC_LDFLAGS = 172BASIC_LDFLAGS =
176 173
177# Guard against environment variables 174# Guard against environment variables
@@ -252,6 +249,8 @@ LIB_H += util/include/asm/uaccess.h
252LIB_H += util/include/dwarf-regs.h 249LIB_H += util/include/dwarf-regs.h
253LIB_H += util/include/asm/dwarf2.h 250LIB_H += util/include/asm/dwarf2.h
254LIB_H += util/include/asm/cpufeature.h 251LIB_H += util/include/asm/cpufeature.h
252LIB_H += util/include/asm/unistd_32.h
253LIB_H += util/include/asm/unistd_64.h
255LIB_H += perf.h 254LIB_H += perf.h
256LIB_H += util/annotate.h 255LIB_H += util/annotate.h
257LIB_H += util/cache.h 256LIB_H += util/cache.h
diff --git a/tools/perf/arch/powerpc/util/header.c b/tools/perf/arch/powerpc/util/header.c
index eba80c292945..2f7073d107fd 100644
--- a/tools/perf/arch/powerpc/util/header.c
+++ b/tools/perf/arch/powerpc/util/header.c
@@ -25,7 +25,7 @@ get_cpuid(char *buffer, size_t sz)
25 25
26 pvr = mfspr(SPRN_PVR); 26 pvr = mfspr(SPRN_PVR);
27 27
28 nb = snprintf(buffer, sz, "%lu,%lu$", PVR_VER(pvr), PVR_REV(pvr)); 28 nb = scnprintf(buffer, sz, "%lu,%lu$", PVR_VER(pvr), PVR_REV(pvr));
29 29
30 /* look for end marker to ensure the entire data fit */ 30 /* look for end marker to ensure the entire data fit */
31 if (strchr(buffer, '$')) { 31 if (strchr(buffer, '$')) {
diff --git a/tools/perf/arch/x86/util/header.c b/tools/perf/arch/x86/util/header.c
index f94006068d2b..146d12a1cec0 100644
--- a/tools/perf/arch/x86/util/header.c
+++ b/tools/perf/arch/x86/util/header.c
@@ -48,7 +48,7 @@ get_cpuid(char *buffer, size_t sz)
48 if (family >= 0x6) 48 if (family >= 0x6)
49 model += ((a >> 16) & 0xf) << 4; 49 model += ((a >> 16) & 0xf) << 4;
50 } 50 }
51 nb = snprintf(buffer, sz, "%s,%u,%u,%u$", vendor, family, model, step); 51 nb = scnprintf(buffer, sz, "%s,%u,%u,%u$", vendor, family, model, step);
52 52
53 /* look for end marker to ensure the entire data fit */ 53 /* look for end marker to ensure the entire data fit */
54 if (strchr(buffer, '$')) { 54 if (strchr(buffer, '$')) {
diff --git a/tools/perf/bench/mem-memcpy-x86-64-asm.S b/tools/perf/bench/mem-memcpy-x86-64-asm.S
index a57b66e853c2..185a96d66dd1 100644
--- a/tools/perf/bench/mem-memcpy-x86-64-asm.S
+++ b/tools/perf/bench/mem-memcpy-x86-64-asm.S
@@ -1,2 +1,8 @@
1 1
2#include "../../../arch/x86/lib/memcpy_64.S" 2#include "../../../arch/x86/lib/memcpy_64.S"
3/*
4 * We need to provide note.GNU-stack section, saying that we want
5 * NOT executable stack. Otherwise the final linking will assume that
6 * the ELF stack should not be restricted at all and set it RWX.
7 */
8.section .note.GNU-stack,"",@progbits
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 59d43abfbfec..fb8566181f27 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -20,7 +20,6 @@
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * 21 *
22 */ 22 */
23#define _GNU_SOURCE
24#include <sys/utsname.h> 23#include <sys/utsname.h>
25#include <sys/types.h> 24#include <sys/types.h>
26#include <sys/stat.h> 25#include <sys/stat.h>
@@ -31,7 +30,6 @@
31#include <stdlib.h> 30#include <stdlib.h>
32#include <string.h> 31#include <string.h>
33 32
34#undef _GNU_SOURCE
35#include "perf.h" 33#include "perf.h"
36#include "builtin.h" 34#include "builtin.h"
37#include "util/util.h" 35#include "util/util.h"
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 0abfb18b911f..227b6ae99785 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -204,6 +204,9 @@ static void perf_record__open(struct perf_record *rec)
204 204
205 if (opts->group && pos != first) 205 if (opts->group && pos != first)
206 group_fd = first->fd; 206 group_fd = first->fd;
207fallback_missing_features:
208 if (opts->exclude_guest_missing)
209 attr->exclude_guest = attr->exclude_host = 0;
207retry_sample_id: 210retry_sample_id:
208 attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0; 211 attr->sample_id_all = opts->sample_id_all_avail ? 1 : 0;
209try_again: 212try_again:
@@ -217,15 +220,23 @@ try_again:
217 } else if (err == ENODEV && opts->cpu_list) { 220 } else if (err == ENODEV && opts->cpu_list) {
218 die("No such device - did you specify" 221 die("No such device - did you specify"
219 " an out-of-range profile CPU?\n"); 222 " an out-of-range profile CPU?\n");
220 } else if (err == EINVAL && opts->sample_id_all_avail) { 223 } else if (err == EINVAL) {
221 /* 224 if (!opts->exclude_guest_missing &&
222 * Old kernel, no attr->sample_id_type_all field 225 (attr->exclude_guest || attr->exclude_host)) {
223 */ 226 pr_debug("Old kernel, cannot exclude "
224 opts->sample_id_all_avail = false; 227 "guest or host samples.\n");
225 if (!opts->sample_time && !opts->raw_samples && !time_needed) 228 opts->exclude_guest_missing = true;
226 attr->sample_type &= ~PERF_SAMPLE_TIME; 229 goto fallback_missing_features;
227 230 } else if (opts->sample_id_all_avail) {
228 goto retry_sample_id; 231 /*
232 * Old kernel, no attr->sample_id_type_all field
233 */
234 opts->sample_id_all_avail = false;
235 if (!opts->sample_time && !opts->raw_samples && !time_needed)
236 attr->sample_type &= ~PERF_SAMPLE_TIME;
237
238 goto retry_sample_id;
239 }
229 } 240 }
230 241
231 /* 242 /*
@@ -503,9 +514,9 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
503 return err; 514 return err;
504 } 515 }
505 516
506 if (!!rec->no_buildid 517 if (!rec->no_buildid
507 && !perf_header__has_feat(&session->header, HEADER_BUILD_ID)) { 518 && !perf_header__has_feat(&session->header, HEADER_BUILD_ID)) {
508 pr_err("Couldn't generating buildids. " 519 pr_err("Couldn't generate buildids. "
509 "Use --no-buildid to profile anyway.\n"); 520 "Use --no-buildid to profile anyway.\n");
510 return -1; 521 return -1;
511 } 522 }
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 8f80df896038..ecff31257eb3 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -89,8 +89,6 @@ void get_term_dimensions(struct winsize *ws)
89 89
90static void perf_top__update_print_entries(struct perf_top *top) 90static void perf_top__update_print_entries(struct perf_top *top)
91{ 91{
92 top->print_entries = top->winsize.ws_row;
93
94 if (top->print_entries > 9) 92 if (top->print_entries > 9)
95 top->print_entries -= 9; 93 top->print_entries -= 9;
96} 94}
@@ -100,6 +98,13 @@ static void perf_top__sig_winch(int sig __used, siginfo_t *info __used, void *ar
100 struct perf_top *top = arg; 98 struct perf_top *top = arg;
101 99
102 get_term_dimensions(&top->winsize); 100 get_term_dimensions(&top->winsize);
101 if (!top->print_entries
102 || (top->print_entries+4) > top->winsize.ws_row) {
103 top->print_entries = top->winsize.ws_row;
104 } else {
105 top->print_entries += 4;
106 top->winsize.ws_row = top->print_entries;
107 }
103 perf_top__update_print_entries(top); 108 perf_top__update_print_entries(top);
104} 109}
105 110
@@ -453,8 +458,10 @@ static void perf_top__handle_keypress(struct perf_top *top, int c)
453 }; 458 };
454 perf_top__sig_winch(SIGWINCH, NULL, top); 459 perf_top__sig_winch(SIGWINCH, NULL, top);
455 sigaction(SIGWINCH, &act, NULL); 460 sigaction(SIGWINCH, &act, NULL);
456 } else 461 } else {
462 perf_top__sig_winch(SIGWINCH, NULL, top);
457 signal(SIGWINCH, SIG_DFL); 463 signal(SIGWINCH, SIG_DFL);
464 }
458 break; 465 break;
459 case 'E': 466 case 'E':
460 if (top->evlist->nr_entries > 1) { 467 if (top->evlist->nr_entries > 1) {
@@ -850,6 +857,9 @@ static void perf_top__start_counters(struct perf_top *top)
850 attr->mmap = 1; 857 attr->mmap = 1;
851 attr->comm = 1; 858 attr->comm = 1;
852 attr->inherit = top->inherit; 859 attr->inherit = top->inherit;
860fallback_missing_features:
861 if (top->exclude_guest_missing)
862 attr->exclude_guest = attr->exclude_host = 0;
853retry_sample_id: 863retry_sample_id:
854 attr->sample_id_all = top->sample_id_all_avail ? 1 : 0; 864 attr->sample_id_all = top->sample_id_all_avail ? 1 : 0;
855try_again: 865try_again:
@@ -861,12 +871,20 @@ try_again:
861 if (err == EPERM || err == EACCES) { 871 if (err == EPERM || err == EACCES) {
862 ui__error_paranoid(); 872 ui__error_paranoid();
863 goto out_err; 873 goto out_err;
864 } else if (err == EINVAL && top->sample_id_all_avail) { 874 } else if (err == EINVAL) {
865 /* 875 if (!top->exclude_guest_missing &&
866 * Old kernel, no attr->sample_id_type_all field 876 (attr->exclude_guest || attr->exclude_host)) {
867 */ 877 pr_debug("Old kernel, cannot exclude "
868 top->sample_id_all_avail = false; 878 "guest or host samples.\n");
869 goto retry_sample_id; 879 top->exclude_guest_missing = true;
880 goto fallback_missing_features;
881 } else if (top->sample_id_all_avail) {
882 /*
883 * Old kernel, no attr->sample_id_type_all field
884 */
885 top->sample_id_all_avail = false;
886 goto retry_sample_id;
887 }
870 } 888 }
871 /* 889 /*
872 * If it's cycles then fall back to hrtimer 890 * If it's cycles then fall back to hrtimer
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 64f8bee31ced..3afa39ac1d40 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -10,6 +10,9 @@ void get_term_dimensions(struct winsize *ws);
10#define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory") 10#define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
11#define cpu_relax() asm volatile("rep; nop" ::: "memory"); 11#define cpu_relax() asm volatile("rep; nop" ::: "memory");
12#define CPUINFO_PROC "model name" 12#define CPUINFO_PROC "model name"
13#ifndef __NR_perf_event_open
14# define __NR_perf_event_open 336
15#endif
13#endif 16#endif
14 17
15#if defined(__x86_64__) 18#if defined(__x86_64__)
@@ -17,6 +20,9 @@ void get_term_dimensions(struct winsize *ws);
17#define rmb() asm volatile("lfence" ::: "memory") 20#define rmb() asm volatile("lfence" ::: "memory")
18#define cpu_relax() asm volatile("rep; nop" ::: "memory"); 21#define cpu_relax() asm volatile("rep; nop" ::: "memory");
19#define CPUINFO_PROC "model name" 22#define CPUINFO_PROC "model name"
23#ifndef __NR_perf_event_open
24# define __NR_perf_event_open 298
25#endif
20#endif 26#endif
21 27
22#ifdef __powerpc__ 28#ifdef __powerpc__
@@ -199,6 +205,7 @@ struct perf_record_opts {
199 bool sample_address; 205 bool sample_address;
200 bool sample_time; 206 bool sample_time;
201 bool sample_id_all_avail; 207 bool sample_id_all_avail;
208 bool exclude_guest_missing;
202 bool system_wide; 209 bool system_wide;
203 bool period; 210 bool period;
204 unsigned int freq; 211 unsigned int freq;
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
index 521c38a79190..11e46da17bbb 100644
--- a/tools/perf/util/color.c
+++ b/tools/perf/util/color.c
@@ -1,3 +1,4 @@
1#include <linux/kernel.h>
1#include "cache.h" 2#include "cache.h"
2#include "color.h" 3#include "color.h"
3 4
@@ -182,12 +183,12 @@ static int __color_vsnprintf(char *bf, size_t size, const char *color,
182 } 183 }
183 184
184 if (perf_use_color_default && *color) 185 if (perf_use_color_default && *color)
185 r += snprintf(bf, size, "%s", color); 186 r += scnprintf(bf, size, "%s", color);
186 r += vsnprintf(bf + r, size - r, fmt, args); 187 r += vscnprintf(bf + r, size - r, fmt, args);
187 if (perf_use_color_default && *color) 188 if (perf_use_color_default && *color)
188 r += snprintf(bf + r, size - r, "%s", PERF_COLOR_RESET); 189 r += scnprintf(bf + r, size - r, "%s", PERF_COLOR_RESET);
189 if (trail) 190 if (trail)
190 r += snprintf(bf + r, size - r, "%s", trail); 191 r += scnprintf(bf + r, size - r, "%s", trail);
191 return r; 192 return r;
192} 193}
193 194
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 73ddaf06b8e7..2a6f33cd888c 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -74,6 +74,7 @@ static pid_t perf_event__get_comm_tgid(pid_t pid, char *comm, size_t len)
74 if (size >= len) 74 if (size >= len)
75 size = len - 1; 75 size = len - 1;
76 memcpy(comm, name, size); 76 memcpy(comm, name, size);
77 comm[size] = '\0';
77 78
78 } else if (memcmp(bf, "Tgid:", 5) == 0) { 79 } else if (memcmp(bf, "Tgid:", 5) == 0) {
79 char *tgids = bf + 5; 80 char *tgids = bf + 5;
@@ -554,7 +555,7 @@ static int perf_event__process_kernel_mmap(struct perf_tool *tool __used,
554 555
555 is_kernel_mmap = memcmp(event->mmap.filename, 556 is_kernel_mmap = memcmp(event->mmap.filename,
556 kmmap_prefix, 557 kmmap_prefix,
557 strlen(kmmap_prefix)) == 0; 558 strlen(kmmap_prefix) - 1) == 0;
558 if (event->mmap.filename[0] == '/' || 559 if (event->mmap.filename[0] == '/' ||
559 (!is_kernel_mmap && event->mmap.filename[0] == '[')) { 560 (!is_kernel_mmap && event->mmap.filename[0] == '[')) {
560 561
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 3f16e08a5c8d..ea32a061f1c8 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -349,6 +349,10 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
349 hlist_for_each_entry(sid, pos, head, node) 349 hlist_for_each_entry(sid, pos, head, node)
350 if (sid->id == id) 350 if (sid->id == id)
351 return sid->evsel; 351 return sid->evsel;
352
353 if (!perf_evlist__sample_id_all(evlist))
354 return list_entry(evlist->entries.next, struct perf_evsel, node);
355
352 return NULL; 356 return NULL;
353} 357}
354 358
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 667f3b78bb2c..7132ee834e0e 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -463,6 +463,7 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
463 memset(data, 0, sizeof(*data)); 463 memset(data, 0, sizeof(*data));
464 data->cpu = data->pid = data->tid = -1; 464 data->cpu = data->pid = data->tid = -1;
465 data->stream_id = data->id = data->time = -1ULL; 465 data->stream_id = data->id = data->time = -1ULL;
466 data->period = 1;
466 467
467 if (event->header.type != PERF_RECORD_SAMPLE) { 468 if (event->header.type != PERF_RECORD_SAMPLE) {
468 if (!sample_id_all) 469 if (!sample_id_all)
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 3e7e0b09c12c..14bb035c5fd9 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -280,7 +280,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
280 if (realname == NULL || filename == NULL || linkname == NULL) 280 if (realname == NULL || filename == NULL || linkname == NULL)
281 goto out_free; 281 goto out_free;
282 282
283 len = snprintf(filename, size, "%s%s%s", 283 len = scnprintf(filename, size, "%s%s%s",
284 debugdir, is_kallsyms ? "/" : "", realname); 284 debugdir, is_kallsyms ? "/" : "", realname);
285 if (mkdir_p(filename, 0755)) 285 if (mkdir_p(filename, 0755))
286 goto out_free; 286 goto out_free;
@@ -295,7 +295,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
295 goto out_free; 295 goto out_free;
296 } 296 }
297 297
298 len = snprintf(linkname, size, "%s/.build-id/%.2s", 298 len = scnprintf(linkname, size, "%s/.build-id/%.2s",
299 debugdir, sbuild_id); 299 debugdir, sbuild_id);
300 300
301 if (access(linkname, X_OK) && mkdir_p(linkname, 0755)) 301 if (access(linkname, X_OK) && mkdir_p(linkname, 0755))
@@ -2105,7 +2105,7 @@ int perf_event__synthesize_event_type(struct perf_tool *tool,
2105 strncpy(ev.event_type.event_type.name, name, MAX_EVENT_NAME - 1); 2105 strncpy(ev.event_type.event_type.name, name, MAX_EVENT_NAME - 1);
2106 2106
2107 ev.event_type.header.type = PERF_RECORD_HEADER_EVENT_TYPE; 2107 ev.event_type.header.type = PERF_RECORD_HEADER_EVENT_TYPE;
2108 size = strlen(name); 2108 size = strlen(ev.event_type.event_type.name);
2109 size = ALIGN(size, sizeof(u64)); 2109 size = ALIGN(size, sizeof(u64));
2110 ev.event_type.header.size = sizeof(ev.event_type) - 2110 ev.event_type.header.size = sizeof(ev.event_type) -
2111 (sizeof(ev.event_type.event_type.name) - size); 2111 (sizeof(ev.event_type.event_type.name) - size);
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 6f505d1abac7..e11e482bd185 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -768,7 +768,7 @@ static int hist_entry__pcnt_snprintf(struct hist_entry *he, char *s,
768 sep ? "%.2f" : " %6.2f%%", 768 sep ? "%.2f" : " %6.2f%%",
769 (period * 100.0) / total); 769 (period * 100.0) / total);
770 else 770 else
771 ret = snprintf(s, size, sep ? "%.2f" : " %6.2f%%", 771 ret = scnprintf(s, size, sep ? "%.2f" : " %6.2f%%",
772 (period * 100.0) / total); 772 (period * 100.0) / total);
773 if (symbol_conf.show_cpu_utilization) { 773 if (symbol_conf.show_cpu_utilization) {
774 ret += percent_color_snprintf(s + ret, size - ret, 774 ret += percent_color_snprintf(s + ret, size - ret,
@@ -791,20 +791,20 @@ static int hist_entry__pcnt_snprintf(struct hist_entry *he, char *s,
791 } 791 }
792 } 792 }
793 } else 793 } else
794 ret = snprintf(s, size, sep ? "%" PRIu64 : "%12" PRIu64 " ", period); 794 ret = scnprintf(s, size, sep ? "%" PRIu64 : "%12" PRIu64 " ", period);
795 795
796 if (symbol_conf.show_nr_samples) { 796 if (symbol_conf.show_nr_samples) {
797 if (sep) 797 if (sep)
798 ret += snprintf(s + ret, size - ret, "%c%" PRIu64, *sep, nr_events); 798 ret += scnprintf(s + ret, size - ret, "%c%" PRIu64, *sep, nr_events);
799 else 799 else
800 ret += snprintf(s + ret, size - ret, "%11" PRIu64, nr_events); 800 ret += scnprintf(s + ret, size - ret, "%11" PRIu64, nr_events);
801 } 801 }
802 802
803 if (symbol_conf.show_total_period) { 803 if (symbol_conf.show_total_period) {
804 if (sep) 804 if (sep)
805 ret += snprintf(s + ret, size - ret, "%c%" PRIu64, *sep, period); 805 ret += scnprintf(s + ret, size - ret, "%c%" PRIu64, *sep, period);
806 else 806 else
807 ret += snprintf(s + ret, size - ret, " %12" PRIu64, period); 807 ret += scnprintf(s + ret, size - ret, " %12" PRIu64, period);
808 } 808 }
809 809
810 if (pair_hists) { 810 if (pair_hists) {
@@ -819,25 +819,25 @@ static int hist_entry__pcnt_snprintf(struct hist_entry *he, char *s,
819 diff = new_percent - old_percent; 819 diff = new_percent - old_percent;
820 820
821 if (fabs(diff) >= 0.01) 821 if (fabs(diff) >= 0.01)
822 snprintf(bf, sizeof(bf), "%+4.2F%%", diff); 822 ret += scnprintf(bf, sizeof(bf), "%+4.2F%%", diff);
823 else 823 else
824 snprintf(bf, sizeof(bf), " "); 824 ret += scnprintf(bf, sizeof(bf), " ");
825 825
826 if (sep) 826 if (sep)
827 ret += snprintf(s + ret, size - ret, "%c%s", *sep, bf); 827 ret += scnprintf(s + ret, size - ret, "%c%s", *sep, bf);
828 else 828 else
829 ret += snprintf(s + ret, size - ret, "%11.11s", bf); 829 ret += scnprintf(s + ret, size - ret, "%11.11s", bf);
830 830
831 if (show_displacement) { 831 if (show_displacement) {
832 if (displacement) 832 if (displacement)
833 snprintf(bf, sizeof(bf), "%+4ld", displacement); 833 ret += scnprintf(bf, sizeof(bf), "%+4ld", displacement);
834 else 834 else
835 snprintf(bf, sizeof(bf), " "); 835 ret += scnprintf(bf, sizeof(bf), " ");
836 836
837 if (sep) 837 if (sep)
838 ret += snprintf(s + ret, size - ret, "%c%s", *sep, bf); 838 ret += scnprintf(s + ret, size - ret, "%c%s", *sep, bf);
839 else 839 else
840 ret += snprintf(s + ret, size - ret, "%6.6s", bf); 840 ret += scnprintf(s + ret, size - ret, "%6.6s", bf);
841 } 841 }
842 } 842 }
843 843
@@ -855,7 +855,7 @@ int hist_entry__snprintf(struct hist_entry *he, char *s, size_t size,
855 if (se->elide) 855 if (se->elide)
856 continue; 856 continue;
857 857
858 ret += snprintf(s + ret, size - ret, "%s", sep ?: " "); 858 ret += scnprintf(s + ret, size - ret, "%s", sep ?: " ");
859 ret += se->se_snprintf(he, s + ret, size - ret, 859 ret += se->se_snprintf(he, s + ret, size - ret,
860 hists__col_len(hists, se->se_width_idx)); 860 hists__col_len(hists, se->se_width_idx));
861 } 861 }
diff --git a/tools/perf/util/include/asm/unistd_32.h b/tools/perf/util/include/asm/unistd_32.h
new file mode 100644
index 000000000000..8b137891791f
--- /dev/null
+++ b/tools/perf/util/include/asm/unistd_32.h
@@ -0,0 +1 @@
diff --git a/tools/perf/util/include/asm/unistd_64.h b/tools/perf/util/include/asm/unistd_64.h
new file mode 100644
index 000000000000..8b137891791f
--- /dev/null
+++ b/tools/perf/util/include/asm/unistd_64.h
@@ -0,0 +1 @@
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index b029296d20d9..c7a6f6faf91e 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -165,7 +165,7 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
165 struct tracepoint_path *path = NULL; 165 struct tracepoint_path *path = NULL;
166 DIR *sys_dir, *evt_dir; 166 DIR *sys_dir, *evt_dir;
167 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; 167 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;
168 char id_buf[4]; 168 char id_buf[24];
169 int fd; 169 int fd;
170 u64 id; 170 u64 id;
171 char evt_path[MAXPATHLEN]; 171 char evt_path[MAXPATHLEN];
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index eb25900e2211..e33554a562b3 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -19,7 +19,6 @@
19 * 19 *
20 */ 20 */
21 21
22#define _GNU_SOURCE
23#include <sys/utsname.h> 22#include <sys/utsname.h>
24#include <sys/types.h> 23#include <sys/types.h>
25#include <sys/stat.h> 24#include <sys/stat.h>
@@ -33,7 +32,6 @@
33#include <limits.h> 32#include <limits.h>
34#include <elf.h> 33#include <elf.h>
35 34
36#undef _GNU_SOURCE
37#include "util.h" 35#include "util.h"
38#include "event.h" 36#include "event.h"
39#include "string.h" 37#include "string.h"
@@ -1869,6 +1867,12 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev,
1869 tev->point.symbol); 1867 tev->point.symbol);
1870 ret = -ENOENT; 1868 ret = -ENOENT;
1871 goto error; 1869 goto error;
1870 } else if (tev->point.offset > sym->end - sym->start) {
1871 pr_warning("Offset specified is greater than size of %s\n",
1872 tev->point.symbol);
1873 ret = -ENOENT;
1874 goto error;
1875
1872 } 1876 }
1873 1877
1874 return 1; 1878 return 1;
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 5d732621a462..74bd2e63c4b4 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -672,7 +672,7 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)
672static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr, 672static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr,
673 bool retprobe, struct probe_trace_point *tp) 673 bool retprobe, struct probe_trace_point *tp)
674{ 674{
675 Dwarf_Addr eaddr; 675 Dwarf_Addr eaddr, highaddr;
676 const char *name; 676 const char *name;
677 677
678 /* Copy the name of probe point */ 678 /* Copy the name of probe point */
@@ -683,6 +683,16 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwarf_Addr paddr,
683 dwarf_diename(sp_die)); 683 dwarf_diename(sp_die));
684 return -ENOENT; 684 return -ENOENT;
685 } 685 }
686 if (dwarf_highpc(sp_die, &highaddr) != 0) {
687 pr_warning("Failed to get end address of %s\n",
688 dwarf_diename(sp_die));
689 return -ENOENT;
690 }
691 if (paddr > highaddr) {
692 pr_warning("Offset specified is greater than size of %s\n",
693 dwarf_diename(sp_die));
694 return -EINVAL;
695 }
686 tp->symbol = strdup(name); 696 tp->symbol = strdup(name);
687 if (tp->symbol == NULL) 697 if (tp->symbol == NULL)
688 return -ENOMEM; 698 return -ENOMEM;
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 16da30d8d765..076c9d4e1ea4 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -33,6 +33,9 @@ static int repsep_snprintf(char *bf, size_t size, const char *fmt, ...)
33 } 33 }
34 } 34 }
35 va_end(ap); 35 va_end(ap);
36
37 if (n >= (int)size)
38 return size - 1;
36 return n; 39 return n;
37} 40}
38 41
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index 92e068517c1a..2eeb51baf077 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -1,4 +1,5 @@
1#include "cache.h" 1#include "cache.h"
2#include <linux/kernel.h>
2 3
3int prefixcmp(const char *str, const char *prefix) 4int prefixcmp(const char *str, const char *prefix)
4{ 5{
@@ -89,14 +90,14 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
89 if (!strbuf_avail(sb)) 90 if (!strbuf_avail(sb))
90 strbuf_grow(sb, 64); 91 strbuf_grow(sb, 64);
91 va_start(ap, fmt); 92 va_start(ap, fmt);
92 len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap); 93 len = vscnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
93 va_end(ap); 94 va_end(ap);
94 if (len < 0) 95 if (len < 0)
95 die("your vsnprintf is broken"); 96 die("your vscnprintf is broken");
96 if (len > strbuf_avail(sb)) { 97 if (len > strbuf_avail(sb)) {
97 strbuf_grow(sb, len); 98 strbuf_grow(sb, len);
98 va_start(ap, fmt); 99 va_start(ap, fmt);
99 len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap); 100 len = vscnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
100 va_end(ap); 101 va_end(ap);
101 if (len > strbuf_avail(sb)) { 102 if (len > strbuf_avail(sb)) {
102 die("this should not happen, your snprintf is broken"); 103 die("this should not happen, your snprintf is broken");
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 215d50f2042e..0975438c3e72 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1,4 +1,3 @@
1#define _GNU_SOURCE
2#include <ctype.h> 1#include <ctype.h>
3#include <dirent.h> 2#include <dirent.h>
4#include <errno.h> 3#include <errno.h>
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h
index a248f3c2c60d..f2eab81435ae 100644
--- a/tools/perf/util/top.h
+++ b/tools/perf/util/top.h
@@ -34,6 +34,7 @@ struct perf_top {
34 bool inherit; 34 bool inherit;
35 bool group; 35 bool group;
36 bool sample_id_all_avail; 36 bool sample_id_all_avail;
37 bool exclude_guest_missing;
37 bool dump_symtab; 38 bool dump_symtab;
38 const char *cpu_list; 39 const char *cpu_list;
39 struct hist_entry *sym_filter_entry; 40 struct hist_entry *sym_filter_entry;
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 6c164dc9ee95..1a8d4dc4f386 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -21,14 +21,13 @@
21 * The parts for function graph printing was taken and modified from the 21 * The parts for function graph printing was taken and modified from the
22 * Linux Kernel that were written by Frederic Weisbecker. 22 * Linux Kernel that were written by Frederic Weisbecker.
23 */ 23 */
24#define _GNU_SOURCE 24
25#include <stdio.h> 25#include <stdio.h>
26#include <stdlib.h> 26#include <stdlib.h>
27#include <string.h> 27#include <string.h>
28#include <ctype.h> 28#include <ctype.h>
29#include <errno.h> 29#include <errno.h>
30 30
31#undef _GNU_SOURCE
32#include "../perf.h" 31#include "../perf.h"
33#include "util.h" 32#include "util.h"
34#include "trace-event.h" 33#include "trace-event.h"
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c
index 1212a386a033..bb9197c9c4a4 100644
--- a/tools/perf/util/ui/browsers/hists.c
+++ b/tools/perf/util/ui/browsers/hists.c
@@ -1,6 +1,4 @@
1#define _GNU_SOURCE
2#include <stdio.h> 1#include <stdio.h>
3#undef _GNU_SOURCE
4#include "../libslang.h" 2#include "../libslang.h"
5#include <stdlib.h> 3#include <stdlib.h>
6#include <string.h> 4#include <string.h>
@@ -839,15 +837,15 @@ static int hists__browser_title(struct hists *self, char *bf, size_t size,
839 unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE]; 837 unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE];
840 838
841 nr_events = convert_unit(nr_events, &unit); 839 nr_events = convert_unit(nr_events, &unit);
842 printed = snprintf(bf, size, "Events: %lu%c %s", nr_events, unit, ev_name); 840 printed = scnprintf(bf, size, "Events: %lu%c %s", nr_events, unit, ev_name);
843 841
844 if (thread) 842 if (thread)
845 printed += snprintf(bf + printed, size - printed, 843 printed += scnprintf(bf + printed, size - printed,
846 ", Thread: %s(%d)", 844 ", Thread: %s(%d)",
847 (thread->comm_set ? thread->comm : ""), 845 (thread->comm_set ? thread->comm : ""),
848 thread->pid); 846 thread->pid);
849 if (dso) 847 if (dso)
850 printed += snprintf(bf + printed, size - printed, 848 printed += scnprintf(bf + printed, size - printed,
851 ", DSO: %s", dso->short_name); 849 ", DSO: %s", dso->short_name);
852 return printed; 850 return printed;
853} 851}
@@ -1097,7 +1095,7 @@ static void perf_evsel_menu__write(struct ui_browser *browser,
1097 HE_COLORSET_NORMAL); 1095 HE_COLORSET_NORMAL);
1098 1096
1099 nr_events = convert_unit(nr_events, &unit); 1097 nr_events = convert_unit(nr_events, &unit);
1100 printed = snprintf(bf, sizeof(bf), "%lu%c%s%s", nr_events, 1098 printed = scnprintf(bf, sizeof(bf), "%lu%c%s%s", nr_events,
1101 unit, unit == ' ' ? "" : " ", ev_name); 1099 unit, unit == ' ' ? "" : " ", ev_name);
1102 slsmg_printf("%s", bf); 1100 slsmg_printf("%s", bf);
1103 1101
@@ -1107,8 +1105,8 @@ static void perf_evsel_menu__write(struct ui_browser *browser,
1107 if (!current_entry) 1105 if (!current_entry)
1108 ui_browser__set_color(browser, HE_COLORSET_TOP); 1106 ui_browser__set_color(browser, HE_COLORSET_TOP);
1109 nr_events = convert_unit(nr_events, &unit); 1107 nr_events = convert_unit(nr_events, &unit);
1110 snprintf(bf, sizeof(bf), ": %ld%c%schunks LOST!", nr_events, 1108 printed += scnprintf(bf, sizeof(bf), ": %ld%c%schunks LOST!",
1111 unit, unit == ' ' ? "" : " "); 1109 nr_events, unit, unit == ' ' ? "" : " ");
1112 warn = bf; 1110 warn = bf;
1113 } 1111 }
1114 1112
diff --git a/tools/perf/util/ui/helpline.c b/tools/perf/util/ui/helpline.c
index 6ef3c5691762..2f950c2641c8 100644
--- a/tools/perf/util/ui/helpline.c
+++ b/tools/perf/util/ui/helpline.c
@@ -1,4 +1,3 @@
1#define _GNU_SOURCE
2#include <stdio.h> 1#include <stdio.h>
3#include <stdlib.h> 2#include <stdlib.h>
4#include <string.h> 3#include <string.h>
@@ -65,7 +64,7 @@ int ui_helpline__show_help(const char *format, va_list ap)
65 static int backlog; 64 static int backlog;
66 65
67 pthread_mutex_lock(&ui__lock); 66 pthread_mutex_lock(&ui__lock);
68 ret = vsnprintf(ui_helpline__last_msg + backlog, 67 ret = vscnprintf(ui_helpline__last_msg + backlog,
69 sizeof(ui_helpline__last_msg) - backlog, format, ap); 68 sizeof(ui_helpline__last_msg) - backlog, format, ap);
70 backlog += ret; 69 backlog += ret;
71 70
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 813141047fc2..fb25d1329218 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -6,7 +6,7 @@
6 * XXX We need to find a better place for these things... 6 * XXX We need to find a better place for these things...
7 */ 7 */
8bool perf_host = true; 8bool perf_host = true;
9bool perf_guest = true; 9bool perf_guest = false;
10 10
11void event_attr_init(struct perf_event_attr *attr) 11void event_attr_init(struct perf_event_attr *attr)
12{ 12{
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index b9c530cce79a..ecf9898169c8 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -40,7 +40,6 @@
40#define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) 40#define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)
41 41
42#define _ALL_SOURCE 1 42#define _ALL_SOURCE 1
43#define _GNU_SOURCE 1
44#define _BSD_SOURCE 1 43#define _BSD_SOURCE 1
45#define HAS_BOOL 44#define HAS_BOOL
46 45
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 62a134dc421a..9507c4b251a8 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -3244,9 +3244,11 @@ sub make_min_config {
3244 $in_bisect = 1; 3244 $in_bisect = 1;
3245 3245
3246 my $failed = 0; 3246 my $failed = 0;
3247 build "oldconfig"; 3247 build "oldconfig" or $failed = 1;
3248 start_monitor_and_boot or $failed = 1; 3248 if (!$failed) {
3249 end_monitor; 3249 start_monitor_and_boot or $failed = 1;
3250 end_monitor;
3251 }
3250 3252
3251 $in_bisect = 0; 3253 $in_bisect = 0;
3252 3254