Re: [PATCH v4] perf evsel: Fix missing exclude_{host,guest} setting

From: Namhyung Kim
Date: Mon Nov 08 2021 - 13:53:28 EST


Hi Arnaldo,

On Sat, Nov 6, 2021 at 12:09 PM Arnaldo Carvalho de Melo
<acme@xxxxxxxxxx> wrote:
>
> Em Fri, Nov 05, 2021 at 01:58:47PM -0700, Namhyung Kim escreveu:
> > The current logic for the perf missing feature has a bug that it can
> > wrongly clear some modifiers like G or H. Actually some PMUs don't
> > support any filtering or exclusion while others do. But we check it
> > as a global feature.
> >
> > For example, the cycles event can have 'G' modifier to enable it only
> > in the guest mode on x86. When you don't run any VMs it'll return 0.
> >
> > # perf stat -a -e cycles:G sleep 1
> >
> > Performance counter stats for 'system wide':
> >
> > 0 cycles:G
> >
> > 1.000721670 seconds time elapsed
> >
> > But when it's used with other pmu events that don't support G modifier,
> > it'll be reset and return non-zero values.
> >
> > # perf stat -a -e cycles:G,msr/tsc/ sleep 1
> >
> > Performance counter stats for 'system wide':
> >
> > 538,029,960 cycles:G
> > 16,924,010,738 msr/tsc/
> >
> > 1.001815327 seconds time elapsed
> >
> > This is because of the missing feature detection logic being global.
> > Add a hashmap to set pmu-specific exclude_host/guest features.
>
> ⬢[acme@toolbox perf]$ perf test python
> 19: 'import perf' in python : FAILED!
> ⬢[acme@toolbox perf]$ perf test -v python
> Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc
> 19: 'import perf' in python :
> --- start ---
> test child forked, pid 11602
> python usage test: "echo "import sys ; sys.path.append('/tmp/build/perf/python'); import perf" | '/usr/bin/python3' "
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ImportError: /tmp/build/perf/python/perf.cpython-39-x86_64-linux-gnu.so: undefined symbol: evsel__find_pmu
> test child finished with -1
> ---- end ----
> 'import perf' in python: FAILED!
> ⬢[acme@toolbox perf]$
>
> Trying to fix this now. please do a 'perf test' before submitting
> patches.

Oops, sorry about that. Forgot to run it after the change.
I'll check it next time and thanks for the fix.

Thanks,
Namhyung