Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo-4.11-20170126' of git://git.kernel.org…
Browse files Browse the repository at this point in the history
…/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]>
  • Loading branch information
Ingo Molnar committed Jan 26, 2017
2 parents 47cd95a + ec34787 commit e2cf00c
Show file tree
Hide file tree
Showing 22 changed files with 600 additions and 96 deletions.
69 changes: 41 additions & 28 deletions tools/lib/bpf/libbpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <fcntl.h>
#include <errno.h>
#include <asm/unistd.h>
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/bpf.h>
#include <linux/list.h>
Expand Down Expand Up @@ -779,7 +780,7 @@ static int
bpf_program__collect_reloc(struct bpf_program *prog,
size_t nr_maps, GElf_Shdr *shdr,
Elf_Data *data, Elf_Data *symbols,
int maps_shndx)
int maps_shndx, struct bpf_map *maps)
{
int i, nrels;

Expand Down Expand Up @@ -829,7 +830,15 @@ bpf_program__collect_reloc(struct bpf_program *prog,
return -LIBBPF_ERRNO__RELOC;
}

map_idx = sym.st_value / sizeof(struct bpf_map_def);
/* TODO: 'maps' is sorted. We can use bsearch to make it faster. */
for (map_idx = 0; map_idx < nr_maps; map_idx++) {
if (maps[map_idx].offset == sym.st_value) {
pr_debug("relocation: find map %zd (%s) for insn %u\n",
map_idx, maps[map_idx].name, insn_idx);
break;
}
}

if (map_idx >= nr_maps) {
pr_warning("bpf relocation: map_idx %d large than %d\n",
(int)map_idx, (int)nr_maps - 1);
Expand Down Expand Up @@ -953,7 +962,8 @@ static int bpf_object__collect_reloc(struct bpf_object *obj)
err = bpf_program__collect_reloc(prog, nr_maps,
shdr, data,
obj->efile.symbols,
obj->efile.maps_shndx);
obj->efile.maps_shndx,
obj->maps);
if (err)
return err;
}
Expand Down Expand Up @@ -1419,37 +1429,33 @@ static void bpf_program__set_type(struct bpf_program *prog,
prog->type = type;
}

int bpf_program__set_tracepoint(struct bpf_program *prog)
{
if (!prog)
return -EINVAL;
bpf_program__set_type(prog, BPF_PROG_TYPE_TRACEPOINT);
return 0;
}

int bpf_program__set_kprobe(struct bpf_program *prog)
{
if (!prog)
return -EINVAL;
bpf_program__set_type(prog, BPF_PROG_TYPE_KPROBE);
return 0;
}

static bool bpf_program__is_type(struct bpf_program *prog,
enum bpf_prog_type type)
{
return prog ? (prog->type == type) : false;
}

bool bpf_program__is_tracepoint(struct bpf_program *prog)
{
return bpf_program__is_type(prog, BPF_PROG_TYPE_TRACEPOINT);
}

bool bpf_program__is_kprobe(struct bpf_program *prog)
{
return bpf_program__is_type(prog, BPF_PROG_TYPE_KPROBE);
}
#define BPF_PROG_TYPE_FNS(NAME, TYPE) \
int bpf_program__set_##NAME(struct bpf_program *prog) \
{ \
if (!prog) \
return -EINVAL; \
bpf_program__set_type(prog, TYPE); \
return 0; \
} \
\
bool bpf_program__is_##NAME(struct bpf_program *prog) \
{ \
return bpf_program__is_type(prog, TYPE); \
} \

BPF_PROG_TYPE_FNS(socket_filter, BPF_PROG_TYPE_SOCKET_FILTER);
BPF_PROG_TYPE_FNS(kprobe, BPF_PROG_TYPE_KPROBE);
BPF_PROG_TYPE_FNS(sched_cls, BPF_PROG_TYPE_SCHED_CLS);
BPF_PROG_TYPE_FNS(sched_act, BPF_PROG_TYPE_SCHED_ACT);
BPF_PROG_TYPE_FNS(tracepoint, BPF_PROG_TYPE_TRACEPOINT);
BPF_PROG_TYPE_FNS(xdp, BPF_PROG_TYPE_XDP);
BPF_PROG_TYPE_FNS(perf_event, BPF_PROG_TYPE_PERF_EVENT);

int bpf_map__fd(struct bpf_map *map)
{
Expand Down Expand Up @@ -1537,3 +1543,10 @@ bpf_object__find_map_by_offset(struct bpf_object *obj, size_t offset)
}
return ERR_PTR(-ENOENT);
}

long libbpf_get_error(const void *ptr)
{
if (IS_ERR(ptr))
return PTR_ERR(ptr);
return 0;
}
14 changes: 13 additions & 1 deletion tools/lib/bpf/libbpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#define __BPF_LIBBPF_H

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <linux/err.h>
#include <sys/types.h> // for size_t

enum libbpf_errno {
Expand Down Expand Up @@ -174,11 +174,21 @@ int bpf_program__nth_fd(struct bpf_program *prog, int n);
/*
* Adjust type of bpf program. Default is kprobe.
*/
int bpf_program__set_socket_filter(struct bpf_program *prog);
int bpf_program__set_tracepoint(struct bpf_program *prog);
int bpf_program__set_kprobe(struct bpf_program *prog);
int bpf_program__set_sched_cls(struct bpf_program *prog);
int bpf_program__set_sched_act(struct bpf_program *prog);
int bpf_program__set_xdp(struct bpf_program *prog);
int bpf_program__set_perf_event(struct bpf_program *prog);

bool bpf_program__is_socket_filter(struct bpf_program *prog);
bool bpf_program__is_tracepoint(struct bpf_program *prog);
bool bpf_program__is_kprobe(struct bpf_program *prog);
bool bpf_program__is_sched_cls(struct bpf_program *prog);
bool bpf_program__is_sched_act(struct bpf_program *prog);
bool bpf_program__is_xdp(struct bpf_program *prog);
bool bpf_program__is_perf_event(struct bpf_program *prog);

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

long libbpf_get_error(const void *ptr);

#endif
1 change: 1 addition & 0 deletions tools/perf/Build
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ perf-y += builtin-annotate.o
perf-y += builtin-config.o
perf-y += builtin-diff.o
perf-y += builtin-evlist.o
perf-y += builtin-ftrace.o
perf-y += builtin-help.o
perf-y += builtin-sched.o
perf-y += builtin-buildid-list.o
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/Documentation/perf-c2c.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ output fields set for caheline offsets output:
Code address, Code symbol, Shared Object, Source line
dso - coalesced by shared object

By default the coalescing is setup with 'pid,tid,iaddr'.
By default the coalescing is setup with 'pid,iaddr'.

STDIO OUTPUT
------------
Expand Down
36 changes: 36 additions & 0 deletions tools/perf/Documentation/perf-ftrace.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
perf-ftrace(1)
=============

NAME
----
perf-ftrace - simple wrapper for kernel's ftrace functionality


SYNOPSIS
--------
[verse]
'perf ftrace' <command>

DESCRIPTION
-----------
The 'perf ftrace' command is a simple wrapper of kernel's ftrace
functionality. It only supports single thread tracing currently and
just reads trace_pipe in text and then write it to stdout.

The following options apply to perf ftrace.

OPTIONS
-------

-t::
--tracer=::
Tracer to use: function_graph or function.

-v::
--verbose=::
Verbosity level.


SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-trace[1]
12 changes: 6 additions & 6 deletions tools/perf/arch/arm64/include/dwarf-regs-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
/* This is included in perf/util/dwarf-regs.c */

static const char * const aarch64_regstr_tbl[] = {
"%r0", "%r1", "%r2", "%r3", "%r4",
"%r5", "%r6", "%r7", "%r8", "%r9",
"%r10", "%r11", "%r12", "%r13", "%r14",
"%r15", "%r16", "%r17", "%r18", "%r19",
"%r20", "%r21", "%r22", "%r23", "%r24",
"%r25", "%r26", "%r27", "%r28", "%r29",
"%x0", "%x1", "%x2", "%x3", "%x4",
"%x5", "%x6", "%x7", "%x8", "%x9",
"%x10", "%x11", "%x12", "%x13", "%x14",
"%x15", "%x16", "%x17", "%x18", "%x19",
"%x20", "%x21", "%x22", "%x23", "%x24",
"%x25", "%x26", "%x27", "%x28", "%x29",
"%lr", "%sp",
};
#endif
3 changes: 2 additions & 1 deletion tools/perf/builtin-c2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct c2c_hist_entry {
struct hist_entry he;
};

static char const *coalesce_default = "pid,tid,iaddr";
static char const *coalesce_default = "pid,iaddr";

struct perf_c2c {
struct perf_tool tool;
Expand Down Expand Up @@ -2476,6 +2476,7 @@ static int build_cl_output(char *cl_sort, bool no_source)
"mean_rmt,"
"mean_lcl,"
"mean_load,"
"tot_recs,"
"cpucnt,",
add_sym ? "symbol," : "",
add_dso ? "dso," : "",
Expand Down
Loading

0 comments on commit e2cf00c

Please sign in to comment.