Skip to content

Commit 1354ac6

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: User visible changes: - IPC and cycle accounting in 'perf annotate'. (Andi Kleen) - Display cycles in branch sort mode in 'perf report'. (Andi Kleen) - Add total time column to 'perf trace' syscall stats summary. (Milian Woff) Infrastructure changes: - PMU helpers to use in Intel PT. (Adrian Hunter) - Fix perf-with-kcore script not to split args with spaces. (Adrian Hunter) - Add empty Build files for some more architectures. (Ben Hutchings) - Move 'perf stat' config variables to a struct to allow using some of its functions in more places. (Jiri Olsa) - Add DWARF register names for 'xtensa' arch. (Max Filippov) - Implement BPF programs attached to uprobes. (Wang Nan) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
2 parents b6b6c18 + 141b2d3 commit 1354ac6

39 files changed

+716
-225
lines changed

include/linux/trace_events.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ enum {
243243
TRACE_EVENT_FL_USE_CALL_FILTER_BIT,
244244
TRACE_EVENT_FL_TRACEPOINT_BIT,
245245
TRACE_EVENT_FL_KPROBE_BIT,
246+
TRACE_EVENT_FL_UPROBE_BIT,
246247
};
247248

248249
/*
@@ -257,6 +258,7 @@ enum {
257258
* USE_CALL_FILTER - For trace internal events, don't use file filter
258259
* TRACEPOINT - Event is a tracepoint
259260
* KPROBE - Event is a kprobe
261+
* UPROBE - Event is a uprobe
260262
*/
261263
enum {
262264
TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT),
@@ -267,8 +269,11 @@ enum {
267269
TRACE_EVENT_FL_USE_CALL_FILTER = (1 << TRACE_EVENT_FL_USE_CALL_FILTER_BIT),
268270
TRACE_EVENT_FL_TRACEPOINT = (1 << TRACE_EVENT_FL_TRACEPOINT_BIT),
269271
TRACE_EVENT_FL_KPROBE = (1 << TRACE_EVENT_FL_KPROBE_BIT),
272+
TRACE_EVENT_FL_UPROBE = (1 << TRACE_EVENT_FL_UPROBE_BIT),
270273
};
271274

275+
#define TRACE_EVENT_FL_UKPROBE (TRACE_EVENT_FL_KPROBE | TRACE_EVENT_FL_UPROBE)
276+
272277
struct trace_event_call {
273278
struct list_head list;
274279
struct trace_event_class *class;
@@ -542,7 +547,7 @@ event_trigger_unlock_commit_regs(struct trace_event_file *file,
542547
event_triggers_post_call(file, tt);
543548
}
544549

545-
#ifdef CONFIG_BPF_SYSCALL
550+
#ifdef CONFIG_BPF_EVENTS
546551
unsigned int trace_call_bpf(struct bpf_prog *prog, void *ctx);
547552
#else
548553
static inline unsigned int trace_call_bpf(struct bpf_prog *prog, void *ctx)

kernel/events/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6846,8 +6846,8 @@ static int perf_event_set_bpf_prog(struct perf_event *event, u32 prog_fd)
68466846
if (event->tp_event->prog)
68476847
return -EEXIST;
68486848

6849-
if (!(event->tp_event->flags & TRACE_EVENT_FL_KPROBE))
6850-
/* bpf programs can only be attached to kprobes */
6849+
if (!(event->tp_event->flags & TRACE_EVENT_FL_UKPROBE))
6850+
/* bpf programs can only be attached to u/kprobes */
68516851
return -EINVAL;
68526852

68536853
prog = bpf_prog_get(prog_fd);

kernel/trace/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ config UPROBE_EVENT
434434

435435
config BPF_EVENTS
436436
depends on BPF_SYSCALL
437-
depends on KPROBE_EVENT
437+
depends on KPROBE_EVENT || UPROBE_EVENT
438438
bool
439439
default y
440440
help

kernel/trace/trace_uprobe.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,11 +1095,15 @@ static void __uprobe_perf_func(struct trace_uprobe *tu,
10951095
{
10961096
struct trace_event_call *call = &tu->tp.call;
10971097
struct uprobe_trace_entry_head *entry;
1098+
struct bpf_prog *prog = call->prog;
10981099
struct hlist_head *head;
10991100
void *data;
11001101
int size, esize;
11011102
int rctx;
11021103

1104+
if (prog && !trace_call_bpf(prog, regs))
1105+
return;
1106+
11031107
esize = SIZEOF_TRACE_ENTRY(is_ret_probe(tu));
11041108

11051109
size = esize + tu->tp.size + dsize;
@@ -1289,6 +1293,7 @@ static int register_uprobe_event(struct trace_uprobe *tu)
12891293
return -ENODEV;
12901294
}
12911295

1296+
call->flags = TRACE_EVENT_FL_UPROBE;
12921297
call->class->reg = trace_uprobe_register;
12931298
call->data = tu;
12941299
ret = trace_add_event_call(call);

tools/perf/Documentation/perf-report.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ OPTIONS
109109
- mispredict: "N" for predicted branch, "Y" for mispredicted branch
110110
- in_tx: branch in TSX transaction
111111
- abort: TSX transaction abort.
112+
- cycles: Cycles in basic block
112113

113114
And default sort keys are changed to comm, dso_from, symbol_from, dso_to
114115
and symbol_to, see '--branch-stack'.

tools/perf/Documentation/perf-top.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,27 @@ Default is to monitor all CPUS.
208208
This option sets the time out limit. The default value is 500 ms.
209209

210210

211+
-b::
212+
--branch-any::
213+
Enable taken branch stack sampling. Any type of taken branch may be sampled.
214+
This is a shortcut for --branch-filter any. See --branch-filter for more infos.
215+
216+
-j::
217+
--branch-filter::
218+
Enable taken branch stack sampling. Each sample captures a series of consecutive
219+
taken branches. The number of branches captured with each sample depends on the
220+
underlying hardware, the type of branches of interest, and the executed code.
221+
It is possible to select the types of branches captured by enabling filters.
222+
For a full list of modifiers please see the perf record manpage.
223+
224+
The option requires at least one branch type among any, any_call, any_ret, ind_call, cond.
225+
The privilege levels may be omitted, in which case, the privilege levels of the associated
226+
event are applied to the branch filter. Both kernel (k) and hypervisor (hv) privilege
227+
levels are subject to permissions. When sampling on multiple events, branch stack sampling
228+
is enabled for all the sampling events. The sampled branch type is the same for all events.
229+
The various filters must be specified as a comma separated list: --branch-filter any_ret,u,k
230+
Note that this feature may not be available on all processors.
231+
211232
INTERACTIVE PROMPTING KEYS
212233
--------------------------
213234

tools/perf/arch/alpha/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# empty

tools/perf/arch/mips/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# empty

tools/perf/arch/parisc/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# empty

tools/perf/arch/xtensa/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
libperf-y += util/

tools/perf/arch/xtensa/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ifndef NO_DWARF
2+
PERF_HAVE_DWARF_REGS := 1
3+
endif

tools/perf/arch/xtensa/util/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
libperf-$(CONFIG_DWARF) += dwarf-regs.o
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Mapping of DWARF debug register numbers into register names.
3+
*
4+
* Copyright (c) 2015 Cadence Design Systems Inc.
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU General Public License
8+
* as published by the Free Software Foundation; either version
9+
* 2 of the License, or (at your option) any later version.
10+
*/
11+
12+
#include <stddef.h>
13+
#include <dwarf-regs.h>
14+
15+
#define XTENSA_MAX_REGS 16
16+
17+
const char *xtensa_regs_table[XTENSA_MAX_REGS] = {
18+
"a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
19+
"a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15",
20+
};
21+
22+
const char *get_arch_regstr(unsigned int n)
23+
{
24+
return n < XTENSA_MAX_REGS ? xtensa_regs_table[n] : NULL;
25+
}

tools/perf/builtin-annotate.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ static void hists__find_annotations(struct hists *hists,
187187
* symbol, free he->ms.sym->src to signal we already
188188
* processed this symbol.
189189
*/
190+
zfree(&notes->src->cycles_hist);
190191
zfree(&notes->src);
191192
}
192193
}

tools/perf/builtin-report.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct report {
5353
bool mem_mode;
5454
bool header;
5555
bool header_only;
56+
bool nonany_branch_mode;
5657
int max_stack;
5758
struct perf_read_values show_threads_values;
5859
const char *pretty_printing_style;
@@ -102,6 +103,9 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,
102103
if (!ui__has_annotation())
103104
return 0;
104105

106+
hist__account_cycles(iter->sample->branch_stack, al, iter->sample,
107+
rep->nonany_branch_mode);
108+
105109
if (sort__mode == SORT_MODE__BRANCH) {
106110
bi = he->branch_info;
107111
err = addr_map_symbol__inc_samples(&bi->from, evsel->idx);
@@ -258,6 +262,12 @@ static int report__setup_sample_type(struct report *rep)
258262
else
259263
callchain_param.record_mode = CALLCHAIN_FP;
260264
}
265+
266+
/* ??? handle more cases than just ANY? */
267+
if (!(perf_evlist__combined_branch_type(session->evlist) &
268+
PERF_SAMPLE_BRANCH_ANY))
269+
rep->nonany_branch_mode = true;
270+
261271
return 0;
262272
}
263273

0 commit comments

Comments
 (0)