lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YYbVPmrF0CD6KFLk@kernel.org>
Date:   Sat, 6 Nov 2021 16:19:26 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Namhyung Kim <namhyung@...nel.org>
Cc:     Jiri Olsa <jolsa@...hat.com>, Ingo Molnar <mingo@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Andi Kleen <ak@...ux.intel.com>,
        Ian Rogers <irogers@...gle.com>,
        Stephane Eranian <eranian@...gle.com>,
        Ravi Bangoria <ravi.bangoria@....com>
Subject: Re: [PATCH v4] perf evsel: Fix missing exclude_{host,guest} setting

Em Sat, Nov 06, 2021 at 04:09:49PM -0300, Arnaldo Carvalho de Melo escreveu:
> 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@...lbox perf]$ perf test python
> 19: 'import perf' in python                                         : FAILED!
> ⬢[acme@...lbox 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@...lbox perf]$
> 
> Trying to fix this now. please do a 'perf test' before submitting
> patches.

Added this bandaid, should be good for the time being.

- Arnaldo

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 8feef3a05af7b31d..563a9ba8954f31b3 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -69,6 +69,18 @@ void perf_stat__collect_metric_expr(struct evlist *evsel_list)
 {
 }

+/*
+ * This one is needed not to drag the PMU bandwagon, jevents generated
+ * pmu_sys_event_tables, etc and evsel__find_pmu() is used so far just for
+ * doing per PMU perf_event_attr.exclude_guest handling, not really needed, so
+ * far, for the perf python binding known usecases, revisit if this become
+ * necessary.
+ */
+struct perf_pmu *evsel__find_pmu(struct evsel *evsel __maybe_unused)
+{
+       return NULL;
+}
+

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ