Re: [PATCH] perf tools: Do not rely on errno values for precise_ip fallback

From: Arnaldo Carvalho de Melo
Date: Wed Jul 03 2019 - 10:52:26 EST


Em Wed, Jul 03, 2019 at 10:09:49AM +0200, Jiri Olsa escreveu:
> Konstantin reported problem with default perf record command,
> which fails on some AMD servers, because of the default maximum
> precise config.
>
> The current fallback mechanism counts on getting ENOTSUP errno for
> precise_ip fails, but that's not the case on some AMD servers.
>
> We can fix this by removing the errno check completely, because the
> precise_ip fallback is separated. We can just try (if requested by
> evsel->precise_max) all possible precise_ip, and if one succeeds we
> win, if not, we continue with standard fallback.

Thanks, applied.

Simple test shows that behaviour continues the same on x86_64.

- Arnaldo

> Reported-by: Konstantin Kharlamov <Hi-Angel@xxxxxxxxx>
> Cc: Quentin Monnet <quentin.monnet@xxxxxxxxxxxxx>
> Cc: Kim Phillips <kim.phillips@xxxxxxx>
> Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> ---
> tools/perf/util/evsel.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 5ab31a4a658d..7fb4ae82f34c 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -1800,14 +1800,8 @@ static int perf_event_open(struct perf_evsel *evsel,
> if (fd >= 0)
> break;
>
> - /*
> - * Do quick precise_ip fallback if:
> - * - there is precise_ip set in perf_event_attr
> - * - maximum precise is requested
> - * - sys_perf_event_open failed with ENOTSUP error,
> - * which is associated with wrong precise_ip
> - */
> - if (!precise_ip || !evsel->precise_max || (errno != ENOTSUP))
> + /* Do not try less precise if not requested. */
> + if (!evsel->precise_max)
> break;
>
> /*
> --
> 2.21.0

--

- Arnaldo