Re: [PATCH RFC 11/19] perf tools: Synthesize and process mmap events for x86_64 KPTI entry trampolines

From: Jiri Olsa
Date: Tue May 15 2018 - 06:49:08 EST


On Wed, May 09, 2018 at 02:43:40PM +0300, Adrian Hunter wrote:
> Like the kernel text, the location of x86_64 KPTI entry trampolines must be
> recorded in the perf.data file. Like the kernel, synthesize a mmap event
> for that, and add processing for it.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
> ---
> tools/perf/util/event.c | 90 +++++++++++++++++++++++++++++++++++++++++++++--
> tools/perf/util/machine.c | 28 +++++++++++++++
> 2 files changed, 115 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
> index aafa9878465f..d810ff8488b1 100644
> --- a/tools/perf/util/event.c
> +++ b/tools/perf/util/event.c
> @@ -888,9 +888,80 @@ int kallsyms__get_function_start(const char *kallsyms_filename,
> return 0;
> }
>
> -int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
> - perf_event__handler_t process,
> - struct machine *machine)
> +#if defined(__x86_64__)

also this could go under arch/x86/

jirka

> +
> +static int perf_event__synthesize_special_kmaps(struct perf_tool *tool,
> + perf_event__handler_t process,
> + struct machine *machine)
> +{
> + int rc = 0;
> + struct map *pos;
> + struct map_groups *kmaps = &machine->kmaps;
> + struct maps *maps = &kmaps->maps;
> + union perf_event *event = zalloc(sizeof(event->mmap) +
> + machine->id_hdr_size);
> +
> + if (!event) {
> + pr_debug("Not enough memory synthesizing mmap event "
> + "for special kernel maps\n");
> + return -1;
> + }
> +

SNIP