lkml.org 
[lkml]   [2018]   [May]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH RFC 06/19] perf tools: Fix kernel_start for KPTI on x86_64
Em Wed, May 09, 2018 at 02:43:35PM +0300, Adrian Hunter escreveu:
> On x86_64, KPTI entry trampolines are less than the start of kernel text,
> but still above 2^63. So leave kernel_start = 1ULL << 63 for x86_64.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> tools/perf/util/machine.c | 16 +++++++++++++++-
> tools/perf/util/machine.h | 2 ++
> 2 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 72a351613d85..22047ff3cf2a 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -2296,6 +2296,15 @@ int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
> return 0;
> }
>
> +/*
> + * Compares the raw arch string. N.B. see instead perf_env__arch() if a
> + * normalized arch is needed.
> + */
> +bool machine__is(struct machine *machine, const char *arch)
> +{
> + return machine->env && !strcmp(machine->env->arch, arch);
> +}
> +

Please make machine__is(NULL) return false, to reduce boilerplate in
callers:

bool machine__is(struct machine *machine, const char *arch)
{
return machine && machine->env && !strcmp(machine->env->arch, arch);
}


> int machine__get_kernel_start(struct machine *machine)
> {
> struct map *map = machine__kernel_map(machine);
> @@ -2312,7 +2321,12 @@ int machine__get_kernel_start(struct machine *machine)
> machine->kernel_start = 1ULL << 63;
> if (map) {
> err = map__load(map);
> - if (!err)
> + /*
> + * On x86_64, KPTI entry trampolines are less than the
> + * start of kernel text, but still above 2^63. So leave
> + * kernel_start = 1ULL << 63 for x86_64.
> + */
> + if (!err && !machine__is(machine, "x86_64"))
> machine->kernel_start = map->start;
> }
> return err;
> diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
> index 388fb4741c54..b31d33b5aa2a 100644
> --- a/tools/perf/util/machine.h
> +++ b/tools/perf/util/machine.h
> @@ -188,6 +188,8 @@ static inline bool machine__is_host(struct machine *machine)
> return machine ? machine->pid == HOST_KERNEL_ID : false;
> }
>
> +bool machine__is(struct machine *machine, const char *arch);
> +
> struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid);
> struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid);
>
> --
> 1.9.1

\
 
 \ /
  Last update: 2018-05-09 19:08    [W:0.168 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site