diff options
author | Ingo Molnar <mingo@kernel.org> | 2016-12-02 10:08:03 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-12-02 10:08:03 +0100 |
commit | e7af7b15121ca08c31a0ab9df71a41b4c53365b4 (patch) | |
tree | 3c4ee7bd52c8cc41642efee0b5549b573d69268a /tools/perf/tests/perf-hooks.c | |
parent | 3782746a08f6b0a8e385058b6748a5a0f166f3a7 (diff) | |
parent | 0fcb1da4aba6e6c7b32de5e0948b740b31ad822d (diff) |
Merge tag 'perf-core-for-mingo-20161201' 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:
New features:
- Support AArch64 in the 'annotate' code, native/local and
cross-arch/remote (Kim Phillips)
- Allow considering just events in a given time interval, via the
'--time start.s.ms,end.s.ms' command line, added to 'perf kmem',
'perf report', 'perf sched timehist' and 'perf script' (David Ahern)
- Add option to stop printing a callchain at one of a given group of
symbol names (David Ahern)
- Handle CPU migration events in 'perf sched timehist' (David Ahern)
- Track memory freed in 'perf kmem stat' (David Ahern)
Infrastructure:
- Add initial support (and perf test entry) for tooling hooks, starting with
'record_start' and 'record_end', that will have as its initial user the
eBPF infrastructure, where perf_ prefixed functions will be JITed and
run when such hooks are called (Wang Nan)
- Remove redundant "test" and similar strings from 'perf test' descriptions
(Arnaldo Carvalho de Melo)
- Implement assorted libbpf improvements (Wang Nan)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/tests/perf-hooks.c')
-rw-r--r-- | tools/perf/tests/perf-hooks.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/perf/tests/perf-hooks.c b/tools/perf/tests/perf-hooks.c new file mode 100644 index 000000000000..9338cb2c25ab --- /dev/null +++ b/tools/perf/tests/perf-hooks.c @@ -0,0 +1,44 @@ +#include <signal.h> +#include <stdlib.h> + +#include "tests.h" +#include "debug.h" +#include "util.h" +#include "perf-hooks.h" + +static void sigsegv_handler(int sig __maybe_unused) +{ + pr_debug("SIGSEGV is observed as expected, try to recover.\n"); + perf_hooks__recover(); + signal(SIGSEGV, SIG_DFL); + raise(SIGSEGV); + exit(-1); +} + +static int hook_flags; + +static void the_hook(void) +{ + int *p = NULL; + + hook_flags = 1234; + + /* Generate a segfault, test perf_hooks__recover */ + *p = 0; +} + +int test__perf_hooks(int subtest __maybe_unused) +{ + signal(SIGSEGV, sigsegv_handler); + perf_hooks__set_hook("test", the_hook); + perf_hooks__invoke_test(); + + /* hook is triggered? */ + if (hook_flags != 1234) + return TEST_FAIL; + + /* the buggy hook is removed? */ + if (perf_hooks__get_hook("test")) + return TEST_FAIL; + return TEST_OK; +} |