Skip to content

Commit 750991f

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Thomas Gleixner: "A pile of perf related fixes: Kernel: - Fix SLOTS PEBS event constraints for Icelake CPUs - Add the missing mask bit to allow counting hardware generated prefetches on L3 for Icelake CPUs - Make the test for hypervisor platforms more accurate (as far as possible) - Handle PMUs correctly which override event->cpu - Yet another missing fallthrough annotation Tools: perf.data: - Fix loading of compressed data split across adjacent records - Fix buffer size setting for processing CPU topology perf.data header. perf stat: - Fix segfault for event group in repeat mode - Always separate "stalled cycles per insn" line, it was being appended to the "instructions" line. perf script: - Fix --max-blocks man page description. - Improve man page description of metrics. - Fix off by one in brstackinsn IPC computation. perf probe: - 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" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/x86/intel: Mark expected switch fall-throughs perf/core: Fix creating kernel counters for PMUs that override event->cpu perf/x86: Apply more accurate check on hypervisor platform perf/x86/intel: Fix invalid Bit 13 for Icelake MSR_OFFCORE_RSP_x register perf/x86/intel: Fix SLOTS PEBS event constraint perf build: Do not use -Wshadow on gcc < 4.8 perf probe: Avoid calling freeing routine multiple times for same pointer perf probe: Set pev->nargs to zero after freeing pev->args entries perf session: Fix loading of compressed data split across adjacent records perf stat: Always separate stalled cycles per insn perf stat: Fix segfault for event group in repeat mode perf tools: Fix proper buffer size for feature processing perf script: Fix off by one in brstackinsn IPC computation perf script: Improve man page description of metrics perf script: Fix --max-blocks man page description
2 parents 431f288 + 289a2d2 commit 750991f

File tree

15 files changed

+59
-25
lines changed

15 files changed

+59
-25
lines changed

arch/x86/events/intel/core.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <asm/intel-family.h>
2121
#include <asm/apic.h>
2222
#include <asm/cpu_device_id.h>
23-
#include <asm/hypervisor.h>
2423

2524
#include "../perf_event.h"
2625

@@ -263,8 +262,8 @@ static struct event_constraint intel_icl_event_constraints[] = {
263262
};
264263

265264
static struct extra_reg intel_icl_extra_regs[] __read_mostly = {
266-
INTEL_UEVENT_EXTRA_REG(0x01b7, MSR_OFFCORE_RSP_0, 0x3fffff9fffull, RSP_0),
267-
INTEL_UEVENT_EXTRA_REG(0x01bb, MSR_OFFCORE_RSP_1, 0x3fffff9fffull, RSP_1),
265+
INTEL_UEVENT_EXTRA_REG(0x01b7, MSR_OFFCORE_RSP_0, 0x3fffffbfffull, RSP_0),
266+
INTEL_UEVENT_EXTRA_REG(0x01bb, MSR_OFFCORE_RSP_1, 0x3fffffbfffull, RSP_1),
268267
INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG(0x01cd),
269268
INTEL_UEVENT_EXTRA_REG(0x01c6, MSR_PEBS_FRONTEND, 0x7fff17, FE),
270269
EVENT_EXTRA_END
@@ -4053,7 +4052,7 @@ static bool check_msr(unsigned long msr, u64 mask)
40534052
* Disable the check for real HW, so we don't
40544053
* mess with potentionaly enabled registers:
40554054
*/
4056-
if (hypervisor_is_type(X86_HYPER_NATIVE))
4055+
if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
40574056
return true;
40584057

40594058
/*

arch/x86/events/intel/ds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ struct event_constraint intel_skl_pebs_event_constraints[] = {
851851

852852
struct event_constraint intel_icl_pebs_event_constraints[] = {
853853
INTEL_FLAGS_UEVENT_CONSTRAINT(0x1c0, 0x100000000ULL), /* INST_RETIRED.PREC_DIST */
854-
INTEL_FLAGS_UEVENT_CONSTRAINT(0x0400, 0x400000000ULL), /* SLOTS */
854+
INTEL_FLAGS_UEVENT_CONSTRAINT(0x0400, 0x800000000ULL), /* SLOTS */
855855

856856
INTEL_PLD_CONSTRAINT(0x1cd, 0xff), /* MEM_TRANS_RETIRED.LOAD_LATENCY */
857857
INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x1d0, 0xf), /* MEM_INST_RETIRED.LOAD */

kernel/events/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11274,7 +11274,7 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
1127411274
goto err_unlock;
1127511275
}
1127611276

11277-
perf_install_in_context(ctx, event, cpu);
11277+
perf_install_in_context(ctx, event, event->cpu);
1127811278
perf_unpin_context(ctx);
1127911279
mutex_unlock(&ctx->mutex);
1128011280

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

0 commit comments

Comments
 (0)