Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

User visible changes:

  - Make Ctrl-C stop processing on TUI, allowing interrupting the load of big
    perf.data files (Namhyung Kim)

  - Fix 'perf annotate' -i option, which is currently ignored (Martin Liška)

  - Add ARM64 perf_regs_load to support libunwind and enable testing (Wang Nan)

Infrastructure changes:

  - Fix thread ref-counting in db-export (Adrian Hunter)

  - Fix compiler warning about may be accessing uninitialized (Arnaldo Carvalho de Melo)

  - No need to have two lists for user and kernel DSOs, unify them (Arnaldo Carvalho de Melo)

  - Function namespace consistency fixups (Arnaldo Carvalho de Melo)

  - Do not fail on missing Build file, fixing the build on MIPS (Jiri Olsa)

  - Fix up syscall tests, making those tests pass on ARM64 (Riku Voipio)

  - Fix 'function unused' warning in 'perf probe' (Wang Nan)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Ingo Molnar committed May 29, 2015
2 parents f1942b9 + ed42691 commit 5c9b9bc
Show file tree
Hide file tree
Showing 34 changed files with 277 additions and 188 deletions.
2 changes: 1 addition & 1 deletion tools/build/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ subdir-obj-y :=

# Build definitions
build-file := $(dir)/Build
include $(build-file)
-include $(build-file)

quiet_cmd_flex = FLEX $@
quiet_cmd_bison = BISON $@
Expand Down
1 change: 1 addition & 0 deletions tools/build/tests/ex/Build
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ex-y += ex.o
ex-y += a.o
ex-y += b.o
ex-y += empty/
ex-y += empty2/

libex-y += c.o
libex-y += d.o
Expand Down
2 changes: 2 additions & 0 deletions tools/build/tests/ex/empty2/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This directory is left intentionally without Build file
to test proper nesting into Build-less directories.
1 change: 1 addition & 0 deletions tools/perf/arch/arm64/Build
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
libperf-y += util/
libperf-$(CONFIG_DWARF_UNWIND) += tests/
3 changes: 3 additions & 0 deletions tools/perf/arch/arm64/include/perf_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
#include <linux/types.h>
#include <asm/perf_regs.h>

void perf_regs_load(u64 *regs);

#define PERF_REGS_MASK ((1ULL << PERF_REG_ARM64_MAX) - 1)
#define PERF_REGS_MAX PERF_REG_ARM64_MAX
#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_64

#define PERF_REG_IP PERF_REG_ARM64_PC
#define PERF_REG_SP PERF_REG_ARM64_SP
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/arch/arm64/tests/Build
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
libperf-y += regs_load.o
libperf-y += dwarf-unwind.o
61 changes: 61 additions & 0 deletions tools/perf/arch/arm64/tests/dwarf-unwind.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <string.h>
#include "perf_regs.h"
#include "thread.h"
#include "map.h"
#include "event.h"
#include "debug.h"
#include "tests/tests.h"

#define STACK_SIZE 8192

static int sample_ustack(struct perf_sample *sample,
struct thread *thread, u64 *regs)
{
struct stack_dump *stack = &sample->user_stack;
struct map *map;
unsigned long sp;
u64 stack_size, *buf;

buf = malloc(STACK_SIZE);
if (!buf) {
pr_debug("failed to allocate sample uregs data\n");
return -1;
}

sp = (unsigned long) regs[PERF_REG_ARM64_SP];

map = map_groups__find(thread->mg, MAP__VARIABLE, (u64) sp);
if (!map) {
pr_debug("failed to get stack map\n");
free(buf);
return -1;
}

stack_size = map->end - sp;
stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;

memcpy(buf, (void *) sp, stack_size);
stack->data = (char *) buf;
stack->size = stack_size;
return 0;
}

int test__arch_unwind_sample(struct perf_sample *sample,
struct thread *thread)
{
struct regs_dump *regs = &sample->user_regs;
u64 *buf;

buf = calloc(1, sizeof(u64) * PERF_REGS_MAX);
if (!buf) {
pr_debug("failed to allocate sample uregs data\n");
return -1;
}

perf_regs_load(buf);
regs->abi = PERF_SAMPLE_REGS_ABI;
regs->regs = buf;
regs->mask = PERF_REGS_MASK;

return sample_ustack(sample, thread, buf);
}
46 changes: 46 additions & 0 deletions tools/perf/arch/arm64/tests/regs_load.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <linux/linkage.h>

.text
.type perf_regs_load,%function
#define STR_REG(r) str x##r, [x0, 8 * r]
#define LDR_REG(r) ldr x##r, [x0, 8 * r]
#define SP (8 * 31)
#define PC (8 * 32)
ENTRY(perf_regs_load)
STR_REG(0)
STR_REG(1)
STR_REG(2)
STR_REG(3)
STR_REG(4)
STR_REG(5)
STR_REG(6)
STR_REG(7)
STR_REG(8)
STR_REG(9)
STR_REG(10)
STR_REG(11)
STR_REG(12)
STR_REG(13)
STR_REG(14)
STR_REG(15)
STR_REG(16)
STR_REG(17)
STR_REG(18)
STR_REG(19)
STR_REG(20)
STR_REG(21)
STR_REG(22)
STR_REG(23)
STR_REG(24)
STR_REG(25)
STR_REG(26)
STR_REG(27)
STR_REG(28)
STR_REG(29)
STR_REG(30)
mov x1, sp
str x1, [x0, #SP]
str x30, [x0, #PC]
LDR_REG(1)
ret
ENDPROC(perf_regs_load)
3 changes: 2 additions & 1 deletion tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
},
};
struct perf_data_file file = {
.path = input_name,
.mode = PERF_DATA_MODE_READ,
};
const struct option options[] = {
Expand Down Expand Up @@ -346,6 +345,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
else if (annotate.use_gtk)
use_browser = 2;

file.path = input_name;

setup_browser(true);

annotate.session = perf_session__new(&file, false, &annotate.tool);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ static char *compact_gfp_flags(char *gfp_flags)
{
char *orig_flags = strdup(gfp_flags);
char *new_flags = NULL;
char *str, *pos;
char *str, *pos = NULL;
size_t len = 0;

if (orig_flags == NULL)
Expand Down
8 changes: 4 additions & 4 deletions tools/perf/tests/Build
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ perf-y += parse-events.o
perf-y += dso-data.o
perf-y += attr.o
perf-y += vmlinux-kallsyms.o
perf-y += open-syscall.o
perf-y += open-syscall-all-cpus.o
perf-y += open-syscall-tp-fields.o
perf-y += openat-syscall.o
perf-y += openat-syscall-all-cpus.o
perf-y += openat-syscall-tp-fields.o
perf-y += mmap-basic.o
perf-y += perf-record.o
perf-y += rdpmc.o
Expand Down Expand Up @@ -34,7 +34,7 @@ perf-y += kmod-path.o

perf-$(CONFIG_X86) += perf-time-to-tsc.o

ifeq ($(ARCH),$(filter $(ARCH),x86 arm))
ifeq ($(ARCH),$(filter $(ARCH),x86 arm arm64))
perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
endif

Expand Down
14 changes: 7 additions & 7 deletions tools/perf/tests/builtin-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ static struct test {
.func = test__vmlinux_matches_kallsyms,
},
{
.desc = "detect open syscall event",
.func = test__open_syscall_event,
.desc = "detect openat syscall event",
.func = test__openat_syscall_event,
},
{
.desc = "detect open syscall event on all cpus",
.func = test__open_syscall_event_on_all_cpus,
.desc = "detect openat syscall event on all cpus",
.func = test__openat_syscall_event_on_all_cpus,
},
{
.desc = "read samples using the mmap interface",
Expand Down Expand Up @@ -73,8 +73,8 @@ static struct test {
.func = test__perf_evsel__tp_sched_test,
},
{
.desc = "Generate and check syscalls:sys_enter_open event fields",
.func = test__syscall_open_tp_fields,
.desc = "Generate and check syscalls:sys_enter_openat event fields",
.func = test__syscall_openat_tp_fields,
},
{
.desc = "struct perf_event_attr setup",
Expand Down Expand Up @@ -126,7 +126,7 @@ static struct test {
.desc = "Test parsing with no sample_id_all bit set",
.func = test__parse_no_sample_id_all,
},
#if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)
#ifdef HAVE_DWARF_UNWIND_SUPPORT
{
.desc = "Test dwarf unwind",
Expand Down
3 changes: 1 addition & 2 deletions tools/perf/tests/hists_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ struct machine *setup_fake_machine(struct machines *machines)
size_t k;
struct dso *dso;

dso = __dsos__findnew(&machine->user_dsos,
fake_symbols[i].dso_name);
dso = machine__findnew_dso(machine, fake_symbols[i].dso_name);
if (dso == NULL)
goto out;

Expand Down
6 changes: 2 additions & 4 deletions tools/perf/tests/mmap-basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ int test__basic_mmap(void)
struct cpu_map *cpus;
struct perf_evlist *evlist;
cpu_set_t cpu_set;
const char *syscall_names[] = { "getsid", "getppid", "getpgrp",
"getpgid", };
pid_t (*syscalls[])(void) = { (void *)getsid, getppid, getpgrp,
(void*)getpgid };
const char *syscall_names[] = { "getsid", "getppid", "getpgid", };
pid_t (*syscalls[])(void) = { (void *)getsid, getppid, (void*)getpgid };
#define nsyscalls ARRAY_SIZE(syscall_names)
unsigned int nr_events[nsyscalls],
expected_nr_events[nsyscalls], i, j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#include "cpumap.h"
#include "debug.h"

int test__open_syscall_event_on_all_cpus(void)
int test__openat_syscall_event_on_all_cpus(void)
{
int err = -1, fd, cpu;
struct cpu_map *cpus;
struct perf_evsel *evsel;
unsigned int nr_open_calls = 111, i;
unsigned int nr_openat_calls = 111, i;
cpu_set_t cpu_set;
struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
char sbuf[STRERR_BUFSIZE];
Expand All @@ -27,7 +27,7 @@ int test__open_syscall_event_on_all_cpus(void)

CPU_ZERO(&cpu_set);

evsel = perf_evsel__newtp("syscalls", "sys_enter_open");
evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
if (evsel == NULL) {
if (tracefs_configured())
pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
Expand All @@ -46,7 +46,7 @@ int test__open_syscall_event_on_all_cpus(void)
}

for (cpu = 0; cpu < cpus->nr; ++cpu) {
unsigned int ncalls = nr_open_calls + cpu;
unsigned int ncalls = nr_openat_calls + cpu;
/*
* XXX eventually lift this restriction in a way that
* keeps perf building on older glibc installations
Expand All @@ -66,7 +66,7 @@ int test__open_syscall_event_on_all_cpus(void)
goto out_close_fd;
}
for (i = 0; i < ncalls; ++i) {
fd = open("/etc/passwd", O_RDONLY);
fd = openat(0, "/etc/passwd", O_RDONLY);
close(fd);
}
CPU_CLR(cpus->map[cpu], &cpu_set);
Expand Down Expand Up @@ -96,7 +96,7 @@ int test__open_syscall_event_on_all_cpus(void)
break;
}

expected = nr_open_calls + cpu;
expected = nr_openat_calls + cpu;
if (evsel->counts->cpu[cpu].val != expected) {
pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64 "\n",
expected, cpus->map[cpu], evsel->counts->cpu[cpu].val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "tests.h"
#include "debug.h"

int test__syscall_open_tp_fields(void)
int test__syscall_openat_tp_fields(void)
{
struct record_opts opts = {
.target = {
Expand All @@ -29,7 +29,7 @@ int test__syscall_open_tp_fields(void)
goto out;
}

evsel = perf_evsel__newtp("syscalls", "sys_enter_open");
evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
if (evsel == NULL) {
pr_debug("%s: perf_evsel__newtp\n", __func__);
goto out_delete_evlist;
Expand Down Expand Up @@ -66,7 +66,7 @@ int test__syscall_open_tp_fields(void)
/*
* Generate the event:
*/
open(filename, flags);
openat(AT_FDCWD, filename, flags);

while (1) {
int before = nr_events;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#include "debug.h"
#include "tests.h"

int test__open_syscall_event(void)
int test__openat_syscall_event(void)
{
int err = -1, fd;
struct perf_evsel *evsel;
unsigned int nr_open_calls = 111, i;
unsigned int nr_openat_calls = 111, i;
struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
char sbuf[STRERR_BUFSIZE];

Expand All @@ -16,7 +16,7 @@ int test__open_syscall_event(void)
return -1;
}

evsel = perf_evsel__newtp("syscalls", "sys_enter_open");
evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
if (evsel == NULL) {
if (tracefs_configured())
pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
Expand All @@ -34,8 +34,8 @@ int test__open_syscall_event(void)
goto out_evsel_delete;
}

for (i = 0; i < nr_open_calls; ++i) {
fd = open("/etc/passwd", O_RDONLY);
for (i = 0; i < nr_openat_calls; ++i) {
fd = openat(0, "/etc/passwd", O_RDONLY);
close(fd);
}

Expand All @@ -44,9 +44,9 @@ int test__open_syscall_event(void)
goto out_close_fd;
}

if (evsel->counts->cpu[0].val != nr_open_calls) {
if (evsel->counts->cpu[0].val != nr_openat_calls) {
pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls, got %" PRIu64 "\n",
nr_open_calls, evsel->counts->cpu[0].val);
nr_openat_calls, evsel->counts->cpu[0].val);
goto out_close_fd;
}

Expand Down
Loading

0 comments on commit 5c9b9bc

Please sign in to comment.