diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-11-18 17:20:53 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-19 02:28:13 -0500 |
commit | 2446042c93bfc6eeebfc89e88fdef2435d2bb5c4 (patch) | |
tree | 3b442923926652127331449cf9a2da811a8fca4a | |
parent | f1617b40596cb341ee6602a9d969c5e4cebe9260 (diff) |
perf symbols: Capture the running kernel buildid too
[root@doppio linux-2.6-tip]# perf record -a -f sleep 3s ; perf
buildid-list | grep vmlinux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.171 MB perf.data (~7489
samples) ] 18e7cc53db62a7d35e9d6f6c9ddc23017d38ee9a vmlinux
[root@doppio linux-2.6-tip]#
Several refactorings were needed so that we can have symmetry
between dsos__load_modules() and dsos__load_kernel(), i.e. those
functions will respectively create and add to the dsos list the
loaded modules and kernel, with its buildids, but not load its
symbols. That is something the subcomands that need will have to
call dso__load_kernel_sym(), just like we do with modules with
dsos__load_module_sym()/dso__load_module_sym().
Next csets will actually use this info to stop producing bogus
results using mismatched vmlinux and .ko files.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1258582853-8579-4-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | tools/perf/builtin-top.c | 7 | ||||
-rw-r--r-- | tools/perf/util/header.c | 1 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 65 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 3 |
4 files changed, 46 insertions, 30 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 07b92c378ae2..6d770ac7be0b 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -948,7 +948,12 @@ static int symbol_filter(struct map *map, struct symbol *sym) | |||
948 | 948 | ||
949 | static int parse_symbols(void) | 949 | static int parse_symbols(void) |
950 | { | 950 | { |
951 | if (dsos__load_kernel(vmlinux_name, symbol_filter, 1) <= 0) | 951 | struct dso *kernel = dsos__load_kernel(); |
952 | |||
953 | if (kernel == NULL) | ||
954 | return -1; | ||
955 | |||
956 | if (dso__load_kernel_sym(kernel, symbol_filter, 1) <= 0) | ||
952 | return -1; | 957 | return -1; |
953 | 958 | ||
954 | if (dump_symtab) | 959 | if (dump_symtab) |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index d3d656f9a621..425a29ba01a9 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -241,6 +241,7 @@ perf_header__adds_write(struct perf_header *self, int fd) | |||
241 | 241 | ||
242 | buildid_sec = &feat_sec[idx++]; | 242 | buildid_sec = &feat_sec[idx++]; |
243 | 243 | ||
244 | dsos__load_kernel(); | ||
244 | /* | 245 | /* |
245 | * Read the list of loaded modules with its build_ids | 246 | * Read the list of loaded modules with its build_ids |
246 | */ | 247 | */ |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 7b4cedeb3020..4d75e745288f 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1352,17 +1352,11 @@ static int dso__load_vmlinux(struct dso *self, struct map *map, | |||
1352 | return err; | 1352 | return err; |
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | int dsos__load_kernel(const char *vmlinux, symbol_filter_t filter, | 1355 | int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter, int use_modules) |
1356 | int use_modules) | ||
1357 | { | 1356 | { |
1358 | int err = -1; | 1357 | int err = -1; |
1359 | struct dso *dso = dso__new(vmlinux); | ||
1360 | 1358 | ||
1361 | if (dso == NULL) | 1359 | kernel_map = map__new2(0, self); |
1362 | return -1; | ||
1363 | |||
1364 | dso->short_name = "[kernel]"; | ||
1365 | kernel_map = map__new2(0, dso); | ||
1366 | if (kernel_map == NULL) | 1360 | if (kernel_map == NULL) |
1367 | goto out_delete_dso; | 1361 | goto out_delete_dso; |
1368 | 1362 | ||
@@ -1374,39 +1368,36 @@ int dsos__load_kernel(const char *vmlinux, symbol_filter_t filter, | |||
1374 | use_modules = 0; | 1368 | use_modules = 0; |
1375 | } | 1369 | } |
1376 | 1370 | ||
1377 | if (vmlinux) { | 1371 | err = dso__load_vmlinux(self, kernel_map, self->name, filter); |
1378 | err = dso__load_vmlinux(dso, kernel_map, vmlinux, filter); | 1372 | if (err > 0 && use_modules) { |
1379 | if (err > 0 && use_modules) { | 1373 | int syms = dsos__load_modules_sym(filter); |
1380 | int syms = dsos__load_modules_sym(filter); | ||
1381 | 1374 | ||
1382 | if (syms < 0) | 1375 | if (syms < 0) |
1383 | pr_warning("Failed to read module symbols!" | 1376 | pr_warning("Failed to read module symbols!" |
1384 | " Continuing...\n"); | 1377 | " Continuing...\n"); |
1385 | else | 1378 | else |
1386 | err += syms; | 1379 | err += syms; |
1387 | } | ||
1388 | } | 1380 | } |
1389 | 1381 | ||
1390 | if (err <= 0) | 1382 | if (err <= 0) |
1391 | err = kernel_maps__load_kallsyms(filter, use_modules); | 1383 | err = kernel_maps__load_kallsyms(filter, use_modules); |
1392 | 1384 | ||
1393 | if (err > 0) { | 1385 | if (err > 0) { |
1394 | struct rb_node *node = rb_first(&dso->syms); | 1386 | struct rb_node *node = rb_first(&self->syms); |
1395 | struct symbol *sym = rb_entry(node, struct symbol, rb_node); | 1387 | struct symbol *sym = rb_entry(node, struct symbol, rb_node); |
1396 | 1388 | ||
1397 | kernel_map->start = sym->start; | 1389 | kernel_map->start = sym->start; |
1398 | node = rb_last(&dso->syms); | 1390 | node = rb_last(&self->syms); |
1399 | sym = rb_entry(node, struct symbol, rb_node); | 1391 | sym = rb_entry(node, struct symbol, rb_node); |
1400 | kernel_map->end = sym->end; | 1392 | kernel_map->end = sym->end; |
1401 | 1393 | ||
1402 | dso->origin = DSO__ORIG_KERNEL; | 1394 | self->origin = DSO__ORIG_KERNEL; |
1403 | kernel_maps__insert(kernel_map); | 1395 | kernel_maps__insert(kernel_map); |
1404 | /* | 1396 | /* |
1405 | * Now that we have all sorted out, just set the ->end of all | 1397 | * Now that we have all sorted out, just set the ->end of all |
1406 | * maps: | 1398 | * maps: |
1407 | */ | 1399 | */ |
1408 | kernel_maps__fixup_end(); | 1400 | kernel_maps__fixup_end(); |
1409 | dsos__add(dso); | ||
1410 | 1401 | ||
1411 | if (verbose) | 1402 | if (verbose) |
1412 | kernel_maps__fprintf(stderr); | 1403 | kernel_maps__fprintf(stderr); |
@@ -1415,7 +1406,7 @@ int dsos__load_kernel(const char *vmlinux, symbol_filter_t filter, | |||
1415 | return err; | 1406 | return err; |
1416 | 1407 | ||
1417 | out_delete_dso: | 1408 | out_delete_dso: |
1418 | dso__delete(dso); | 1409 | dso__delete(self); |
1419 | return -1; | 1410 | return -1; |
1420 | } | 1411 | } |
1421 | 1412 | ||
@@ -1475,18 +1466,36 @@ size_t dsos__fprintf_buildid(FILE *fp) | |||
1475 | return ret; | 1466 | return ret; |
1476 | } | 1467 | } |
1477 | 1468 | ||
1478 | int load_kernel(symbol_filter_t filter) | 1469 | struct dso *dsos__load_kernel(void) |
1479 | { | 1470 | { |
1480 | if (dsos__load_kernel(vmlinux_name, filter, modules) <= 0) | 1471 | struct dso *kernel = dso__new(vmlinux_name); |
1481 | return -1; | ||
1482 | 1472 | ||
1473 | if (kernel == NULL) | ||
1474 | return NULL; | ||
1475 | |||
1476 | kernel->short_name = "[kernel]"; | ||
1483 | vdso = dso__new("[vdso]"); | 1477 | vdso = dso__new("[vdso]"); |
1484 | if (!vdso) | 1478 | if (!vdso) |
1485 | return -1; | 1479 | return NULL; |
1480 | |||
1481 | if (sysfs__read_build_id("/sys/kernel/notes", kernel->build_id, | ||
1482 | sizeof(kernel->build_id)) == 0) | ||
1483 | kernel->has_build_id = true; | ||
1486 | 1484 | ||
1485 | dsos__add(kernel); | ||
1487 | dsos__add(vdso); | 1486 | dsos__add(vdso); |
1488 | 1487 | ||
1489 | return 0; | 1488 | return kernel; |
1489 | } | ||
1490 | |||
1491 | int load_kernel(symbol_filter_t filter) | ||
1492 | { | ||
1493 | struct dso *kernel = dsos__load_kernel(); | ||
1494 | |||
1495 | if (kernel == NULL) | ||
1496 | return -1; | ||
1497 | |||
1498 | return dso__load_kernel_sym(kernel, filter, modules); | ||
1490 | } | 1499 | } |
1491 | 1500 | ||
1492 | void symbol__init(unsigned int priv_size) | 1501 | void symbol__init(unsigned int priv_size) |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index da7ec1af255a..f0593a649c3d 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -77,10 +77,10 @@ void dso__delete(struct dso *self); | |||
77 | 77 | ||
78 | struct symbol *dso__find_symbol(struct dso *self, u64 ip); | 78 | struct symbol *dso__find_symbol(struct dso *self, u64 ip); |
79 | 79 | ||
80 | int dsos__load_kernel(const char *vmlinux, symbol_filter_t filter, int modules); | ||
81 | int dsos__load_modules(void); | 80 | int dsos__load_modules(void); |
82 | struct dso *dsos__findnew(const char *name); | 81 | struct dso *dsos__findnew(const char *name); |
83 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); | 82 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); |
83 | int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter, int modules); | ||
84 | void dsos__fprintf(FILE *fp); | 84 | void dsos__fprintf(FILE *fp); |
85 | size_t dsos__fprintf_buildid(FILE *fp); | 85 | size_t dsos__fprintf_buildid(FILE *fp); |
86 | 86 | ||
@@ -94,6 +94,7 @@ int sysfs__read_build_id(const char *filename, void *bf, size_t size); | |||
94 | bool dsos__read_build_ids(void); | 94 | bool dsos__read_build_ids(void); |
95 | int build_id__sprintf(u8 *self, int len, char *bf); | 95 | int build_id__sprintf(u8 *self, int len, char *bf); |
96 | 96 | ||
97 | struct dso *dsos__load_kernel(void); | ||
97 | int load_kernel(symbol_filter_t filter); | 98 | int load_kernel(symbol_filter_t filter); |
98 | 99 | ||
99 | void symbol__init(unsigned int priv_size); | 100 | void symbol__init(unsigned int priv_size); |