diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-02-09 13:09:49 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-02-09 13:09:49 -0500 |
| commit | 6f2a1c1e78771a78c1696f5a67e8320e76a8dc0b (patch) | |
| tree | 2cb86333c24239e8d1a674fdb74e1fc927453996 | |
| parent | 494479038d97f1b9f76fc633a360a681acdf035c (diff) | |
| parent | 2737fce8bc8dea2852289df29b4f92e6a7fb7c91 (diff) | |
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar:
"Tooling fixes, mostly related to the KASLR fallout, but also other
fixes"
* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
perf buildid-cache: Check relocation when checking for existing kcore
perf tools: Adjust kallsyms for relocated kernel
perf tests: No need to set up ref_reloc_sym
perf symbols: Prevent the use of kcore if the kernel has moved
perf record: Get ref_reloc_sym from kernel map
perf machine: Set up ref_reloc_sym in machine__create_kernel_maps()
perf machine: Add machine__get_kallsyms_filename()
perf tools: Add kallsyms__get_function_start()
perf symbols: Fix symbol annotation for relocated kernel
perf tools: Fix include for non x86 architectures
perf tools: Fix AAAAARGH64 memory barriers
perf tools: Demangle kernel and kernel module symbols too
perf/doc: Remove mention of non-existent set_perf_event_pending() from design.txt
| -rw-r--r-- | tools/perf/builtin-buildid-cache.c | 33 | ||||
| -rw-r--r-- | tools/perf/builtin-record.c | 10 | ||||
| -rw-r--r-- | tools/perf/design.txt | 1 | ||||
| -rw-r--r-- | tools/perf/perf.h | 4 | ||||
| -rw-r--r-- | tools/perf/tests/vmlinux-kallsyms.c | 10 | ||||
| -rw-r--r-- | tools/perf/util/event.c | 36 | ||||
| -rw-r--r-- | tools/perf/util/event.h | 6 | ||||
| -rw-r--r-- | tools/perf/util/include/asm/hash.h | 6 | ||||
| -rw-r--r-- | tools/perf/util/machine.c | 42 | ||||
| -rw-r--r-- | tools/perf/util/machine.h | 2 | ||||
| -rw-r--r-- | tools/perf/util/map.c | 5 | ||||
| -rw-r--r-- | tools/perf/util/map.h | 1 | ||||
| -rw-r--r-- | tools/perf/util/symbol-elf.c | 4 | ||||
| -rw-r--r-- | tools/perf/util/symbol.c | 65 |
14 files changed, 162 insertions, 63 deletions
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index cfede86161d8..b22dbb16f877 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c | |||
| @@ -63,11 +63,35 @@ static int build_id_cache__kcore_dir(char *dir, size_t sz) | |||
| 63 | return 0; | 63 | return 0; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | static bool same_kallsyms_reloc(const char *from_dir, char *to_dir) | ||
| 67 | { | ||
| 68 | char from[PATH_MAX]; | ||
| 69 | char to[PATH_MAX]; | ||
| 70 | const char *name; | ||
| 71 | u64 addr1 = 0, addr2 = 0; | ||
| 72 | int i; | ||
| 73 | |||
| 74 | scnprintf(from, sizeof(from), "%s/kallsyms", from_dir); | ||
| 75 | scnprintf(to, sizeof(to), "%s/kallsyms", to_dir); | ||
| 76 | |||
| 77 | for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) { | ||
| 78 | addr1 = kallsyms__get_function_start(from, name); | ||
| 79 | if (addr1) | ||
| 80 | break; | ||
| 81 | } | ||
| 82 | |||
| 83 | if (name) | ||
| 84 | addr2 = kallsyms__get_function_start(to, name); | ||
| 85 | |||
| 86 | return addr1 == addr2; | ||
| 87 | } | ||
| 88 | |||
| 66 | static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir, | 89 | static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir, |
| 67 | size_t to_dir_sz) | 90 | size_t to_dir_sz) |
| 68 | { | 91 | { |
| 69 | char from[PATH_MAX]; | 92 | char from[PATH_MAX]; |
| 70 | char to[PATH_MAX]; | 93 | char to[PATH_MAX]; |
| 94 | char to_subdir[PATH_MAX]; | ||
| 71 | struct dirent *dent; | 95 | struct dirent *dent; |
| 72 | int ret = -1; | 96 | int ret = -1; |
| 73 | DIR *d; | 97 | DIR *d; |
| @@ -86,10 +110,11 @@ static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir, | |||
| 86 | continue; | 110 | continue; |
| 87 | scnprintf(to, sizeof(to), "%s/%s/modules", to_dir, | 111 | scnprintf(to, sizeof(to), "%s/%s/modules", to_dir, |
| 88 | dent->d_name); | 112 | dent->d_name); |
| 89 | if (!compare_proc_modules(from, to)) { | 113 | scnprintf(to_subdir, sizeof(to_subdir), "%s/%s", |
| 90 | scnprintf(to, sizeof(to), "%s/%s", to_dir, | 114 | to_dir, dent->d_name); |
| 91 | dent->d_name); | 115 | if (!compare_proc_modules(from, to) && |
| 92 | strlcpy(to_dir, to, to_dir_sz); | 116 | same_kallsyms_reloc(from_dir, to_subdir)) { |
| 117 | strlcpy(to_dir, to_subdir, to_dir_sz); | ||
| 93 | ret = 0; | 118 | ret = 0; |
| 94 | break; | 119 | break; |
| 95 | } | 120 | } |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 3c394bf16fa8..af47531b82ec 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
| @@ -287,10 +287,7 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data) | |||
| 287 | * have no _text sometimes. | 287 | * have no _text sometimes. |
| 288 | */ | 288 | */ |
| 289 | err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event, | 289 | err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event, |
| 290 | machine, "_text"); | 290 | machine); |
| 291 | if (err < 0) | ||
| 292 | err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event, | ||
| 293 | machine, "_stext"); | ||
| 294 | if (err < 0) | 291 | if (err < 0) |
| 295 | pr_err("Couldn't record guest kernel [%d]'s reference" | 292 | pr_err("Couldn't record guest kernel [%d]'s reference" |
| 296 | " relocation symbol.\n", machine->pid); | 293 | " relocation symbol.\n", machine->pid); |
| @@ -457,10 +454,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) | |||
| 457 | } | 454 | } |
| 458 | 455 | ||
| 459 | err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event, | 456 | err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event, |
| 460 | machine, "_text"); | 457 | machine); |
| 461 | if (err < 0) | ||
| 462 | err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event, | ||
| 463 | machine, "_stext"); | ||
| 464 | if (err < 0) | 458 | if (err < 0) |
| 465 | pr_err("Couldn't record kernel reference relocation symbol\n" | 459 | pr_err("Couldn't record kernel reference relocation symbol\n" |
| 466 | "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" | 460 | "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" |
diff --git a/tools/perf/design.txt b/tools/perf/design.txt index 67e5d0cace85..63a0e6f04a01 100644 --- a/tools/perf/design.txt +++ b/tools/perf/design.txt | |||
| @@ -454,7 +454,6 @@ So to start with, in order to add HAVE_PERF_EVENTS to your Kconfig, you | |||
| 454 | will need at least this: | 454 | will need at least this: |
| 455 | - asm/perf_event.h - a basic stub will suffice at first | 455 | - asm/perf_event.h - a basic stub will suffice at first |
| 456 | - support for atomic64 types (and associated helper functions) | 456 | - support for atomic64 types (and associated helper functions) |
| 457 | - set_perf_event_pending() implemented | ||
| 458 | 457 | ||
| 459 | If your architecture does have hardware capabilities, you can override the | 458 | If your architecture does have hardware capabilities, you can override the |
| 460 | weak stub hw_perf_event_init() to register hardware counters. | 459 | weak stub hw_perf_event_init() to register hardware counters. |
diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 7daa806d9050..e84fa26bc1be 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h | |||
| @@ -100,8 +100,8 @@ | |||
| 100 | 100 | ||
| 101 | #ifdef __aarch64__ | 101 | #ifdef __aarch64__ |
| 102 | #define mb() asm volatile("dmb ish" ::: "memory") | 102 | #define mb() asm volatile("dmb ish" ::: "memory") |
| 103 | #define wmb() asm volatile("dmb ishld" ::: "memory") | 103 | #define wmb() asm volatile("dmb ishst" ::: "memory") |
| 104 | #define rmb() asm volatile("dmb ishst" ::: "memory") | 104 | #define rmb() asm volatile("dmb ishld" ::: "memory") |
| 105 | #define cpu_relax() asm volatile("yield" ::: "memory") | 105 | #define cpu_relax() asm volatile("yield" ::: "memory") |
| 106 | #endif | 106 | #endif |
| 107 | 107 | ||
diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c index 2bd13edcbc17..3d9088003a5b 100644 --- a/tools/perf/tests/vmlinux-kallsyms.c +++ b/tools/perf/tests/vmlinux-kallsyms.c | |||
| @@ -26,7 +26,6 @@ int test__vmlinux_matches_kallsyms(void) | |||
| 26 | struct map *kallsyms_map, *vmlinux_map; | 26 | struct map *kallsyms_map, *vmlinux_map; |
| 27 | struct machine kallsyms, vmlinux; | 27 | struct machine kallsyms, vmlinux; |
| 28 | enum map_type type = MAP__FUNCTION; | 28 | enum map_type type = MAP__FUNCTION; |
| 29 | struct ref_reloc_sym ref_reloc_sym = { .name = "_stext", }; | ||
| 30 | u64 mem_start, mem_end; | 29 | u64 mem_start, mem_end; |
| 31 | 30 | ||
| 32 | /* | 31 | /* |
| @@ -70,14 +69,6 @@ int test__vmlinux_matches_kallsyms(void) | |||
| 70 | */ | 69 | */ |
| 71 | kallsyms_map = machine__kernel_map(&kallsyms, type); | 70 | kallsyms_map = machine__kernel_map(&kallsyms, type); |
| 72 | 71 | ||
| 73 | sym = map__find_symbol_by_name(kallsyms_map, ref_reloc_sym.name, NULL); | ||
| 74 | if (sym == NULL) { | ||
| 75 | pr_debug("dso__find_symbol_by_name "); | ||
| 76 | goto out; | ||
| 77 | } | ||
| 78 | |||
| 79 | ref_reloc_sym.addr = UM(sym->start); | ||
| 80 | |||
| 81 | /* | 72 | /* |
| 82 | * Step 5: | 73 | * Step 5: |
| 83 | * | 74 | * |
| @@ -89,7 +80,6 @@ int test__vmlinux_matches_kallsyms(void) | |||
| 89 | } | 80 | } |
| 90 | 81 | ||
| 91 | vmlinux_map = machine__kernel_map(&vmlinux, type); | 82 | vmlinux_map = machine__kernel_map(&vmlinux, type); |
| 92 | map__kmap(vmlinux_map)->ref_reloc_sym = &ref_reloc_sym; | ||
| 93 | 83 | ||
| 94 | /* | 84 | /* |
| 95 | * Step 6: | 85 | * Step 6: |
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 1fc1c2f04772..b0f3ca850e9e 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
| @@ -470,23 +470,32 @@ static int find_symbol_cb(void *arg, const char *name, char type, | |||
| 470 | return 1; | 470 | return 1; |
| 471 | } | 471 | } |
| 472 | 472 | ||
