Skip to content

Commit

Permalink
perf dso: Sort symbols under lock
Browse files Browse the repository at this point in the history
Determine if symbols are sorted, set the sorted flag and sort under
the dso lock. Done in the interest of thread safety.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Carsten Haitzler <carsten.haitzler@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Jason Wang <wangborong@cdjrlc.com>
Cc: Changbin Du <changbin.du@huawei.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/20230623054520.4118442-2-irogers@google.com
[ handle the similar code in util/probe-event.c ]
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
  • Loading branch information
Ian Rogers authored and Namhyung Kim committed Jun 24, 2023
1 parent ae7eb5b commit ce5b293
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions tools/perf/util/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,7 @@ struct symbol *map__find_symbol_by_name(struct map *map, const char *name)
return NULL;

dso = map__dso(map);
if (!dso__sorted_by_name(dso))
dso__sort_by_name(dso);
dso__sort_by_name(dso);

return dso__find_symbol_by_name(dso, name);
}
Expand Down
3 changes: 1 addition & 2 deletions tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -3767,8 +3767,7 @@ int show_available_funcs(const char *target, struct nsinfo *nsi,
goto end;
}
dso = map__dso(map);
if (!dso__sorted_by_name(dso))
dso__sort_by_name(dso);
dso__sort_by_name(dso);

/* Show all (filtered) symbols */
setup_pager();
Expand Down
8 changes: 6 additions & 2 deletions tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,12 @@ struct symbol *dso__find_symbol_by_name(struct dso *dso, const char *name)

void dso__sort_by_name(struct dso *dso)
{
dso__set_sorted_by_name(dso);
return symbols__sort_by_name(&dso->symbol_names, &dso->symbols);
mutex_lock(&dso->lock);
if (!dso__sorted_by_name(dso)) {
symbols__sort_by_name(&dso->symbol_names, &dso->symbols);
dso__set_sorted_by_name(dso);
}
mutex_unlock(&dso->lock);
}

/*
Expand Down

0 comments on commit ce5b293

Please sign in to comment.