Skip to content

Commit

Permalink
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…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
  ...
  • Loading branch information
torvalds committed Mar 10, 2019
2 parents 262d6a9 + b339da4 commit 12ad143
Show file tree
Hide file tree
Showing 55 changed files with 1,003 additions and 472 deletions.
1 change: 1 addition & 0 deletions arch/x86/events/intel/uncore.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ static int uncore_pmu_event_init(struct perf_event *event)
/* fixed counters have event field hardcoded to zero */
hwc->config = 0ULL;
} else if (is_freerunning_event(event)) {
hwc->config = event->attr.config;
if (!check_valid_freerunning_event(box, event))
return -EINVAL;
event->hw.idx = UNCORE_PMC_IDX_FREERUNNING;
Expand Down
12 changes: 6 additions & 6 deletions arch/x86/events/intel/uncore.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ static inline
unsigned int uncore_freerunning_counter(struct intel_uncore_box *box,
struct perf_event *event)
{
unsigned int type = uncore_freerunning_type(event->attr.config);
unsigned int idx = uncore_freerunning_idx(event->attr.config);
unsigned int type = uncore_freerunning_type(event->hw.config);
unsigned int idx = uncore_freerunning_idx(event->hw.config);
struct intel_uncore_pmu *pmu = box->pmu;

return pmu->type->freerunning[type].counter_base +
Expand Down Expand Up @@ -377,15 +377,15 @@ static inline
unsigned int uncore_freerunning_bits(struct intel_uncore_box *box,
struct perf_event *event)
{
unsigned int type = uncore_freerunning_type(event->attr.config);
unsigned int type = uncore_freerunning_type(event->hw.config);

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

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

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

return (type < uncore_num_freerunning_types(box, event)) &&
(idx < uncore_num_freerunning(box, event));
Expand Down
4 changes: 3 additions & 1 deletion arch/x86/events/intel/uncore_snb.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,11 @@ static int snb_uncore_imc_event_init(struct perf_event *event)

/* must be done before validate_group */
event->hw.event_base = base;
event->hw.config = cfg;
event->hw.idx = idx;

/* Convert to standard encoding format for freerunning counters */
event->hw.config = ((cfg - 1) << 8) | 0x10ff;

/* no group validation needed, we have free running counters */

return 0;
Expand Down
4 changes: 3 additions & 1 deletion kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4238,7 +4238,8 @@ static bool is_sb_event(struct perf_event *event)
if (attr->mmap || attr->mmap_data || attr->mmap2 ||
attr->comm || attr->comm_exec ||
attr->task || attr->ksymbol ||
attr->context_switch)
attr->context_switch ||
attr->bpf_event)
return true;
return false;
}
Expand Down Expand Up @@ -9174,6 +9175,7 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
case IF_SRC_KERNELADDR:
case IF_SRC_KERNEL:
kernel = 1;
/* fall through */

case IF_SRC_FILEADDR:
case IF_SRC_FILE:
Expand Down
32 changes: 15 additions & 17 deletions kernel/events/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,29 +598,27 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
{
bool overwrite = !(flags & RING_BUFFER_WRITABLE);
int node = (event->cpu == -1) ? -1 : cpu_to_node(event->cpu);
int ret = -ENOMEM, max_order = 0;
int ret = -ENOMEM, max_order;

if (!has_aux(event))
return -EOPNOTSUPP;

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

/*
* PMU requests more than one contiguous chunks of memory
* for SW double buffering
*/
if ((event->pmu->capabilities & PERF_PMU_CAP_AUX_SW_DOUBLEBUF) &&
!overwrite) {
if (!max_order)
return -EINVAL;
/*
* PMU requests more than one contiguous chunks of memory
* for SW double buffering
*/
if ((event->pmu->capabilities & PERF_PMU_CAP_AUX_SW_DOUBLEBUF) &&
!overwrite) {
if (!max_order)
return -EINVAL;

max_order--;
}
max_order--;
}

rb->aux_pages = kcalloc_node(nr_pages, sizeof(void *), GFP_KERNEL,
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -2457,7 +2457,7 @@ static int arg_num_eval(struct tep_print_arg *arg, long long *val)
static char *arg_eval (struct tep_print_arg *arg)
{
long long val;
static char buf[20];
static char buf[24];

switch (arg->type) {
case TEP_PRINT_ATOM:
Expand Down
56 changes: 56 additions & 0 deletions tools/perf/Documentation/perf-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,62 @@ OPTIONS
sum of shown entries will be always 100%. "absolute" means it retains
the original value before and after the filter is applied.

--time::
Analyze samples within given time window. It supports time
percent with multiple time ranges. Time string is 'a%/n,b%/m,...'
or 'a%-b%,c%-%d,...'.

For example:

Select the second 10% time slice to diff:

perf diff --time 10%/2

Select from 0% to 10% time slice to diff:

perf diff --time 0%-10%

Select the first and the second 10% time slices to diff:

perf diff --time 10%/1,10%/2

Select from 0% to 10% and 30% to 40% slices to diff:

perf diff --time 0%-10%,30%-40%

It also supports analyzing samples within a given time window
<start>,<stop>. Times have the format seconds.microseconds. If 'start'
is not given (i.e., time string is ',x.y') then analysis starts at
the beginning of the file. If stop time is not given (i.e, time
string is 'x.y,') then analysis goes to the end of the file. Time string is
'a1.b1,c1.d1:a2.b2,c2.d2'. Use ':' to separate timestamps for different
perf.data files.

For example, we get the timestamp information from 'perf script'.

perf script -i perf.data.old
mgen 13940 [000] 3946.361400: ...

perf script -i perf.data
mgen 13940 [000] 3971.150589 ...

perf diff --time 3946.361400,:3971.150589,

It analyzes the perf.data.old from the timestamp 3946.361400 to
the end of perf.data.old and analyzes the perf.data from the
timestamp 3971.150589 to the end of perf.data.

--cpu:: Only diff samples for the list of CPUs provided. Multiple CPUs can
be provided as a comma-separated list with no space: 0,1. Ranges of
CPUs are specified with -: 0-2. Default is to report samples on all
CPUs.

--pid=::
Only diff samples for given process ID (comma separated list).

--tid=::
Only diff samples for given thread ID (comma separated list).

COMPARISON
----------
The comparison is governed by the baseline file. The baseline perf.data
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/arch/arm64/annotate/instructions.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static int arm64_mov__parse(struct arch *arch __maybe_unused,
}

static int mov__scnprintf(struct ins *ins, char *bf, size_t size,
struct ins_operands *ops);
struct ins_operands *ops, int max_ins_name);

static struct ins_ops arm64_mov_ops = {
.parse = arm64_mov__parse,
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/arch/s390/annotate/instructions.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static int s390_call__parse(struct arch *arch, struct ins_operands *ops,
}

static int call__scnprintf(struct ins *ins, char *bf, size_t size,
struct ins_operands *ops);
struct ins_operands *ops, int max_ins_name);

static struct ins_ops s390_call_ops = {
.parse = s390_call__parse,
Expand Down
8 changes: 6 additions & 2 deletions tools/perf/builtin-c2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,12 @@ static int setup_nodes(struct perf_session *session)
if (!set)
return -ENOMEM;

nodes[node] = set;

/* empty node, skip */
if (cpu_map__empty(map))
continue;

for (cpu = 0; cpu < map->nr; cpu++) {
set_bit(map->map[cpu], set);

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

cpu2node[map->map[cpu]] = node;
}

nodes[node] = set;
}

setup_nodes_header();
Expand Down
Loading

0 comments on commit 12ad143

Please sign in to comment.