#include #include #include #include "tests.h" #include "debug.h" #include "machine.h" #include "event.h" #include "unwind.h" #include "perf_regs.h" #include "map.h" #include "thread.h" #include "callchain.h" #if defined (__x86_64__) || defined (__i386__) || defined (__powerpc__) #include "arch-tests.h" #endif /* For bsearch. We try to unwind functions in shared object. */ #include static int mmap_handler(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) { return machine__process_mmap2_event(machine, event, sample); } static int init_live_machine(struct machine *machine) { union perf_event event; pid_t pid = getpid(); return perf_event__synthesize_mmap_events(NULL, &event, pid, pid, mmap_handler, machine, true, 500); } #define MAX_STACK 8 static int unwind_entry(struct unwind_entry *entry, void *arg) { unsigned long *cnt = (unsigned long *) arg; char *symbol = entry->sym ? entry->sym->name : NULL; static const char *funcs[MAX_STACK] = { "test__arch_unwind_sample", "unwind_thread", "compare", "bsearch", "krava_3", "krava_2", "krava_1", "test__dwarf_unwind" }; /* * The funcs[MAX_STACK] array index, based on the * callchain order setup. */ int idx = callchain_param.order == ORDER_CALLER ? MAX_STACK - *cnt - 1 : *cnt; if (*cnt >= MAX_STACK) { pr_debug("failed: crossed the max stack value %d\n", MAX_STACK); return -1; } if (!symbol) { pr_debug("failed: got unresolved address 0x%" PRIx64 "\n", entry->ip); return -1; } (*cnt)++; pr_debug("got: %s 0x%" PRIx64 ", expecting %s\n", symbol, entry->ip, funcs[idx]); return strcmp((const char *) symbol, funcs[idx]); } __attribute__ ((noinline)) static int unwind_thread(struct thread *thread) { struct perf_sample sample; unsigned long cnt = 0; int err = -1; memset(&sample, 0, sizeof(sample)); if (test__arch_unwind_sample(&sample, thread)) { pr_debug("failed to get unwind sample\n"); goto out; } err = unwind__get_entries(unwind_entry, &cnt, thread, &sample, MAX_STACK); if (err) pr_debug("unwind failed\n"); else if (cnt != MAX_STACK) { pr_debug("got wrong number of stack entries %lu != %d\n", cnt, MAX_STACK); err = -1; } out: free(sample.user_stack.data); free(sample.user_regs.regs); return err; } static int global_unwind_retval = -INT_MAX; __attribute__ ((noinline)) static int compare(void *p1, void *p2) { /* Any possible value should be 'thread' */ struct thread *thread = *(struct thread **)p1; if (global_unwind_retval == -INT_MAX) { /* Call unwinder twice for both callchain orders. */ callchain_param.order = ORDER_CALLER; global_unwind_retval = unwind_thread(thread); if (!global_unwind_retval) { callchain_param.order = ORDER_CALLEE; global_unwind_retval = unwind_thread(thread); } } return p1 - p2; } __attribute__ ((noinline)) static int krava_3(struct thread *thread) { struct thread *array[2] = {thread, thread}; void *fp = &bsearch; /* * make _bsearch a volatile function pointer to * prevent potential optimization, which may expand * bsearch and call compare directly from this function, * instead of libc shared object. */ void *(*volatile _bsearch)(void *, void *, size_t, size_t, int (*)(void *, void *)); _bsearch = fp; _bsearch(array, &thread, 2, sizeof(struct thread **), compare); return global_unwind_retval; } __attribute__ ((noinline)) static int krava_2(struct thread *thread) { return krava_3(thread); } __attribute__ ((noinline)) static int krava_1(struct thread *thread) { return krava_2(thread); } int test__dwarf_unwind(int subtest __maybe_unused) { struct machine *machine; struct thread *thread; int err = -1; machine = machine__new_host(); if (!machine) { pr_err("Could not get machine\n"); return -1; } if (machine__create_kernel_maps(machine)) { pr_err("Failed to create kernel maps\n"); return -1; } callchain_param.record_mode = CALLCHAIN_DWARF; if (init_live_machine(machine)) { pr_err("Could not init machine\n"); goto out; } if (verbose > 1) machine__fprintf(machine, stderr); thread = machine__find_thread(machine, getpid(), getpid()); if (!thread) { pr_err("Could not get thread\n"); goto out; } err = krava_1(thread); thread__put(thread); out: machine__delete_threads(machine); machine__delete(machine); return err; } >stat only
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-24 16:54:39 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-24 16:54:39 -0800
commit883af14e67e8b8702b5560aa64c888c0cd0bd66c (patch)
tree74e3a6b53f5fad9f7848ab1b9f6921b7012940a4 /include/trace/events/rxrpc.h
parent0263d4ebd94b36280608e296cba39b924b6e832b (diff)
parentaab45453ff5c77200c6da4ac909f7a4392aed17e (diff)
Merge branch 'akpm' (patches from Andrew)
Merge fixes from Andrew Morton: "26 fixes" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (26 commits) MAINTAINERS: add Dan Streetman to zbud maintainers MAINTAINERS: add Dan Streetman to zswap maintainers mm: do not export ioremap_page_range symbol for external module mn10300: fix build error of missing fpu_save() romfs: use different way to generate fsid for BLOCK or MTD frv: add missing atomic64 operations mm, page_alloc: fix premature OOM when racing with cpuset mems update mm, page_alloc: move cpuset seqcount checking to slowpath mm, page_alloc: fix fast-path race with cpuset update or removal mm, page_alloc: fix check for NULL preferred_zone kernel/panic.c: add missing \n fbdev: color map copying bounds checking frv: add atomic64_add_unless() mm/mempolicy.c: do not put mempolicy before using its nodemask radix-tree: fix private list warnings Documentation/filesystems/proc.txt: add VmPin mm, memcg: do not retry precharge charges proc: add a schedule point in proc_pid_readdir() mm: alloc_contig: re-allow CMA to compact FS pages mm/slub.c: trace free objects at KERN_INFO ...
Diffstat (limited to 'include/trace/events/rxrpc.h')