Skip to content

Commit 4990205

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-urgent-for-mingo-5.3-20190723' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes from Arnaldo Carvalho de Melo: perf.data: Alexey Budankov: - Fix loading of compressed data split across adjacent records Jiri Olsa: - Fix buffer size setting for processing CPU topology perf.data header. perf stat: Jiri Olsa: - Fix segfault for event group in repeat mode Cong Wang: - Always separate "stalled cycles per insn" line, it was being appended to the "instructions" line. perf script: Andi Kleen: - Fix --max-blocks man page description. - Improve man page description of metrics. - Fix off by one in brstackinsn IPC computation. perf probe: Arnaldo Carvalho de Melo: - Avoid calling freeing routine multiple times for same pointer. perf build: - Do not use -Wshadow on gcc < 4.8, avoiding too strict warnings treated as errors, breaking the build. Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents 7b5cf70 + 39e7317 commit 4990205

File tree

12 files changed

+54
-19
lines changed

12 files changed

+54
-19
lines changed

tools/perf/Documentation/perf-script.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ OPTIONS
228228

229229
With the metric option perf script can compute metrics for
230230
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
232232
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
234234
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.
236236

237237
For sample events it's possible to display misc field with -F +misc option,
238238
following letters are displayed for each bit:
@@ -384,7 +384,7 @@ include::itrace.txt[]
384384
perf script --time 0%-10%,30%-40%
385385

386386
--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
388388
each sample.
389389

390390
--reltime::

tools/perf/builtin-probe.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,16 @@ __cmd_probe(int argc, const char **argv)
698698

699699
ret = perf_add_probe_events(params.events, params.nevents);
700700
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;
701711
pr_err_with_code(" Error: Failed to add events.", ret);
702712
return ret;
703713
}

tools/perf/builtin-script.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample,
10591059

10601060
printed += ip__fprintf_sym(ip, thread, x.cpumode, x.cpu, &lastsym, attr, fp);
10611061
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,
10631063
&total_cycles);
10641064
if (PRINT_FIELD(SRCCODE))
10651065
printed += print_srccode(thread, x.cpumode, ip);

tools/perf/builtin-stat.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,13 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
607607
* group leaders.
608608
*/
609609
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);
611617

612618
return WEXITSTATUS(status);
613619
}
@@ -1997,6 +2003,7 @@ int cmd_stat(int argc, const char **argv)
19972003
perf_session__write_header(perf_stat.session, evsel_list, fd, true);
19982004
}
19992005

2006+
perf_evlist__close(evsel_list);
20002007
perf_session__delete(perf_stat.session);
20012008
}
20022009

tools/perf/util/evsel.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,7 @@ static void perf_evsel__free_id(struct perf_evsel *evsel)
12911291
xyarray__delete(evsel->sample_id);
12921292
evsel->sample_id = NULL;
12931293
zfree(&evsel->id);
1294+
evsel->ids = 0;
12941295
}
12951296

12961297
static void perf_evsel__free_config_terms(struct perf_evsel *evsel)
@@ -2077,6 +2078,7 @@ void perf_evsel__close(struct perf_evsel *evsel)
20772078

20782079
perf_evsel__close_fd(evsel);
20792080
perf_evsel__free_fd(evsel);
2081+
perf_evsel__free_id(evsel);
20802082
}
20812083

20822084
int perf_evsel__open_per_cpu(struct perf_evsel *evsel,

tools/perf/util/header.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3747,7 +3747,7 @@ int perf_event__process_feature(struct perf_session *session,
37473747
return 0;
37483748

37493749
ff.buf = (void *)fe->data;
3750-
ff.size = event->header.size - sizeof(event->header);
3750+
ff.size = event->header.size - sizeof(*fe);
37513751
ff.ph = &session->header;
37523752

37533753
if (feat_ops[feat].process(&ff, NULL))

tools/perf/util/probe-event.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,6 +2230,7 @@ void clear_perf_probe_event(struct perf_probe_event *pev)
22302230
field = next;
22312231
}
22322232
}
2233+
pev->nargs = 0;
22332234
zfree(&pev->args);
22342235
}
22352236

tools/perf/util/session.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,27 @@ static int perf_session__process_compressed_event(struct perf_session *session,
3636
void *src;
3737
size_t decomp_size, src_size;
3838
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;
4040
struct decomp *decomp, *decomp_last = session->decomp_last;
4141

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,
4349
MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
4450
if (decomp == MAP_FAILED) {
4551
pr_err("Couldn't allocate memory for decompression\n");
4652
return -1;
4753
}
4854

4955
decomp->file_pos = file_offset;
56+
decomp->mmap_len = mmap_len;
5057
decomp->head = 0;
5158

52-
if (decomp_last) {
53-
decomp_last_rem = decomp_last->size - decomp_last->head;
59+
if (decomp_last_rem) {
5460
memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_last_rem);
5561
decomp->size = decomp_last_rem;
5662
}
@@ -61,7 +67,7 @@ static int perf_session__process_compressed_event(struct perf_session *session,
6167
decomp_size = zstd_decompress_stream(&(session->zstd_data), src, src_size,
6268
&(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem);
6369
if (!decomp_size) {
64-
munmap(decomp, sizeof(struct decomp) + decomp_len);
70+
munmap(decomp, mmap_len);
6571
pr_err("Couldn't decompress data\n");
6672
return -1;
6773
}
@@ -255,15 +261,15 @@ static void perf_session__delete_threads(struct perf_session *session)
255261
static void perf_session__release_decomp_events(struct perf_session *session)
256262
{
257263
struct decomp *next, *decomp;
258-
size_t decomp_len;
264+
size_t mmap_len;
259265
next = session->decomp;
260-
decomp_len = session->header.env.comp_mmap_len;
261266
do {
262267
decomp = next;
263268
if (decomp == NULL)
264269
break;
265270
next = decomp->next;
266-
munmap(decomp, decomp_len + sizeof(struct decomp));
271+
mmap_len = decomp->mmap_len;
272+
munmap(decomp, mmap_len);
267273
} while (1);
268274
}
269275

tools/perf/util/session.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct perf_session {
4646
struct decomp {
4747
struct decomp *next;
4848
u64 file_pos;
49+
size_t mmap_len;
4950
u64 head;
5051
size_t size;
5152
char data[];

tools/perf/util/stat-shadow.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
819819
"stalled cycles per insn",
820820
ratio);
821821
} 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 ",
823824
"stalled cycles per insn", 0);
824825
}
825826
} else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES)) {

0 commit comments

Comments
 (0)