[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230623054520.4118442-2-irogers@google.com>
Date: Thu, 22 Jun 2023 22:45:18 -0700
From: Ian Rogers <irogers@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Kan Liang <kan.liang@...ux.intel.com>,
Yang Jihong <yangjihong1@...wei.com>,
Carsten Haitzler <carsten.haitzler@....com>,
Changbin Du <changbin.du@...wei.com>,
Athira Rajeev <atrajeev@...ux.vnet.ibm.com>,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
Jason Wang <wangborong@...rlc.com>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v3 1/3] perf dso: Sort symbols under lock
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@...gle.com>
---
tools/perf/util/map.c | 3 +--
tools/perf/util/symbol.c | 8 ++++++--
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index f30d34903aa4..a45708289cc6 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -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);
}
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index d275d3bef7d5..bb02047e1c59 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -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);
}
/*
--
2.41.0.162.gfafddb0af9-goog
Powered by blists - more mailing lists