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 return total << PAGE_SHIFT; 502 } 503 504 - #define DEFAULT_BZIMAGE_ADDR_MAX 0x37FFFFFF 505 static void __init reserve_crashkernel(void) 506 { 507 unsigned long long total_mem; ··· 531 const unsigned long long alignment = 16<<20; /* 16M */ 532 533 /* 534 - * kexec want bzImage is below DEFAULT_BZIMAGE_ADDR_MAX 535 */ 536 crash_base = memblock_find_in_range(alignment, 537 - DEFAULT_BZIMAGE_ADDR_MAX, crash_size, alignment); 538 539 if (crash_base == MEMBLOCK_ERROR) { 540 pr_info("crashkernel reservation failed - No suitable area found.\n");
··· 501 return total << PAGE_SHIFT; 502 } 503 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 + 516 static void __init reserve_crashkernel(void) 517 { 518 unsigned long long total_mem; ··· 520 const unsigned long long alignment = 16<<20; /* 16M */ 521 522 /* 523 + * kexec want bzImage is below CRASH_KERNEL_ADDR_MAX 524 */ 525 crash_base = memblock_find_in_range(alignment, 526 + CRASH_KERNEL_ADDR_MAX, crash_size, alignment); 527 528 if (crash_base == MEMBLOCK_ERROR) { 529 pr_info("crashkernel reservation failed - No suitable area found.\n");
+1 -2
tools/perf/builtin-buildid-list.c
··· 36 37 static int __cmd_buildid_list(void) 38 { 39 - int err = -1; 40 struct perf_session *session; 41 42 session = perf_session__new(input_name, O_RDONLY, force, false); ··· 48 perf_session__fprintf_dsos_buildid(session, stdout, with_hits); 49 50 perf_session__delete(session); 51 - return err; 52 } 53 54 int cmd_buildid_list(int argc, const char **argv, const char *prefix __used)
··· 36 37 static int __cmd_buildid_list(void) 38 { 39 struct perf_session *session; 40 41 session = perf_session__new(input_name, O_RDONLY, force, false); ··· 49 perf_session__fprintf_dsos_buildid(session, stdout, with_hits); 50 51 perf_session__delete(session); 52 + return 0; 53 } 54 55 int cmd_buildid_list(int argc, const char **argv, const char *prefix __used)
+5
tools/perf/builtin-probe.c
··· 249 !params.show_lines)) 250 usage_with_options(probe_usage, options); 251 252 if (params.list_events) { 253 if (params.mod_events) { 254 pr_err(" Error: Don't use --list with --add/--del.\n");
··· 249 !params.show_lines)) 250 usage_with_options(probe_usage, options); 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 + 257 if (params.list_events) { 258 if (params.mod_events) { 259 pr_err(" Error: Don't use --list with --add/--del.\n");
+6 -4
tools/perf/util/header.c
··· 265 const char *name, bool is_kallsyms) 266 { 267 const size_t size = PATH_MAX; 268 - char *filename = malloc(size), 269 *linkname = malloc(size), *targetname; 270 int len, err = -1; 271 272 - if (filename == NULL || linkname == NULL) 273 goto out_free; 274 275 len = snprintf(filename, size, "%s%s%s", 276 - debugdir, is_kallsyms ? "/" : "", name); 277 if (mkdir_p(filename, 0755)) 278 goto out_free; 279 ··· 284 if (is_kallsyms) { 285 if (copyfile("/proc/kallsyms", filename)) 286 goto out_free; 287 - } else if (link(name, filename) && copyfile(name, filename)) 288 goto out_free; 289 } 290 ··· 301 if (symlink(targetname, linkname) == 0) 302 err = 0; 303 out_free: 304 free(filename); 305 free(linkname); 306 return err;
··· 265 const char *name, bool is_kallsyms) 266 { 267 const size_t size = PATH_MAX; 268 + char *realname = realpath(name, NULL), 269 + *filename = malloc(size), 270 *linkname = malloc(size), *targetname; 271 int len, err = -1; 272 273 + if (realname == NULL || filename == NULL || linkname == NULL) 274 goto out_free; 275 276 len = snprintf(filename, size, "%s%s%s", 277 + debugdir, is_kallsyms ? "/" : "", realname); 278 if (mkdir_p(filename, 0755)) 279 goto out_free; 280 ··· 283 if (is_kallsyms) { 284 if (copyfile("/proc/kallsyms", filename)) 285 goto out_free; 286 + } else if (link(realname, filename) && copyfile(name, filename)) 287 goto out_free; 288 } 289 ··· 300 if (symlink(targetname, linkname) == 0) 301 err = 0; 302 out_free: 303 + free(realname); 304 free(filename); 305 free(linkname); 306 return err;
+12 -3
tools/perf/util/probe-event.c
··· 114 const char *kernel_get_module_path(const char *module) 115 { 116 struct dso *dso; 117 118 if (module) { 119 list_for_each_entry(dso, &machine.kernel_dsos, node) { ··· 125 } 126 pr_debug("Failed to find module %s.\n", module); 127 return NULL; 128 } else { 129 - dso = machine.vmlinux_maps[MAP__FUNCTION]->dso; 130 - if (dso__load_vmlinux_path(dso, 131 - machine.vmlinux_maps[MAP__FUNCTION], NULL) < 0) { 132 pr_debug("Failed to load kernel map.\n"); 133 return NULL; 134 }
··· 114 const char *kernel_get_module_path(const char *module) 115 { 116 struct dso *dso; 117 + struct map *map; 118 + const char *vmlinux_name; 119 120 if (module) { 121 list_for_each_entry(dso, &machine.kernel_dsos, node) { ··· 123 } 124 pr_debug("Failed to find module %s.\n", module); 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; 135 } else { 136 + if (dso__load_vmlinux_path(dso, map, NULL) <= 0) { 137 pr_debug("Failed to load kernel map.\n"); 138 return NULL; 139 }
+55 -30
tools/perf/util/probe-finder.c
··· 117 } 118 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 static char *debuginfo_path; /* Currently dummy */ 143 144 static const Dwfl_Callbacks offline_callbacks = { ··· 127 128 /* We use this table for core files too. */ 129 .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 }; 139 140 /* Get a Dwarf from offline image */ ··· 155 return dbg; 156 } 157 158 /* Get a Dwarf from live kernel image */ 159 static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr, Dwfl **dwflp, 160 Dwarf_Addr *bias) ··· 207 dbg = dwfl_addrdwarf(*dwflp, addr, bias); 208 /* Here, check whether we could get a real dwarf */ 209 if (!dbg) { 210 dwfl_end(*dwflp); 211 *dwflp = NULL; 212 } 213 return dbg; 214 } 215 216 /* Dwarf wrappers */ 217
··· 117 } 118 119 /* Dwarf FL wrappers */ 120 static char *debuginfo_path; /* Currently dummy */ 121 122 static const Dwfl_Callbacks offline_callbacks = { ··· 149 150 /* We use this table for core files too. */ 151 .find_elf = dwfl_build_id_find_elf, 152 }; 153 154 /* Get a Dwarf from offline image */ ··· 185 return dbg; 186 } 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 + 220 /* Get a Dwarf from live kernel image */ 221 static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr, Dwfl **dwflp, 222 Dwarf_Addr *bias) ··· 205 dbg = dwfl_addrdwarf(*dwflp, addr, bias); 206 /* Here, check whether we could get a real dwarf */ 207 if (!dbg) { 208 + pr_debug("Failed to find kernel dwarf at %lx\n", 209 + (unsigned long)addr); 210 dwfl_end(*dwflp); 211 *dwflp = NULL; 212 } 213 return dbg; 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 236 237 /* Dwarf wrappers */ 238
+1 -1
tools/perf/util/string.c
··· 259 if (!*pat) /* Tail wild card matches all */ 260 return true; 261 while (*str) 262 - if (strglobmatch(str++, pat)) 263 return true; 264 } 265 return !*str && !*pat;
··· 259 if (!*pat) /* Tail wild card matches all */ 260 return true; 261 while (*str) 262 + if (__match_glob(str++, pat, ignore_space)) 263 return true; 264 } 265 return !*str && !*pat;
+2 -2
tools/perf/util/symbol.c
··· 1780 return -1; 1781 } 1782 1783 - static int dso__load_vmlinux(struct dso *self, struct map *map, 1784 - const char *vmlinux, symbol_filter_t filter) 1785 { 1786 int err = -1, fd; 1787
··· 1780 return -1; 1781 } 1782 1783 + int dso__load_vmlinux(struct dso *self, struct map *map, 1784 + const char *vmlinux, symbol_filter_t filter) 1785 { 1786 int err = -1, fd; 1787
+2
tools/perf/util/symbol.h
··· 166 struct dso *__dsos__findnew(struct list_head *head, const char *name); 167 168 int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); 169 int dso__load_vmlinux_path(struct dso *self, struct map *map, 170 symbol_filter_t filter); 171 int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map,
··· 166 struct dso *__dsos__findnew(struct list_head *head, const char *name); 167 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); 171 int dso__load_vmlinux_path(struct dso *self, struct map *map, 172 symbol_filter_t filter); 173 int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map,