Merge branches 'perf-fixes-for-linus' and 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
perf probe: Fix to support libdwfl older than 0.148
perf tools: Fix lazy wildcard matching
perf buildid-list: Fix error return for success
perf buildid-cache: Fix symbolic link handling
perf symbols: Stop using vmlinux files with no symbols
perf probe: Fix use of kernel image path given by 'k' option

* 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
x86, kexec: Limit the crashkernel address appropriately

+98 -45
+14 -3
arch/x86/kernel/setup.c
··· 501 501 return total << PAGE_SHIFT; 502 502 } 503 503 504 - #define DEFAULT_BZIMAGE_ADDR_MAX 0x37FFFFFF 504 + /* 505 + * Keep the crash kernel below this limit. On 32 bits earlier kernels 506 + * would limit the kernel to the low 512 MiB due to mapping restrictions. 507 + * On 64 bits, kexec-tools currently limits us to 896 MiB; increase this 508 + * limit once kexec-tools are fixed. 509 + */ 510 + #ifdef CONFIG_X86_32 511 + # define CRASH_KERNEL_ADDR_MAX (512 << 20) 512 + #else 513 + # define CRASH_KERNEL_ADDR_MAX (896 << 20) 514 + #endif 515 + 505 516 static void __init reserve_crashkernel(void) 506 517 { 507 518 unsigned long long total_mem; ··· 531 520 const unsigned long long alignment = 16<<20; /* 16M */ 532 521 533 522 /* 534 - * kexec want bzImage is below DEFAULT_BZIMAGE_ADDR_MAX 523 + * kexec want bzImage is below CRASH_KERNEL_ADDR_MAX 535 524 */ 536 525 crash_base = memblock_find_in_range(alignment, 537 - DEFAULT_BZIMAGE_ADDR_MAX, crash_size, alignment); 526 + CRASH_KERNEL_ADDR_MAX, crash_size, alignment); 538 527 539 528 if (crash_base == MEMBLOCK_ERROR) { 540 529 pr_info("crashkernel reservation failed - No suitable area found.\n");
+1 -2
tools/perf/builtin-buildid-list.c
··· 36 36 37 37 static int __cmd_buildid_list(void) 38 38 { 39 - int err = -1; 40 39 struct perf_session *session; 41 40 42 41 session = perf_session__new(input_name, O_RDONLY, force, false); ··· 48 49 perf_session__fprintf_dsos_buildid(session, stdout, with_hits); 49 50 50 51 perf_session__delete(session); 51 - return err; 52 + return 0; 52 53 } 53 54 54 55 int cmd_buildid_list(int argc, const char **argv, const char *prefix __used)
+5
tools/perf/builtin-probe.c
··· 249 249 !params.show_lines)) 250 250 usage_with_options(probe_usage, options); 251 251 252 + /* 253 + * Only consider the user's kernel image path if given. 254 + */ 255 + symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL); 256 + 252 257 if (params.list_events) { 253 258 if (params.mod_events) { 254 259 pr_err(" Error: Don't use --list with --add/--del.\n");
+6 -4
tools/perf/util/header.c
··· 265 265 const char *name, bool is_kallsyms) 266 266 { 267 267 const size_t size = PATH_MAX; 268 - char *filename = malloc(size), 268 + char *realname = realpath(name, NULL), 269 + *filename = malloc(size), 269 270 *linkname = malloc(size), *targetname; 270 271 int len, err = -1; 271 272 272 - if (filename == NULL || linkname == NULL) 273 + if (realname == NULL || filename == NULL || linkname == NULL) 273 274 goto out_free; 274 275 275 276 len = snprintf(filename, size, "%s%s%s", 276 - debugdir, is_kallsyms ? "/" : "", name); 277 + debugdir, is_kallsyms ? "/" : "", realname); 277 278 if (mkdir_p(filename, 0755)) 278 279 goto out_free; 279 280 ··· 284 283 if (is_kallsyms) { 285 284 if (copyfile("/proc/kallsyms", filename)) 286 285 goto out_free; 287 - } else if (link(name, filename) && copyfile(name, filename)) 286 + } else if (link(realname, filename) && copyfile(name, filename)) 288 287 goto out_free; 289 288 } 290 289 ··· 301 300 if (symlink(targetname, linkname) == 0) 302 301 err = 0; 303 302 out_free: 303 + free(realname); 304 304 free(filename); 305 305 free(linkname); 306 306 return err;
+12 -3
tools/perf/util/probe-event.c
··· 114 114 const char *kernel_get_module_path(const char *module) 115 115 { 116 116 struct dso *dso; 117 + struct map *map; 118 + const char *vmlinux_name; 117 119 118 120 if (module) { 119 121 list_for_each_entry(dso, &machine.kernel_dsos, node) { ··· 125 123 } 126 124 pr_debug("Failed to find module %s.\n", module); 127 125 return NULL; 126 + } 127 + 128 + map = machine.vmlinux_maps[MAP__FUNCTION]; 129 + dso = map->dso; 130 + 131 + vmlinux_name = symbol_conf.vmlinux_name; 132 + if (vmlinux_name) { 133 + if (dso__load_vmlinux(dso, map, vmlinux_name, NULL) <= 0) 134 + return NULL; 128 135 } else { 129 - dso = machine.vmlinux_maps[MAP__FUNCTION]->dso; 130 - if (dso__load_vmlinux_path(dso, 131 - machine.vmlinux_maps[MAP__FUNCTION], NULL) < 0) { 136 + if (dso__load_vmlinux_path(dso, map, NULL) <= 0) { 132 137 pr_debug("Failed to load kernel map.\n"); 133 138 return NULL; 134 139 }
+55 -30
tools/perf/util/probe-finder.c
··· 117 117 } 118 118 119 119 /* Dwarf FL wrappers */ 120 - 121 - static int __linux_kernel_find_elf(Dwfl_Module *mod, 122 - void **userdata, 123 - const char *module_name, 124 - Dwarf_Addr base, 125 - char **file_name, Elf **elfp) 126 - { 127 - int fd; 128 - const char *path = kernel_get_module_path(module_name); 129 - 130 - if (path) { 131 - fd = open(path, O_RDONLY); 132 - if (fd >= 0) { 133 - *file_name = strdup(path); 134 - return fd; 135 - } 136 - } 137 - /* If failed, try to call standard method */ 138 - return dwfl_linux_kernel_find_elf(mod, userdata, module_name, base, 139 - file_name, elfp); 140 - } 141 - 142 120 static char *debuginfo_path; /* Currently dummy */ 143 121 144 122 static const Dwfl_Callbacks offline_callbacks = { ··· 127 149 128 150 /* We use this table for core files too. */ 129 151 .find_elf = dwfl_build_id_find_elf, 130 - }; 131 - 132 - static const Dwfl_Callbacks kernel_callbacks = { 133 - .find_debuginfo = dwfl_standard_find_debuginfo, 134 - .debuginfo_path = &debuginfo_path, 135 - 136 - .find_elf = __linux_kernel_find_elf, 137 - .section_address = dwfl_linux_kernel_module_section_address, 138 152 }; 139 153 140 154 /* Get a Dwarf from offline image */ ··· 155 185 return dbg; 156 186 } 157 187 188 + #if _ELFUTILS_PREREQ(0, 148) 189 + /* This method is buggy if elfutils is older than 0.148 */ 190 + static int __linux_kernel_find_elf(Dwfl_Module *mod, 191 + void **userdata, 192 + const char *module_name, 193 + Dwarf_Addr base, 194 + char **file_name, Elf **elfp) 195 + { 196 + int fd; 197 + const char *path = kernel_get_module_path(module_name); 198 + 199 + pr_debug2("Use file %s for %s\n", path, module_name); 200 + if (path) { 201 + fd = open(path, O_RDONLY); 202 + if (fd >= 0) { 203 + *file_name = strdup(path); 204 + return fd; 205 + } 206 + } 207 + /* If failed, try to call standard method */ 208 + return dwfl_linux_kernel_find_elf(mod, userdata, module_name, base, 209 + file_name, elfp); 210 + } 211 + 212 + static const Dwfl_Callbacks kernel_callbacks = { 213 + .find_debuginfo = dwfl_standard_find_debuginfo, 214 + .debuginfo_path = &debuginfo_path, 215 + 216 + .find_elf = __linux_kernel_find_elf, 217 + .section_address = dwfl_linux_kernel_module_section_address, 218 + }; 219 + 158 220 /* Get a Dwarf from live kernel image */ 159 221 static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr, Dwfl **dwflp, 160 222 Dwarf_Addr *bias) ··· 207 205 dbg = dwfl_addrdwarf(*dwflp, addr, bias); 208 206 /* Here, check whether we could get a real dwarf */ 209 207 if (!dbg) { 208 + pr_debug("Failed to find kernel dwarf at %lx\n", 209 + (unsigned long)addr); 210 210 dwfl_end(*dwflp); 211 211 *dwflp = NULL; 212 212 } 213 213 return dbg; 214 214 } 215 + #else 216 + /* With older elfutils, this just support kernel module... */ 217 + static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr __used, Dwfl **dwflp, 218 + Dwarf_Addr *bias) 219 + { 220 + int fd; 221 + const char *path = kernel_get_module_path("kernel"); 222 + 223 + if (!path) { 224 + pr_err("Failed to find vmlinux path\n"); 225 + return NULL; 226 + } 227 + 228 + pr_debug2("Use file %s for debuginfo\n", path); 229 + fd = open(path, O_RDONLY); 230 + if (fd < 0) 231 + return NULL; 232 + 233 + return dwfl_init_offline_dwarf(fd, dwflp, bias); 234 + } 235 + #endif 215 236 216 237 /* Dwarf wrappers */ 217 238
+1 -1
tools/perf/util/string.c
··· 259 259 if (!*pat) /* Tail wild card matches all */ 260 260 return true; 261 261 while (*str) 262 - if (strglobmatch(str++, pat)) 262 + if (__match_glob(str++, pat, ignore_space)) 263 263 return true; 264 264 } 265 265 return !*str && !*pat;
+2 -2
tools/perf/util/symbol.c
··· 1780 1780 return -1; 1781 1781 } 1782 1782 1783 - static int dso__load_vmlinux(struct dso *self, struct map *map, 1784 - const char *vmlinux, symbol_filter_t filter) 1783 + int dso__load_vmlinux(struct dso *self, struct map *map, 1784 + const char *vmlinux, symbol_filter_t filter) 1785 1785 { 1786 1786 int err = -1, fd; 1787 1787
+2
tools/perf/util/symbol.h
··· 166 166 struct dso *__dsos__findnew(struct list_head *head, const char *name); 167 167 168 168 int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); 169 + int dso__load_vmlinux(struct dso *self, struct map *map, 170 + const char *vmlinux, symbol_filter_t filter); 169 171 int dso__load_vmlinux_path(struct dso *self, struct map *map, 170 172 symbol_filter_t filter); 171 173 int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map,