public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>, Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Andi Kleen <ak@linux.intel.com>, Ian Rogers <irogers@google.com>,
	Stephane Eranian <eranian@google.com>,
	Ravi Bangoria <ravi.bangoria@amd.com>
Subject: Re: [PATCH v4] perf evsel: Fix missing exclude_{host,guest} setting
Date: Sat, 6 Nov 2021 16:19:26 -0300	[thread overview]
Message-ID: <YYbVPmrF0CD6KFLk@kernel.org> (raw)
In-Reply-To: <YYbS/UoQ9wHAc44j@kernel.org>

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@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.

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;
+}
+


  reply	other threads:[~2021-11-06 19:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05 20:58 [PATCH v4] perf evsel: Fix missing exclude_{host,guest} setting Namhyung Kim
2021-11-06 19:09 ` Arnaldo Carvalho de Melo
2021-11-06 19:19   ` Arnaldo Carvalho de Melo [this message]
2021-11-08 18:53   ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YYbVPmrF0CD6KFLk@kernel.org \
    --to=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox