Skip to content

Commit

Permalink
From patchwork series 412099
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox Snowpatch committed Jun 23, 2024
1 parent e2b06d7 commit dabf6eb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
3 changes: 2 additions & 1 deletion tools/perf/scripts/python/parallel-perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ def ProcessCommandOutputLines(cmd, per_cpu, fn, *x):
pat = re.compile(r"\s*\[[0-9]+\]")
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
while True:
if line := p.stdout.readline():
line = p.stdout.readline()
if line:
line = line.decode("utf-8")
if pat.match(line):
line = line.split()
Expand Down
12 changes: 12 additions & 0 deletions tools/perf/util/dso.c
Original file line number Diff line number Diff line change
Expand Up @@ -1652,3 +1652,15 @@ int dso__strerror_load(struct dso *dso, char *buf, size_t buflen)
scnprintf(buf, buflen, "%s", dso_load__error_str[idx]);
return 0;
}

bool perf_pid_map_tid(const char *dso_name, int *tid)
{
return sscanf(dso_name, "/tmp/perf-%d.map", tid) == 1;
}

bool is_perf_pid_map_name(const char *dso_name)
{
int tid;

return perf_pid_map_tid(dso_name, &tid);
}
4 changes: 4 additions & 0 deletions tools/perf/util/dso.h
Original file line number Diff line number Diff line change
Expand Up @@ -809,4 +809,8 @@ void reset_fd_limit(void);
u64 dso__find_global_type(struct dso *dso, u64 addr);
u64 dso__findnew_global_type(struct dso *dso, u64 addr, u64 offset);

/* Check if dso name is of format "/tmp/perf-%d.map" */
bool perf_pid_map_tid(const char *dso_name, int *tid);
bool is_perf_pid_map_name(const char *dso_name);

#endif /* __PERF_DSO */
2 changes: 1 addition & 1 deletion tools/perf/util/dsos.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ static void dso__set_basename(struct dso *dso)
char *base, *lname;
int tid;

if (sscanf(dso__long_name(dso), "/tmp/perf-%d.map", &tid) == 1) {
if (perf_pid_map_tid(dso__long_name(dso), &tid)) {
if (asprintf(&base, "[JIT] tid %d", tid) < 0)
return;
} else {
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/srcline.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static const char *srcline_dso_name(struct dso *dso)
if (dso_name[0] == '[')
return NULL;

if (!strncmp(dso_name, "/tmp/perf-", 10))
if (is_perf_pid_map_name(dso_name))
return NULL;

return dso_name;
Expand Down
3 changes: 2 additions & 1 deletion tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1799,7 +1799,8 @@ int dso__load(struct dso *dso, struct map *map)
const char *map_path = dso__long_name(dso);

mutex_lock(dso__lock(dso));
perfmap = strncmp(dso__name(dso), "/tmp/perf-", 10) == 0;
perfmap = is_perf_pid_map_name(map_path);

if (perfmap) {
if (dso__nsinfo(dso) &&
(dso__find_perf_map(newmapname, sizeof(newmapname),
Expand Down

0 comments on commit dabf6eb

Please sign in to comment.