Skip to content

Commit e2cf00c

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo-4.11-20170126' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull the latest perf/core updates from Arnaldo Carvalho de Melo: New features: - Introduce 'perf ftrace' a perf front end to the kernel's ftrace function and function_graph tracer, defaulting to the "function_graph" tracer, more work will be done in reviving this effort, forward porting it from its initial patch submission (Namhyung Kim) - Add 'e' and 'c' hotkeys to expand/collapse call chains for a single hist entry in the 'perf report' and 'perf top' TUI (Jiri Olsa) Fixes: - Fix wrong register name for arm64, used in 'perf probe' (He Kuang) - Fix map offsets in relocation in libbpf (Joe Stringer) - Fix looking up dwarf unwind stack info (Matija Glavinic Pecotic) Infrastructure changes: - libbpf prog functions sync with what is exported via uapi (Joe Stringer) Trivial changes: - Remove unnecessary checks and assignments in 'perf probe's try_to_find_absolute_address() (Markus Elfring) Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents 47cd95a + ec34787 commit e2cf00c

22 files changed

+600
-96
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <fcntl.h>
2929
#include <errno.h>
3030
#include <asm/unistd.h>
31+
#include <linux/err.h>
3132
#include <linux/kernel.h>
3233
#include <linux/bpf.h>
3334
#include <linux/list.h>
@@ -779,7 +780,7 @@ static int
779780
bpf_program__collect_reloc(struct bpf_program *prog,
780781
size_t nr_maps, GElf_Shdr *shdr,
781782
Elf_Data *data, Elf_Data *symbols,
782-
int maps_shndx)
783+
int maps_shndx, struct bpf_map *maps)
783784
{
784785
int i, nrels;
785786

@@ -829,7 +830,15 @@ bpf_program__collect_reloc(struct bpf_program *prog,
829830
return -LIBBPF_ERRNO__RELOC;
830831
}
831832

832-
map_idx = sym.st_value / sizeof(struct bpf_map_def);
833+
/* TODO: 'maps' is sorted. We can use bsearch to make it faster. */
834+
for (map_idx = 0; map_idx < nr_maps; map_idx++) {
835+
if (maps[map_idx].offset == sym.st_value) {
836+
pr_debug("relocation: find map %zd (%s) for insn %u\n",
837+
map_idx, maps[map_idx].name, insn_idx);
838+
break;
839+
}
840+
}
841+
833842
if (map_idx >= nr_maps) {
834843
pr_warning("bpf relocation: map_idx %d large than %d\n",
835844
(int)map_idx, (int)nr_maps - 1);
@@ -953,7 +962,8 @@ static int bpf_object__collect_reloc(struct bpf_object *obj)
953962
err = bpf_program__collect_reloc(prog, nr_maps,
954963
shdr, data,
955964
obj->efile.symbols,
956-
obj->efile.maps_shndx);
965+
obj->efile.maps_shndx,
966+
obj->maps);
957967
if (err)
958968
return err;
959969
}
@@ -1419,37 +1429,33 @@ static void bpf_program__set_type(struct bpf_program *prog,
14191429
prog->type = type;
14201430
}
14211431

1422-
int bpf_program__set_tracepoint(struct bpf_program *prog)
1423-
{
1424-
if (!prog)
1425-
return -EINVAL;
1426-
bpf_program__set_type(prog, BPF_PROG_TYPE_TRACEPOINT);
1427-
return 0;
1428-
}
1429-
1430-
int bpf_program__set_kprobe(struct bpf_program *prog)
1431-
{
1432-
if (!prog)
1433-
return -EINVAL;
1434-
bpf_program__set_type(prog, BPF_PROG_TYPE_KPROBE);
1435-
return 0;
1436-
}
1437-
14381432
static bool bpf_program__is_type(struct bpf_program *prog,
14391433
enum bpf_prog_type type)
14401434
{
14411435
return prog ? (prog->type == type) : false;
14421436
}
14431437

1444-
bool bpf_program__is_tracepoint(struct bpf_program *prog)
1445-
{
1446-
return bpf_program__is_type(prog, BPF_PROG_TYPE_TRACEPOINT);
1447-
}
1448-
1449-
bool bpf_program__is_kprobe(struct bpf_program *prog)
1450-
{
1451-
return bpf_program__is_type(prog, BPF_PROG_TYPE_KPROBE);
1452-
}
1438+
#define BPF_PROG_TYPE_FNS(NAME, TYPE) \
1439+
int bpf_program__set_##NAME(struct bpf_program *prog) \
1440+
{ \
1441+
if (!prog) \
1442+
return -EINVAL; \
1443+
bpf_program__set_type(prog, TYPE); \
1444+
return 0; \
1445+
} \
1446+
\
1447+
bool bpf_program__is_##NAME(struct bpf_program *prog) \
1448+
{ \
1449+
return bpf_program__is_type(prog, TYPE); \
1450+
} \
1451+
1452+
BPF_PROG_TYPE_FNS(socket_filter, BPF_PROG_TYPE_SOCKET_FILTER);
1453+
BPF_PROG_TYPE_FNS(kprobe, BPF_PROG_TYPE_KPROBE);
1454+
BPF_PROG_TYPE_FNS(sched_cls, BPF_PROG_TYPE_SCHED_CLS);
1455+
BPF_PROG_TYPE_FNS(sched_act, BPF_PROG_TYPE_SCHED_ACT);
1456+
BPF_PROG_TYPE_FNS(tracepoint, BPF_PROG_TYPE_TRACEPOINT);
1457+
BPF_PROG_TYPE_FNS(xdp, BPF_PROG_TYPE_XDP);
1458+
BPF_PROG_TYPE_FNS(perf_event, BPF_PROG_TYPE_PERF_EVENT);
14531459

14541460
int bpf_map__fd(struct bpf_map *map)
14551461
{
@@ -1537,3 +1543,10 @@ bpf_object__find_map_by_offset(struct bpf_object *obj, size_t offset)
15371543
}
15381544
return ERR_PTR(-ENOENT);
15391545
}
1546+
1547+
long libbpf_get_error(const void *ptr)
1548+
{
1549+
if (IS_ERR(ptr))
1550+
return PTR_ERR(ptr);
1551+
return 0;
1552+
}

tools/lib/bpf/libbpf.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#define __BPF_LIBBPF_H
2323

2424
#include <stdio.h>
25+
#include <stdint.h>
2526
#include <stdbool.h>
26-
#include <linux/err.h>
2727
#include <sys/types.h> // for size_t
2828

2929
enum libbpf_errno {
@@ -174,11 +174,21 @@ int bpf_program__nth_fd(struct bpf_program *prog, int n);
174174
/*
175175
* Adjust type of bpf program. Default is kprobe.
176176
*/
177+
int bpf_program__set_socket_filter(struct bpf_program *prog);
177178
int bpf_program__set_tracepoint(struct bpf_program *prog);
178179
int bpf_program__set_kprobe(struct bpf_program *prog);
180+
int bpf_program__set_sched_cls(struct bpf_program *prog);
181+
int bpf_program__set_sched_act(struct bpf_program *prog);
182+
int bpf_program__set_xdp(struct bpf_program *prog);
183+
int bpf_program__set_perf_event(struct bpf_program *prog);
179184

185+
bool bpf_program__is_socket_filter(struct bpf_program *prog);
180186
bool bpf_program__is_tracepoint(struct bpf_program *prog);
181187
bool bpf_program__is_kprobe(struct bpf_program *prog);
188+
bool bpf_program__is_sched_cls(struct bpf_program *prog);
189+
bool bpf_program__is_sched_act(struct bpf_program *prog);
190+
bool bpf_program__is_xdp(struct bpf_program *prog);
191+
bool bpf_program__is_perf_event(struct bpf_program *prog);
182192

183193
/*
184194
* We don't need __attribute__((packed)) now since it is
@@ -224,4 +234,6 @@ int bpf_map__set_priv(struct bpf_map *map, void *priv,
224234
bpf_map_clear_priv_t clear_priv);
225235
void *bpf_map__priv(struct bpf_map *map);
226236

237+
long libbpf_get_error(const void *ptr);
238+
227239
#endif

tools/perf/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ perf-y += builtin-annotate.o
33
perf-y += builtin-config.o
44
perf-y += builtin-diff.o
55
perf-y += builtin-evlist.o
6+
perf-y += builtin-ftrace.o
67
perf-y += builtin-help.o
78
perf-y += builtin-sched.o
89
perf-y += builtin-buildid-list.o

tools/perf/Documentation/perf-c2c.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ output fields set for caheline offsets output:
248248
Code address, Code symbol, Shared Object, Source line
249249
dso - coalesced by shared object
250250

251-
By default the coalescing is setup with 'pid,tid,iaddr'.
251+
By default the coalescing is setup with 'pid,iaddr'.
252252

253253
STDIO OUTPUT
254254
------------
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
perf-ftrace(1)
2+
=============
3+
4+
NAME
5+
----
6+
perf-ftrace - simple wrapper for kernel's ftrace functionality
7+
8+
9+
SYNOPSIS
10+
--------
11+
[verse]
12+
'perf ftrace' <command>
13+
14+
DESCRIPTION
15+
-----------
16+
The 'perf ftrace' command is a simple wrapper of kernel's ftrace
17+
functionality. It only supports single thread tracing currently and
18+
just reads trace_pipe in text and then write it to stdout.
19+
20+
The following options apply to perf ftrace.
21+
22+
OPTIONS
23+
-------
24+
25+
-t::
26+
--tracer=::
27+
Tracer to use: function_graph or function.
28+
29+
-v::
30+
--verbose=::
31+
Verbosity level.
32+
33+
34+
SEE ALSO
35+
--------
36+
linkperf:perf-record[1], linkperf:perf-trace[1]

tools/perf/arch/arm64/include/dwarf-regs-table.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
/* This is included in perf/util/dwarf-regs.c */
33

44
static const char * const aarch64_regstr_tbl[] = {
5-
"%r0", "%r1", "%r2", "%r3", "%r4",
6-
"%r5", "%r6", "%r7", "%r8", "%r9",
7-
"%r10", "%r11", "%r12", "%r13", "%r14",
8-
"%r15", "%r16", "%r17", "%r18", "%r19",
9-
"%r20", "%r21", "%r22", "%r23", "%r24",
10-
"%r25", "%r26", "%r27", "%r28", "%r29",
5+
"%x0", "%x1", "%x2", "%x3", "%x4",
6+
"%x5", "%x6", "%x7", "%x8", "%x9",
7+
"%x10", "%x11", "%x12", "%x13", "%x14",
8+
"%x15", "%x16", "%x17", "%x18", "%x19",
9+
"%x20", "%x21", "%x22", "%x23", "%x24",
10+
"%x25", "%x26", "%x27", "%x28", "%x29",
1111
"%lr", "%sp",
1212
};
1313
#endif

tools/perf/builtin-c2c.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct c2c_hist_entry {
5858
struct hist_entry he;
5959
};
6060

61-
static char const *coalesce_default = "pid,tid,iaddr";
61+
static char const *coalesce_default = "pid,iaddr";
6262

6363
struct perf_c2c {
6464
struct perf_tool tool;
@@ -2476,6 +2476,7 @@ static int build_cl_output(char *cl_sort, bool no_source)
24762476
"mean_rmt,"
24772477
"mean_lcl,"
24782478
"mean_load,"
2479+
"tot_recs,"
24792480
"cpucnt,",
24802481
add_sym ? "symbol," : "",
24812482
add_dso ? "dso," : "",

0 commit comments

Comments
 (0)