summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2019-08-06 21:44:57 -0400
committerDavid S. Miller <davem@davemloft.net>2019-08-06 21:44:57 -0400
commit13dfb3fa494361ea9a5950f27c9cd8b06d28c04f (patch)
tree1bf30874f57c6c6b21160a10282191fcd0868055 /tools/perf
parent05bb520376af2c5146d3c44832c22ec3bb54d778 (diff)
parent33920f1ec5bf47c5c0a1d2113989bdd9dfb3fae9 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Just minor overlapping changes in the conflicts here. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/Documentation/perf-script.txt8
-rw-r--r--tools/perf/Documentation/perf.data-file-format.txt2
-rw-r--r--tools/perf/arch/x86/entry/syscalls/syscall_64.tbl2
-rw-r--r--tools/perf/builtin-probe.c10
-rw-r--r--tools/perf/builtin-script.c2
-rw-r--r--tools/perf/builtin-stat.c9
-rwxr-xr-xtools/perf/trace/beauty/usbdevfs_ioctl.sh9
-rw-r--r--tools/perf/util/evsel.c2
-rw-r--r--tools/perf/util/header.c11
-rw-r--r--tools/perf/util/probe-event.c1
-rw-r--r--tools/perf/util/session.c22
-rw-r--r--tools/perf/util/session.h1
-rw-r--r--tools/perf/util/stat-shadow.c3
-rw-r--r--tools/perf/util/zstd.c4
14 files changed, 63 insertions, 23 deletions
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index d4e2e18a5881..caaab28f8400 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -228,11 +228,11 @@ OPTIONS
228 228
229 With the metric option perf script can compute metrics for 229 With the metric option perf script can compute metrics for
230 sampling periods, similar to perf stat. This requires 230 sampling periods, similar to perf stat. This requires
231 specifying a group with multiple metrics with the :S option 231 specifying a group with multiple events defining metrics with the :S option
232 for perf record. perf will sample on the first event, and 232 for perf record. perf will sample on the first event, and
233 compute metrics for all the events in the group. Please note 233 print computed metrics for all the events in the group. Please note
234 that the metric computed is averaged over the whole sampling 234 that the metric computed is averaged over the whole sampling
235 period, not just for the sample point. 235 period (since the last sample), not just for the sample point.
236 236
237 For sample events it's possible to display misc field with -F +misc option, 237 For sample events it's possible to display misc field with -F +misc option,
238 following letters are displayed for each bit: 238 following letters are displayed for each bit:
@@ -384,7 +384,7 @@ include::itrace.txt[]
384 perf script --time 0%-10%,30%-40% 384 perf script --time 0%-10%,30%-40%
385 385
386--max-blocks:: 386--max-blocks::
387 Set the maximum number of program blocks to print with brstackasm for 387 Set the maximum number of program blocks to print with brstackinsn for
388 each sample. 388 each sample.
389 389
390--reltime:: 390--reltime::
diff --git a/tools/perf/Documentation/perf.data-file-format.txt b/tools/perf/Documentation/perf.data-file-format.txt
index 5f54feb19977..d030c87ed9f5 100644
--- a/tools/perf/Documentation/perf.data-file-format.txt
+++ b/tools/perf/Documentation/perf.data-file-format.txt
@@ -126,7 +126,7 @@ vendor,family,model,stepping. For example: GenuineIntel,6,69,1
126 126
127 HEADER_TOTAL_MEM = 10, 127 HEADER_TOTAL_MEM = 10,
128 128
129An uint64_t with the total memory in bytes. 129An uint64_t with the total memory in kilobytes.
130 130
131 HEADER_CMDLINE = 11, 131 HEADER_CMDLINE = 11,
132 132
diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
index b4e6f9e6204a..c29976eca4a8 100644
--- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
@@ -355,6 +355,8 @@
355431 common fsconfig __x64_sys_fsconfig 355431 common fsconfig __x64_sys_fsconfig
356432 common fsmount __x64_sys_fsmount 356432 common fsmount __x64_sys_fsmount
357433 common fspick __x64_sys_fspick 357433 common fspick __x64_sys_fspick
358434 common pidfd_open __x64_sys_pidfd_open
359435 common clone3 __x64_sys_clone3/ptregs
358 360
359# 361#
360# x32-specific system call numbers start at 512 to avoid cache impact 362# x32-specific system call numbers start at 512 to avoid cache impact
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 6418782951a4..3d0ffd41fb55 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -698,6 +698,16 @@ __cmd_probe(int argc, const char **argv)
698 698
699 ret = perf_add_probe_events(params.events, params.nevents); 699 ret = perf_add_probe_events(params.events, params.nevents);
700 if (ret < 0) { 700 if (ret < 0) {
701
702 /*
703 * When perf_add_probe_events() fails it calls
704 * cleanup_perf_probe_events(pevs, npevs), i.e.
705 * cleanup_perf_probe_events(params.events, params.nevents), which
706 * will call clear_perf_probe_event(), so set nevents to zero
707 * to avoid cleanup_params() to call clear_perf_probe_event() again
708 * on the same pevs.
709 */
710 params.nevents = 0;
701 pr_err_with_code(" Error: Failed to add events.", ret); 711 pr_err_with_code(" Error: Failed to add events.", ret);
702 return ret; 712 return ret;
703 } 713 }
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 8f24865596af..0140ddb8dd0b 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1059,7 +1059,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample,
1059 1059
1060 printed += ip__fprintf_sym(ip, thread, x.cpumode, x.cpu, &lastsym, attr, fp); 1060 printed += ip__fprintf_sym(ip, thread, x.cpumode, x.cpu, &lastsym, attr, fp);
1061 if (ip == end) { 1061 if (ip == end) {
1062 printed += ip__fprintf_jump(ip, &br->entries[i], &x, buffer + off, len - off, insn, fp, 1062 printed += ip__fprintf_jump(ip, &br->entries[i], &x, buffer + off, len - off, ++insn, fp,
1063 &total_cycles); 1063 &total_cycles);
1064 if (PRINT_FIELD(SRCCODE)) 1064 if (PRINT_FIELD(SRCCODE))
1065 printed += print_srccode(thread, x.cpumode, ip); 1065 printed += print_srccode(thread, x.cpumode, ip);
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index b55a534b4de0..352cf39d7c2f 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -607,7 +607,13 @@ try_again:
607 * group leaders. 607 * group leaders.
608 */ 608 */
609 read_counters(&(struct timespec) { .tv_nsec = t1-t0 }); 609 read_counters(&(struct timespec) { .tv_nsec = t1-t0 });
610 perf_evlist__close(evsel_list); 610
611 /*
612 * We need to keep evsel_list alive, because it's processed
613 * later the evsel_list will be closed after.
614 */
615 if (!STAT_RECORD)
616 perf_evlist__close(evsel_list);
611 617
612 return WEXITSTATUS(status); 618 return WEXITSTATUS(status);
613} 619}
@@ -1997,6 +2003,7 @@ int cmd_stat(int argc, const char **argv)
1997 perf_session__write_header(perf_stat.session, evsel_list, fd, true); 2003 perf_session__write_header(perf_stat.session, evsel_list, fd, true);
1998 } 2004 }
1999 2005
2006 perf_evlist__close(evsel_list);
2000 perf_session__delete(perf_stat.session); 2007 perf_session__delete(perf_stat.session);
2001 } 2008 }
2002 2009
diff --git a/tools/perf/trace/beauty/usbdevfs_ioctl.sh b/tools/perf/trace/beauty/usbdevfs_ioctl.sh
index 930b80f422e8..aa597ae53747 100755
--- a/tools/perf/trace/beauty/usbdevfs_ioctl.sh
+++ b/tools/perf/trace/beauty/usbdevfs_ioctl.sh
@@ -3,10 +3,13 @@
3 3
4[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/ 4[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/
5 5
6# also as:
7# #define USBDEVFS_CONNINFO_EX(len) _IOC(_IOC_READ, 'U', 32, len)
8
6printf "static const char *usbdevfs_ioctl_cmds[] = {\n" 9printf "static const char *usbdevfs_ioctl_cmds[] = {\n"
7regex="^#[[:space:]]*define[[:space:]]+USBDEVFS_(\w+)[[:space:]]+_IO[WR]{0,2}\([[:space:]]*'U'[[:space:]]*,[[:space:]]*([[:digit:]]+).*" 10regex="^#[[:space:]]*define[[:space:]]+USBDEVFS_(\w+)(\(\w+\))?[[:space:]]+_IO[CWR]{0,2}\([[:space:]]*(_IOC_\w+,[[:space:]]*)?'U'[[:space:]]*,[[:space:]]*([[:digit:]]+).*"
8egrep $regex ${header_dir}/usbdevice_fs.h | egrep -v 'USBDEVFS_\w+32[[:space:]]' | \ 11egrep "$regex" ${header_dir}/usbdevice_fs.h | egrep -v 'USBDEVFS_\w+32[[:space:]]' | \
9 sed -r "s/$regex/\2 \1/g" | \ 12 sed -r "s/$regex/\4 \1/g" | \
10 sort | xargs printf "\t[%s] = \"%s\",\n" 13 sort | xargs printf "\t[%s] = \"%s\",\n"
11printf "};\n\n" 14printf "};\n\n"
12printf "#if 0\n" 15printf "#if 0\n"
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index ebb46da4dfe5..52459dd5ad0c 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1291,6 +1291,7 @@ static void perf_evsel__free_id(struct perf_evsel *evsel)
1291 xyarray__delete(evsel->sample_id); 1291 xyarray__delete(evsel->sample_id);
1292 evsel->sample_id = NULL; 1292 evsel->sample_id = NULL;
1293 zfree(&evsel->id); 1293 zfree(&evsel->id);
1294 evsel->ids = 0;
1294} 1295}
1295 1296
1296static void perf_evsel__free_config_terms(struct perf_evsel *evsel) 1297static void perf_evsel__free_config_terms(struct perf_evsel *evsel)
@@ -2077,6 +2078,7 @@ void perf_evsel__close(struct perf_evsel *evsel)
2077 2078
2078 perf_evsel__close_fd(evsel); 2079 perf_evsel__close_fd(evsel);
2079 perf_evsel__free_fd(evsel); 2080 perf_evsel__free_fd(evsel);
2081 perf_evsel__free_id(evsel);
2080} 2082}
2081 2083
2082int perf_evsel__open_per_cpu(struct perf_evsel *evsel, 2084int perf_evsel__open_per_cpu(struct perf_evsel *evsel,
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index c24db7f4909c..1903d7ec9797 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -3559,6 +3559,13 @@ int perf_session__read_header(struct perf_session *session)
3559 data->file.path); 3559 data->file.path);
3560 } 3560 }
3561 3561
3562 if (f_header.attr_size == 0) {
3563 pr_err("ERROR: The %s file's attr size field is 0 which is unexpected.\n"
3564 "Was the 'perf record' command properly terminated?\n",
3565 data->file.path);
3566 return -EINVAL;
3567 }
3568
3562 nr_attrs = f_header.attrs.size / f_header.attr_size; 3569 nr_attrs = f_header.attrs.size / f_header.attr_size;
3563 lseek(fd, f_header.attrs.offset, SEEK_SET); 3570 lseek(fd, f_header.attrs.offset, SEEK_SET);
3564 3571
@@ -3639,7 +3646,7 @@ int perf_event__synthesize_attr(struct perf_tool *tool,
3639 size += sizeof(struct perf_event_header); 3646 size += sizeof(struct perf_event_header);
3640 size += ids * sizeof(u64); 3647 size += ids * sizeof(u64);
3641 3648
3642 ev = malloc(size); 3649 ev = zalloc(size);
3643 3650
3644 if (ev == NULL) 3651 if (ev == NULL)
3645 return -ENOMEM; 3652 return -ENOMEM;
@@ -3747,7 +3754,7 @@ int perf_event__process_feature(struct perf_session *session,
3747 return 0; 3754 return 0;
3748 3755
3749 ff.buf = (void *)fe->data; 3756 ff.buf = (void *)fe->data;
3750 ff.size = event->header.size - sizeof(event->header); 3757 ff.size = event->header.size - sizeof(*fe);
3751 ff.ph = &session->header; 3758 ff.ph = &session->header;
3752 3759
3753 if (feat_ops[feat].process(&ff, NULL)) 3760 if (feat_ops[feat].process(&ff, NULL))
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index cd1eb73cfe83..8394d48f8b32 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2230,6 +2230,7 @@ void clear_perf_probe_event(struct perf_probe_event *pev)
2230 field = next; 2230 field = next;
2231 } 2231 }
2232 } 2232 }
2233 pev->nargs = 0;
2233 zfree(&pev->args); 2234 zfree(&pev->args);
2234} 2235}
2235 2236
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index d0fd6c614e68..37efa1f43d8b 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -36,10 +36,16 @@ static int perf_session__process_compressed_event(struct perf_session *session,
36 void *src; 36 void *src;
37 size_t decomp_size, src_size; 37 size_t decomp_size, src_size;
38 u64 decomp_last_rem = 0; 38 u64 decomp_last_rem = 0;
39 size_t decomp_len = session->header.env.comp_mmap_len; 39 size_t mmap_len, decomp_len = session->header.env.comp_mmap_len;
40 struct decomp *decomp, *decomp_last = session->decomp_last; 40 struct decomp *decomp, *decomp_last = session->decomp_last;
41 41
42 decomp = mmap(NULL, sizeof(struct decomp) + decomp_len, PROT_READ|PROT_WRITE, 42 if (decomp_last) {
43 decomp_last_rem = decomp_last->size - decomp_last->head;
44 decomp_len += decomp_last_rem;
45 }
46
47 mmap_len = sizeof(struct decomp) + decomp_len;
48 decomp = mmap(NULL, mmap_len, PROT_READ|PROT_WRITE,
43 MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); 49 MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
44 if (decomp == MAP_FAILED) { 50 if (decomp == MAP_FAILED) {
45 pr_err("Couldn't allocate memory for decompression\n"); 51 pr_err("Couldn't allocate memory for decompression\n");
@@ -47,10 +53,10 @@ static int perf_session__process_compressed_event(struct perf_session *session,
47 } 53 }
48 54
49 decomp->file_pos = file_offset; 55 decomp->file_pos = file_offset;
56 decomp->mmap_len = mmap_len;
50 decomp->head = 0; 57 decomp->head = 0;
51 58
52 if (decomp_last) { 59 if (decomp_last_rem) {
53 decomp_last_rem = decomp_last->size - decomp_last->head;
54 memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_last_rem); 60 memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_last_rem);
55 decomp->size = decomp_last_rem; 61 decomp->size = decomp_last_rem;
56 } 62 }
@@ -61,7 +67,7 @@ static int perf_session__process_compressed_event(struct perf_session *session,
61 decomp_size = zstd_decompress_stream(&(session->zstd_data), src, src_size, 67 decomp_size = zstd_decompress_stream(&(session->zstd_data), src, src_size,
62 &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem); 68 &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem);
63 if (!decomp_size) { 69 if (!decomp_size) {
64 munmap(decomp, sizeof(struct decomp) + decomp_len); 70 munmap(decomp, mmap_len);
65 pr_err("Couldn't decompress data\n"); 71 pr_err("Couldn't decompress data\n");
66 return -1; 72 return -1;
67 } 73 }
@@ -255,15 +261,15 @@ static void perf_session__delete_threads(struct perf_session *session)
255static void perf_session__release_decomp_events(struct perf_session *session) 261static void perf_session__release_decomp_events(struct perf_session *session)
256{ 262{
257 struct decomp *next, *decomp; 263 struct decomp *next, *decomp;
258 size_t decomp_len; 264 size_t mmap_len;
259 next = session->decomp; 265 next = session->decomp;
260 decomp_len = session->header.env.comp_mmap_len;
261 do { 266 do {
262 decomp = next; 267 decomp = next;
263 if (decomp == NULL) 268 if (decomp == NULL)
264 break; 269 break;
265 next = decomp->next; 270 next = decomp->next;
266 munmap(decomp, decomp_len + sizeof(struct decomp)); 271 mmap_len = decomp->mmap_len;
272 munmap(decomp, mmap_len);
267 } while (1); 273 } while (1);
268} 274}
269 275
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index dd8920b745bc..863dbad87849 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -46,6 +46,7 @@ struct perf_session {
46struct decomp { 46struct decomp {
47 struct decomp *next; 47 struct decomp *next;
48 u64 file_pos; 48 u64 file_pos;
49 size_t mmap_len;
49 u64 head; 50 u64 head;
50 size_t size; 51 size_t size;
51 char data[]; 52 char data[];
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 656065af4971..accb1bf1cfd8 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -819,7 +819,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
819 "stalled cycles per insn", 819 "stalled cycles per insn",
820 ratio); 820 ratio);
821 } else if (have_frontend_stalled) { 821 } else if (have_frontend_stalled) {
822 print_metric(config, ctxp, NULL, NULL, 822 out->new_line(config, ctxp);
823 print_metric(config, ctxp, NULL, "%7.2f ",
823 "stalled cycles per insn", 0); 824 "stalled cycles per insn", 0);
824 } 825 }
825 } else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES)) { 826 } else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES)) {
diff --git a/tools/perf/util/zstd.c b/tools/perf/util/zstd.c
index 23bdb9884576..d2202392ffdb 100644
--- a/tools/perf/util/zstd.c
+++ b/tools/perf/util/zstd.c
@@ -99,8 +99,8 @@ size_t zstd_decompress_stream(struct zstd_data *data, void *src, size_t src_size
99 while (input.pos < input.size) { 99 while (input.pos < input.size) {
100 ret = ZSTD_decompressStream(data->dstream, &output, &input); 100 ret = ZSTD_decompressStream(data->dstream, &output, &input);
101 if (ZSTD_isError(ret)) { 101 if (ZSTD_isError(ret)) {
102 pr_err("failed to decompress (B): %ld -> %ld : %s\n", 102 pr_err("failed to decompress (B): %ld -> %ld, dst_size %ld : %s\n",
103 src_size, output.size, ZSTD_getErrorName(ret)); 103 src_size, output.size, dst_size, ZSTD_getErrorName(ret));
104 break; 104 break;
105 } 105 }
106 output.dst = dst + output.pos; 106 output.dst = dst + output.pos;