Skip to content

Commit 12ad143

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Thomas Gleixner: "Perf updates and fixes: Kernel: - Handle events which have the bpf_event attribute set as side band events as they carry information about BPF programs. - Add missing switch-case fall-through comments Libraries: - Fix leaks and double frees in error code paths. - Prevent buffer overflows in libtraceevent Tools: - Improvements in handling Intel BT/PTS - Add BTF ELF markers to perf trace BPF programs to improve output - Support --time, --cpu, --pid and --tid filters for perf diff - Calculate the column width in perf annotate as the hardcoded 6 characters for the instruction are not sufficient - Small fixes all over the place" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (38 commits) perf/core: Mark expected switch fall-through perf/x86/intel/uncore: Fix client IMC events return huge result perf/ring_buffer: Use high order allocations for AUX buffers optimistically perf data: Force perf_data__open|close zero data->file.path perf session: Fix double free in perf_data__close perf evsel: Probe for precise_ip with simple attr perf tools: Read and store caps/max_precise in perf_pmu perf hist: Fix memory leak of srcline perf hist: Add error path into hist_entry__init perf c2c: Fix c2c report for empty numa node perf script python: Add Python3 support to intel-pt-events.py perf script python: Add Python3 support to event_analyzing_sample.py perf script python: add Python3 support to check-perf-trace.py perf script python: Add Python3 support to futex-contention.py perf script python: Remove mixed indentation perf diff: Support --pid/--tid filter options perf diff: Support --cpu filter option perf diff: Support --time filter option perf thread: Generalize function to copy from thread addr space from intel-bts code perf annotate: Calculate the max instruction name, align column to that ...
2 parents 262d6a9 + b339da4 commit 12ad143

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1003
-472
lines changed

arch/x86/events/intel/uncore.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ static int uncore_pmu_event_init(struct perf_event *event)
732732
/* fixed counters have event field hardcoded to zero */
733733
hwc->config = 0ULL;
734734
} else if (is_freerunning_event(event)) {
735+
hwc->config = event->attr.config;
735736
if (!check_valid_freerunning_event(box, event))
736737
return -EINVAL;
737738
event->hw.idx = UNCORE_PMC_IDX_FREERUNNING;

arch/x86/events/intel/uncore.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ static inline
292292
unsigned int uncore_freerunning_counter(struct intel_uncore_box *box,
293293
struct perf_event *event)
294294
{
295-
unsigned int type = uncore_freerunning_type(event->attr.config);
296-
unsigned int idx = uncore_freerunning_idx(event->attr.config);
295+
unsigned int type = uncore_freerunning_type(event->hw.config);
296+
unsigned int idx = uncore_freerunning_idx(event->hw.config);
297297
struct intel_uncore_pmu *pmu = box->pmu;
298298

299299
return pmu->type->freerunning[type].counter_base +
@@ -377,15 +377,15 @@ static inline
377377
unsigned int uncore_freerunning_bits(struct intel_uncore_box *box,
378378
struct perf_event *event)
379379
{
380-
unsigned int type = uncore_freerunning_type(event->attr.config);
380+
unsigned int type = uncore_freerunning_type(event->hw.config);
381381

382382
return box->pmu->type->freerunning[type].bits;
383383
}
384384

385385
static inline int uncore_num_freerunning(struct intel_uncore_box *box,
386386
struct perf_event *event)
387387
{
388-
unsigned int type = uncore_freerunning_type(event->attr.config);
388+
unsigned int type = uncore_freerunning_type(event->hw.config);
389389

390390
return box->pmu->type->freerunning[type].num_counters;
391391
}
@@ -399,8 +399,8 @@ static inline int uncore_num_freerunning_types(struct intel_uncore_box *box,
399399
static inline bool check_valid_freerunning_event(struct intel_uncore_box *box,
400400
struct perf_event *event)
401401
{
402-
unsigned int type = uncore_freerunning_type(event->attr.config);
403-
unsigned int idx = uncore_freerunning_idx(event->attr.config);
402+
unsigned int type = uncore_freerunning_type(event->hw.config);
403+
unsigned int idx = uncore_freerunning_idx(event->hw.config);
404404

405405
return (type < uncore_num_freerunning_types(box, event)) &&
406406
(idx < uncore_num_freerunning(box, event));

arch/x86/events/intel/uncore_snb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,11 @@ static int snb_uncore_imc_event_init(struct perf_event *event)
442442

443443
/* must be done before validate_group */
444444
event->hw.event_base = base;
445-
event->hw.config = cfg;
446445
event->hw.idx = idx;
447446

447+
/* Convert to standard encoding format for freerunning counters */
448+
event->hw.config = ((cfg - 1) << 8) | 0x10ff;
449+
448450
/* no group validation needed, we have free running counters */
449451

450452
return 0;

kernel/events/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4238,7 +4238,8 @@ static bool is_sb_event(struct perf_event *event)
42384238
if (attr->mmap || attr->mmap_data || attr->mmap2 ||
42394239
attr->comm || attr->comm_exec ||
42404240
attr->task || attr->ksymbol ||
4241-
attr->context_switch)
4241+
attr->context_switch ||
4242+
attr->bpf_event)
42424243
return true;
42434244
return false;
42444245
}
@@ -9174,6 +9175,7 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
91749175
case IF_SRC_KERNELADDR:
91759176
case IF_SRC_KERNEL:
91769177
kernel = 1;
9178+
/* fall through */
91779179

91789180
case IF_SRC_FILEADDR:
91799181
case IF_SRC_FILE:

kernel/events/ring_buffer.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -598,29 +598,27 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
598598
{
599599
bool overwrite = !(flags & RING_BUFFER_WRITABLE);
600600
int node = (event->cpu == -1) ? -1 : cpu_to_node(event->cpu);
601-
int ret = -ENOMEM, max_order = 0;
601+
int ret = -ENOMEM, max_order;
602602

603603
if (!has_aux(event))
604604
return -EOPNOTSUPP;
605605

606-
if (event->pmu->capabilities & PERF_PMU_CAP_AUX_NO_SG) {
607-
/*
608-
* We need to start with the max_order that fits in nr_pages,
609-
* not the other way around, hence ilog2() and not get_order.
610-
*/
611-
max_order = ilog2(nr_pages);
606+
/*
607+
* We need to start with the max_order that fits in nr_pages,
608+
* not the other way around, hence ilog2() and not get_order.
609+
*/
610+
max_order = ilog2(nr_pages);
612611

613-
/*
614-
* PMU requests more than one contiguous chunks of memory
615-
* for SW double buffering
616-
*/
617-
if ((event->pmu->capabilities & PERF_PMU_CAP_AUX_SW_DOUBLEBUF) &&
618-
!overwrite) {
619-
if (!max_order)
620-
return -EINVAL;
612+
/*
613+
* PMU requests more than one contiguous chunks of memory
614+
* for SW double buffering
615+
*/
616+
if ((event->pmu->capabilities & PERF_PMU_CAP_AUX_SW_DOUBLEBUF) &&
617+
!overwrite) {
618+
if (!max_order)
619+
return -EINVAL;
621620

622-
max_order--;
623-
}
621+
max_order--;
624622
}
625623

626624
rb->aux_pages = kcalloc_node(nr_pages, sizeof(void *), GFP_KERNEL,

tools/lib/traceevent/event-parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,7 @@ static int arg_num_eval(struct tep_print_arg *arg, long long *val)
24572457
static char *arg_eval (struct tep_print_arg *arg)
24582458
{
24592459
long long val;
2460-
static char buf[20];
2460+
static char buf[24];
24612461

24622462
switch (arg->type) {
24632463
case TEP_PRINT_ATOM:

tools/perf/Documentation/perf-diff.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,62 @@ OPTIONS
118118
sum of shown entries will be always 100%. "absolute" means it retains
119119
the original value before and after the filter is applied.
120120

121+
--time::
122+
Analyze samples within given time window. It supports time
123+
percent with multiple time ranges. Time string is 'a%/n,b%/m,...'
124+
or 'a%-b%,c%-%d,...'.
125+
126+
For example:
127+
128+
Select the second 10% time slice to diff:
129+
130+
perf diff --time 10%/2
131+
132+
Select from 0% to 10% time slice to diff:
133+
134+
perf diff --time 0%-10%
135+
136+
Select the first and the second 10% time slices to diff:
137+
138+
perf diff --time 10%/1,10%/2
139+
140+
Select from 0% to 10% and 30% to 40% slices to diff:
141+
142+
perf diff --time 0%-10%,30%-40%
143+
144+
It also supports analyzing samples within a given time window
145+
<start>,<stop>. Times have the format seconds.microseconds. If 'start'
146+
is not given (i.e., time string is ',x.y') then analysis starts at
147+
the beginning of the file. If stop time is not given (i.e, time
148+
string is 'x.y,') then analysis goes to the end of the file. Time string is
149+
'a1.b1,c1.d1:a2.b2,c2.d2'. Use ':' to separate timestamps for different
150+
perf.data files.
151+
152+
For example, we get the timestamp information from 'perf script'.
153+
154+
perf script -i perf.data.old
155+
mgen 13940 [000] 3946.361400: ...
156+
157+
perf script -i perf.data
158+
mgen 13940 [000] 3971.150589 ...
159+
160+
perf diff --time 3946.361400,:3971.150589,
161+
162+
It analyzes the perf.data.old from the timestamp 3946.361400 to
163+
the end of perf.data.old and analyzes the perf.data from the
164+
timestamp 3971.150589 to the end of perf.data.
165+
166+
--cpu:: Only diff samples for the list of CPUs provided. Multiple CPUs can
167+
be provided as a comma-separated list with no space: 0,1. Ranges of
168+
CPUs are specified with -: 0-2. Default is to report samples on all
169+
CPUs.
170+
171+
--pid=::
172+
Only diff samples for given process ID (comma separated list).
173+
174+
--tid=::
175+
Only diff samples for given thread ID (comma separated list).
176+
121177
COMPARISON
122178
----------
123179
The comparison is governed by the baseline file. The baseline perf.data

tools/perf/arch/arm64/annotate/instructions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int arm64_mov__parse(struct arch *arch __maybe_unused,
5858
}
5959

6060
static int mov__scnprintf(struct ins *ins, char *bf, size_t size,
61-
struct ins_operands *ops);
61+
struct ins_operands *ops, int max_ins_name);
6262

6363
static struct ins_ops arm64_mov_ops = {
6464
.parse = arm64_mov__parse,

tools/perf/arch/s390/annotate/instructions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static int s390_call__parse(struct arch *arch, struct ins_operands *ops,
4646
}
4747

4848
static int call__scnprintf(struct ins *ins, char *bf, size_t size,
49-
struct ins_operands *ops);
49+
struct ins_operands *ops, int max_ins_name);
5050

5151
static struct ins_ops s390_call_ops = {
5252
.parse = s390_call__parse,

tools/perf/builtin-c2c.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,6 +2056,12 @@ static int setup_nodes(struct perf_session *session)
20562056
if (!set)
20572057
return -ENOMEM;
20582058

2059+
nodes[node] = set;
2060+
2061+
/* empty node, skip */
2062+
if (cpu_map__empty(map))
2063+
continue;
2064+
20592065
for (cpu = 0; cpu < map->nr; cpu++) {
20602066
set_bit(map->map[cpu], set);
20612067

@@ -2064,8 +2070,6 @@ static int setup_nodes(struct perf_session *session)
20642070

20652071
cpu2node[map->map[cpu]] = node;
20662072
}
2067-
2068-
nodes[node] = set;
20692073
}
20702074

20712075
setup_nodes_header();

0 commit comments

Comments
 (0)