* [PATCH v2] perf inject jit: Ignore memfd and anonymous mmap events if jitdump present
@ 2022-08-05 22:06 Brian Robbins
2022-08-05 22:39 ` Ian Rogers
2022-08-10 13:05 ` Arnaldo Carvalho de Melo
0 siblings, 2 replies; 3+ messages in thread
From: Brian Robbins @ 2022-08-05 22:06 UTC (permalink / raw
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Ian Rogers
Cc: linux-perf-users, linux-kernel
Some processes store jitted code in memfd mappings to avoid having rwx
mappings. These processes map the code with a writeable mapping and a
read-execute mapping. They write the code using the writeable mapping
and then unmap the writeable mapping. All subsequent execution is
through the read-execute mapping.
perf inject --jit ignores //anon* mappings for each process where a
jitdump is present because it expects to inject mmap events for each
jitted code range, and said jitted code ranges will overlap with the
//anon* mappings.
Ignore /memfd: and [anon:* mappings so that jitted code contained in
/memfd: and [anon:* mappings is treated the same way as jitted code
contained in //anon* mappings.
Signed-off-by: Brian Robbins <brianrob@linux.microsoft.com>
---
tools/perf/util/jitdump.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c
index a23255773c60..4e6632203704 100644
--- a/tools/perf/util/jitdump.c
+++ b/tools/perf/util/jitdump.c
@@ -845,8 +845,13 @@ jit_process(struct perf_session *session,
if (jit_detect(filename, pid, nsi)) {
nsinfo__put(nsi);
- // Strip //anon* mmaps if we processed a jitdump for this pid
- if (jit_has_pid(machine, pid) && (strncmp(filename, "//anon", 6) == 0))
+ /*
+ * Strip //anon*, [anon:* and /memfd:* mmaps if we processed a jitdump for this pid
+ */
+ if (jit_has_pid(machine, pid) &&
+ ((strncmp(filename, "//anon", 6) == 0) ||
+ (strncmp(filename, "[anon:", 6) == 0) ||
+ (strncmp(filename, "/memfd:", 7) == 0)))
return 1;
return 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] perf inject jit: Ignore memfd and anonymous mmap events if jitdump present
2022-08-05 22:06 [PATCH v2] perf inject jit: Ignore memfd and anonymous mmap events if jitdump present Brian Robbins
@ 2022-08-05 22:39 ` Ian Rogers
2022-08-10 13:05 ` Arnaldo Carvalho de Melo
1 sibling, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2022-08-05 22:39 UTC (permalink / raw
To: Brian Robbins
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
linux-perf-users, linux-kernel
On Fri, Aug 5, 2022 at 3:06 PM Brian Robbins
<brianrob@linux.microsoft.com> wrote:
>
> Some processes store jitted code in memfd mappings to avoid having rwx
> mappings. These processes map the code with a writeable mapping and a
> read-execute mapping. They write the code using the writeable mapping
> and then unmap the writeable mapping. All subsequent execution is
> through the read-execute mapping.
>
> perf inject --jit ignores //anon* mappings for each process where a
> jitdump is present because it expects to inject mmap events for each
> jitted code range, and said jitted code ranges will overlap with the
> //anon* mappings.
>
> Ignore /memfd: and [anon:* mappings so that jitted code contained in
> /memfd: and [anon:* mappings is treated the same way as jitted code
> contained in //anon* mappings.
>
> Signed-off-by: Brian Robbins <brianrob@linux.microsoft.com>
Acked-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> ---
> tools/perf/util/jitdump.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c
> index a23255773c60..4e6632203704 100644
> --- a/tools/perf/util/jitdump.c
> +++ b/tools/perf/util/jitdump.c
> @@ -845,8 +845,13 @@ jit_process(struct perf_session *session,
> if (jit_detect(filename, pid, nsi)) {
> nsinfo__put(nsi);
>
> - // Strip //anon* mmaps if we processed a jitdump for this pid
> - if (jit_has_pid(machine, pid) && (strncmp(filename, "//anon", 6) == 0))
> + /*
> + * Strip //anon*, [anon:* and /memfd:* mmaps if we processed a jitdump for this pid
> + */
> + if (jit_has_pid(machine, pid) &&
> + ((strncmp(filename, "//anon", 6) == 0) ||
> + (strncmp(filename, "[anon:", 6) == 0) ||
> + (strncmp(filename, "/memfd:", 7) == 0)))
> return 1;
>
> return 0;
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] perf inject jit: Ignore memfd and anonymous mmap events if jitdump present
2022-08-05 22:06 [PATCH v2] perf inject jit: Ignore memfd and anonymous mmap events if jitdump present Brian Robbins
2022-08-05 22:39 ` Ian Rogers
@ 2022-08-10 13:05 ` Arnaldo Carvalho de Melo
1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-08-10 13:05 UTC (permalink / raw
To: Brian Robbins
Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Namhyung Kim, Ian Rogers, linux-perf-users,
linux-kernel
Em Fri, Aug 05, 2022 at 03:06:45PM -0700, Brian Robbins escreveu:
> Some processes store jitted code in memfd mappings to avoid having rwx
> mappings. These processes map the code with a writeable mapping and a
> read-execute mapping. They write the code using the writeable mapping
> and then unmap the writeable mapping. All subsequent execution is
> through the read-execute mapping.
>
> perf inject --jit ignores //anon* mappings for each process where a
> jitdump is present because it expects to inject mmap events for each
> jitted code range, and said jitted code ranges will overlap with the
> //anon* mappings.
>
> Ignore /memfd: and [anon:* mappings so that jitted code contained in
> /memfd: and [anon:* mappings is treated the same way as jitted code
> contained in //anon* mappings.
Removed v1, applied this one.
- Arnaldo
> Signed-off-by: Brian Robbins <brianrob@linux.microsoft.com>
> ---
> tools/perf/util/jitdump.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c
> index a23255773c60..4e6632203704 100644
> --- a/tools/perf/util/jitdump.c
> +++ b/tools/perf/util/jitdump.c
> @@ -845,8 +845,13 @@ jit_process(struct perf_session *session,
> if (jit_detect(filename, pid, nsi)) {
> nsinfo__put(nsi);
>
> - // Strip //anon* mmaps if we processed a jitdump for this pid
> - if (jit_has_pid(machine, pid) && (strncmp(filename, "//anon", 6) == 0))
> + /*
> + * Strip //anon*, [anon:* and /memfd:* mmaps if we processed a jitdump for this pid
> + */
> + if (jit_has_pid(machine, pid) &&
> + ((strncmp(filename, "//anon", 6) == 0) ||
> + (strncmp(filename, "[anon:", 6) == 0) ||
> + (strncmp(filename, "/memfd:", 7) == 0)))
> return 1;
>
> return 0;
> --
> 2.25.1
--
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-10 13:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-05 22:06 [PATCH v2] perf inject jit: Ignore memfd and anonymous mmap events if jitdump present Brian Robbins
2022-08-05 22:39 ` Ian Rogers
2022-08-10 13:05 ` Arnaldo Carvalho de Melo
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 read-only IMAP folder(s) and NNTP newsgroup(s).