Skip to content

Commit

Permalink
perf machine: No need to check if kernel module maps pre-exist
Browse files Browse the repository at this point in the history
We'only populating maps for kernel modules either from perf.data file
PERF_RECORD_MMAP records or when parsing /proc/modules, so there is no
need to first look if we already have those module maps in the list,
that would mean the kernel has duplicate entries.

So ditch one use of looking up maps by name.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-gnzjg2hhuz6jnrw91m35059y@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Arnaldo Carvalho de Melo committed Nov 18, 2019
1 parent 6e0a9b3 commit a94ab91
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
16 changes: 6 additions & 10 deletions tools/perf/util/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,20 +772,16 @@ int machine__process_ksymbol(struct machine *machine __maybe_unused,
return machine__process_ksymbol_register(machine, event, sample);
}

struct map *machine__findnew_module_map(struct machine *machine, u64 start,
const char *filename)
static struct map *machine__addnew_module_map(struct machine *machine, u64 start,
const char *filename)
{
struct map *map = NULL;
struct dso *dso = NULL;
struct kmod_path m;
struct dso *dso;

if (kmod_path__parse_name(&m, filename))
return NULL;

map = map_groups__find_by_name(&machine->kmaps, m.name);
if (map)
goto out;

dso = machine__findnew_module_dso(machine, &m, filename);
if (dso == NULL)
goto out;
Expand Down Expand Up @@ -1384,7 +1380,7 @@ static int machine__create_module(void *arg, const char *name, u64 start,
if (arch__fix_module_text_start(&start, &size, name) < 0)
return -1;

map = machine__findnew_module_map(machine, start, name);
map = machine__addnew_module_map(machine, start, name);
if (map == NULL)
return -1;
map->end = start + size;
Expand Down Expand Up @@ -1559,8 +1555,8 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
strlen(machine->mmap_name) - 1) == 0;
if (event->mmap.filename[0] == '/' ||
(!is_kernel_mmap && event->mmap.filename[0] == '[')) {
map = machine__findnew_module_map(machine, event->mmap.start,
event->mmap.filename);
map = machine__addnew_module_map(machine, event->mmap.start,
event->mmap.filename);
if (map == NULL)
goto out_problem;

Expand Down
2 changes: 0 additions & 2 deletions tools/perf/util/machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ struct symbol *machine__find_kernel_symbol_by_name(struct machine *machine,
return map_groups__find_symbol_by_name(&machine->kmaps, name, mapp);
}

struct map *machine__findnew_module_map(struct machine *machine, u64 start,
const char *filename);
int arch__fix_module_text_start(u64 *start, u64 *size, const char *name);

int machine__load_kallsyms(struct machine *machine, const char *filename);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP:
/*
* kernel modules know their symtab type - it's set when
* creating a module dso in machine__findnew_module_map().
* creating a module dso in machine__addnew_module_map().
*/
return kmod && dso->symtab_type == type;

Expand Down

0 comments on commit a94ab91

Please sign in to comment.