Skip to content

Commit

Permalink
perf symbols: Remove unrelated actions from dso__load_kernel_sym
Browse files Browse the repository at this point in the history
It should just load kernel symbols, not load the list of
modules. There are more stuff to move to other routines, but
lets do it in several steps.

End goal is to be able to defer symbol table loading till we
find a hit for that map address range. So that the kernel &
modules are handled just like all the other DSOs in the system.

Signed-off-by: Arnaldo Carvalho de Melo <acme@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: <1258757489-5978-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Arnaldo Carvalho de Melo authored and Ingo Molnar committed Nov 21, 2009
1 parent 9620059 commit 6671cb1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 35 deletions.
5 changes: 3 additions & 2 deletions tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static int input;
static int full_paths;

static int print_line;
static bool use_modules;

static unsigned long page_size;
static unsigned long mmap_window = 32;
Expand Down Expand Up @@ -636,7 +637,7 @@ static int __cmd_annotate(void)
exit(0);
}

if (load_kernel(symbol_filter) < 0) {
if (load_kernel(symbol_filter, use_modules) < 0) {
perror("failed to load kernel symbols");
return EXIT_FAILURE;
}
Expand Down Expand Up @@ -742,7 +743,7 @@ static const struct option options[] = {
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
"dump raw trace in ASCII"),
OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"),
OPT_BOOLEAN('m', "modules", &modules,
OPT_BOOLEAN('m', "modules", &use_modules,
"load module symbols - WARNING: use only with -k and LIVE kernel"),
OPT_BOOLEAN('l', "print-line", &print_line,
"print matching source lines (may be slow)"),
Expand Down
3 changes: 2 additions & 1 deletion tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static char *dso_list_str, *comm_list_str, *sym_list_str,
static struct strlist *dso_list, *comm_list, *sym_list;

static int force;
static bool use_modules;

static int full_paths;
static int show_nr_samples;
Expand Down Expand Up @@ -1023,7 +1024,7 @@ static const struct option options[] = {
"dump raw trace in ASCII"),
OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"),
OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
OPT_BOOLEAN('m', "modules", &modules,
OPT_BOOLEAN('m', "modules", &use_modules,
"load module symbols - WARNING: use only with -k and LIVE kernel"),
OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples,
"Show a column with the number of samples"),
Expand Down
10 changes: 9 additions & 1 deletion tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,16 @@ static int parse_symbols(void)
if (kernel == NULL)
return -1;

if (dsos__load_modules() < 0)
pr_debug("Couldn't read the complete list of modules, "
"continuing...\n");

if (dsos__load_modules_sym(symbol_filter) < 0)
pr_warning("Failed to read module symbols, continuing...\n");

if (dso__load_kernel_sym(kernel, symbol_filter, 1) <= 0)
return -1;
pr_debug("Couldn't read the complete list of kernel symbols, "
"continuing...\n");

if (dump_symtab)
dsos__fprintf(stderr);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/data_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ int mmap_dispatch_perf_file(struct perf_header **pheader,
goto out_delete;

err = -ENOMEM;
if (load_kernel(NULL) < 0) {
if (load_kernel(NULL, 1) < 0) {
pr_err("failed to load kernel symbols\n");
goto out_delete;
}
Expand Down
46 changes: 19 additions & 27 deletions tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ static int dsos__load_modules_sym_dir(char *dirname, symbol_filter_t filter)
return -1;
}

static int dsos__load_modules_sym(symbol_filter_t filter)
int dsos__load_modules_sym(symbol_filter_t filter)
{
struct utsname uts;
char modules_path[PATH_MAX];
Expand Down Expand Up @@ -1352,33 +1352,18 @@ static int dso__load_vmlinux(struct dso *self, struct map *map,
return err;
}

int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter, int use_modules)
int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter,
int use_modules)
{
int err = -1;
int err;

kernel_map = map__new2(0, self);
if (kernel_map == NULL)
goto out_delete_dso;
return -1;

kernel_map->map_ip = kernel_map->unmap_ip = identity__map_ip;

if (use_modules && dsos__load_modules() < 0) {
pr_warning("Failed to load list of modules in use! "
"Continuing...\n");
use_modules = 0;
}

err = dso__load_vmlinux(self, kernel_map, self->name, filter);
if (err > 0 && use_modules) {
int syms = dsos__load_modules_sym(filter);

if (syms < 0)
pr_warning("Failed to read module symbols!"
" Continuing...\n");
else
err += syms;
}

if (err <= 0)
err = kernel_maps__load_kallsyms(filter, use_modules);

Expand All @@ -1404,17 +1389,12 @@ int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter, int use_modul
}

return err;

out_delete_dso:
dso__delete(self);
return -1;
}

LIST_HEAD(dsos);
struct dso *vdso;

const char *vmlinux_name = "vmlinux";
int modules;

static void dsos__add(struct dso *dso)
{
Expand Down Expand Up @@ -1488,14 +1468,26 @@ struct dso *dsos__load_kernel(void)
return kernel;
}

int load_kernel(symbol_filter_t filter)
int load_kernel(symbol_filter_t filter, bool use_modules)
{
struct dso *kernel = dsos__load_kernel();

if (kernel == NULL)
return -1;

return dso__load_kernel_sym(kernel, filter, modules);
if (use_modules) {
if (dsos__load_modules() < 0)
pr_warning("Failed to load list of modules in use, "
"continuing...\n");
else if (dsos__load_modules_sym(filter) < 0)
pr_warning("Failed to read module symbols, "
"continuing...\n");
}

if (dso__load_kernel_sym(kernel, filter, use_modules) < 0)
pr_warning("Failed to read kernel symbols, continuing...\n");

return 0;
}

void symbol__init(unsigned int priv_size)
Expand Down
7 changes: 4 additions & 3 deletions tools/perf/util/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ void dso__delete(struct dso *self);
struct symbol *dso__find_symbol(struct dso *self, u64 ip);

int dsos__load_modules(void);
int dsos__load_modules_sym(symbol_filter_t filter);
struct dso *dsos__findnew(const char *name);
int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter, int modules);
int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter,
int use_modules);
void dsos__fprintf(FILE *fp);
size_t dsos__fprintf_buildid(FILE *fp);

Expand All @@ -95,13 +97,12 @@ bool dsos__read_build_ids(void);
int build_id__sprintf(u8 *self, int len, char *bf);

struct dso *dsos__load_kernel(void);
int load_kernel(symbol_filter_t filter);
int load_kernel(symbol_filter_t filter, bool use_modules);

void symbol__init(unsigned int priv_size);

extern struct list_head dsos;
extern struct map *kernel_map;
extern struct dso *vdso;
extern const char *vmlinux_name;
extern int modules;
#endif /* __PERF_SYMBOL */

0 comments on commit 6671cb1

Please sign in to comment.