From: gpavithrasha@gmail.com
To: acme@kernel.org, peterz@infradead.org, mingo@redhat.com,
mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
jolsa@redhat.com, linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org, namhyung@kernel.org,
irogers@google.com
Cc: gpavithrasha@gmail.com
Subject: [PATCH v1 2/4] perf mutex with nsinfo: Updated pthread_mutex_t usage
Date: Wed, 27 Jul 2022 16:49:52 +0530 [thread overview]
Message-ID: <20220727111954.105118-2-gpavithrasha@gmail.com> (raw)
In-Reply-To: <20220727111954.105118-1-gpavithrasha@gmail.com>
From: pavithra <gpavithrasha@gmail.com>
Updated usage of pthread_mutex_t with nsinfo
with the new wrapped lock(struct) in mutex.h
(remove data races).
Signed-off-by: pavithra <gpavithrasha@gmail.com>
---
tools/perf/builtin-inject.c | 6 +++---
tools/perf/util/map.c | 2 ++
tools/perf/util/probe-event.c | 6 +++++-
tools/perf/util/symbol.c | 2 +-
4 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 372ecb3e2c06..81eaed8da207 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -388,10 +388,10 @@ static int perf_event__repipe_id_index(struct perf_session *session,
static int dso__read_build_id(struct dso *dso)
{
if (dso->has_build_id)
- return 0;
-
+ return 0;
+
if (filename__read_build_id(dso->long_name, dso->build_id,
- sizeof(dso->build_id)) > 0) {
+ sizeof(dso->build_id)) > 0) {
dso->has_build_id = true;
return 0;
}
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 5b83ed1ebbd6..2ef5fe0cc53c 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -214,8 +214,10 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
if (!(prot & PROT_EXEC))
dso__set_loaded(dso);
}
+ mutex_lock(&dso->lock);
dso->nsinfo = nsi;
dso__put(dso);
+ mutex_unlock(&dso->lock);
}
return map;
out_delete:
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 91cab5f669d2..e527f2612ba4 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -38,6 +38,7 @@
#include "session.h"
#include "string2.h"
#include "strbuf.h"
+#include "mutex.h"
#include <subcmd/pager.h>
#include <linux/ctype.h>
@@ -171,8 +172,11 @@ struct map *get_target_map(const char *target, struct nsinfo *nsi, bool user)
struct map *map;
map = dso__new_map(target);
- if (map && map->dso)
+ if (map && map->dso) {
+ mutex_lock(&map->dso->lock);
map->dso->nsinfo = nsinfo__get(nsi);
+ mutex_unlock(&map->dso->lock);
+ }
return map;
} else {
return kernel_get_module_map(target);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 342be12cfa1e..4b711b13f915 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1619,7 +1619,7 @@ int dso__load(struct dso *dso, struct map *map)
struct nscookie nsc;
char newmapname[PATH_MAX];
const char *map_path = dso->long_name;
-
+ mutex_lock(&dso->lock);
perfmap = strncmp(dso->name, "/tmp/perf-", 10) == 0;
if (perfmap) {
if (dso->nsinfo && (dso__find_perf_map(newmapname,
--
2.25.1
next prev parent reply other threads:[~2022-07-27 11:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-27 11:19 [PATCH v1 1/4] perf mutex: Wrapped usage of pthread_mutex_t gpavithrasha
2022-07-27 11:19 ` gpavithrasha [this message]
2022-07-27 22:34 ` [PATCH v1 2/4] perf mutex with nsinfo: Updated pthread_mutex_t usage Namhyung Kim
2022-07-27 11:19 ` [PATCH v1 3/4] perf mutex and cond: Updated files mutex.h & mutex.c gpavithrasha
2022-07-27 22:43 ` Namhyung Kim
2022-07-27 11:19 ` [PATCH v1 4/4] perf mutex and cond: Updated every occurrence of pthread_mutex and pthread_cond gpavithrasha
2022-07-27 22:51 ` Namhyung Kim
2022-07-27 19:35 ` [PATCH v1 1/4] perf mutex: Wrapped usage of pthread_mutex_t Arnaldo Carvalho de Melo
2022-07-27 22:23 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220727111954.105118-2-gpavithrasha@gmail.com \
--to=gpavithrasha@gmail.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).