Skip to content

Commit 9c6a585

Browse files
committed
perf namespaces: Introduce nsinfo__set_in_pidns()
When we're processing a perf.data file we will, for every thread in that file do a machine__findnew_thread(machine, pid, tid) that when that pid is seen for the first time will create a 'struct thread' representing it. That in turn will call nsinfo__new() -> nsinfo__init() and there it will assume we're running live, which is wrong and will need to be addressed in a followup patch. The nsinfo__new() assumes that if we can't access that thread it has already finished and will ignore the -1 return from nsinfo__init(), just taking notes to avoid trying to enter in that namespace, since it isn't there anymore, a race. When doing this from 'perf inject', tho, we can fill in parts of that nsinfo from what we get from the PERF_RECORD_MMAP2 (pid, tid) and in the jitdump file name, that has the form of jit-<PID>.dump. So if the pid in the jitdump file name is not the one in the PERF_RECORD_MMAP2, we can assume that its the pid of the process _inside_ the namespace, and that perf was runing outside that namespace. This will be done in the following patch. Reported-by: Francesco Nigro <[email protected]> Reported-by: Ilan Green <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Clark Williams <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Yonatan Goldschmidt <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent f523347 commit 9c6a585

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

tools/perf/util/namespaces.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ pid_t nsinfo__in_pidns(const struct nsinfo *nsi)
271271
return RC_CHK_ACCESS(nsi)->in_pidns;
272272
}
273273

274+
void nsinfo__set_in_pidns(struct nsinfo *nsi)
275+
{
276+
RC_CHK_ACCESS(nsi)->in_pidns = true;
277+
}
278+
274279
void nsinfo__mountns_enter(struct nsinfo *nsi,
275280
struct nscookie *nc)
276281
{

tools/perf/util/namespaces.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pid_t nsinfo__tgid(const struct nsinfo *nsi);
5959
pid_t nsinfo__nstgid(const struct nsinfo *nsi);
6060
pid_t nsinfo__pid(const struct nsinfo *nsi);
6161
pid_t nsinfo__in_pidns(const struct nsinfo *nsi);
62+
void nsinfo__set_in_pidns(struct nsinfo *nsi);
6263

6364
void nsinfo__mountns_enter(struct nsinfo *nsi, struct nscookie *nc);
6465
void nsinfo__mountns_exit(struct nscookie *nc);

0 commit comments

Comments
 (0)