Re: [PATCH 7/8] perf tools: Check fallback error and order

From: Namhyung Kim
Date: Wed Oct 16 2024 - 00:34:00 EST


Hello Ravi,

On Tue, Oct 15, 2024 at 09:51:50AM +0530, Ravi Bangoria wrote:
> > @@ -2366,9 +2403,6 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,
> > return 0;
> >
> > try_fallback:
> > - if (evsel__precise_ip_fallback(evsel))
> > - goto retry_open;
> > -
> > if (evsel__ignore_missing_thread(evsel, perf_cpu_map__nr(cpus),
> > idx, threads, thread, err)) {
> > /* We just removed 1 thread, so lower the upper nthreads limit. */
> > @@ -2385,11 +2419,15 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,
> > if (err == -EMFILE && rlimit__increase_nofile(&set_rlimit))
> > goto retry_open;
> >
> > - if (err != -EINVAL || idx > 0 || thread > 0)
> > - goto out_close;
> > + if (err == -EOPNOTSUPP && evsel__precise_ip_fallback(evsel))
> > + goto retry_open;
>
> This will change the behavior of events like instructions:P on AMD.
>
> Without patch:
> $ ./perf record -e instructions:P -- true
> [ perf record: Woken up 2 times to write data ]
> [ perf record: Captured and wrote 0.009 MB perf.data (9 samples) ]
>
> With the patch:
>
> $ ./perf record -e instructions:P -- true
> Error:
> The instructions:Pu event is not supported.

Thanks for the test, it should support other events too. I've noticed
it returns -ENOENT for non-IBS events with precise_ip > 0. Will handle
them as well.

Thanks,
Namhyung