From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: John Garry <john.garry@huawei.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Ravi Bangoria <ravi.bangoria@amd.com>,
Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH v1] perf test: Parse events workaround for dash/minus
Date: Fri, 28 Oct 2022 16:45:42 -0300 [thread overview]
Message-ID: <Y1wxZgWWPwuRZ+xj@kernel.org> (raw)
In-Reply-To: <CAP-5=fVmd-f=HAQPJ-UfG5EdnXMk5j6a-PdF5592LDrd8K8neA@mail.gmail.com>
Em Fri, Oct 28, 2022 at 10:55:14AM -0700, Ian Rogers escreveu:
> On Mon, Oct 17, 2022 at 4:07 PM Ian Rogers <irogers@google.com> wrote:
> >
> > On Thu, Oct 13, 2022 at 5:11 AM John Garry <john.garry@huawei.com> wrote:
> > >
> > > On 13/10/2022 02:12, Ian Rogers wrote:
> > > > Skip an event configuration for event names with a dash/minus in them.
> > > > Events with a dash/minus in their name cause parsing issues as legacy
> > > > encoding of events would use a dash/minus as a separator. The parser
> > > > separates events with dashes into prefixes and suffixes and then
> > > > recombines them. Unfortunately if an event has part of its name that
> > > > matches a legacy token then the recombining fails. This is seen for
> > > > branch-brs where branch is a legacy token. branch-brs was introduced
> > > > to sysfs in:
> > > > https://lore.kernel.org/all/20220322221517.2510440-5-eranian@google.com/
> > > > The failure is shown below as well as the workaround to use a config
> > > > where the dash/minus isn't treated specially:
> > > >
> > > > ```
> > > > $ perf stat -e branch-brs true
> > > > event syntax error: 'branch-brs'
> > > > \___ parser error
> > > >
> > > > $ perf stat -e cpu/branch-brs/ true
> > > >
> > > > Performance counter stats for 'true':
> > > >
> > > > 46,179 cpu/branch-brs/
> > > > ```
> > > >
> > > > Signed-off-by: Ian Rogers <irogers@google.com>
> > > > ---
> > > > tools/perf/tests/parse-events.c | 13 +++++++++++++
> > > > 1 file changed, 13 insertions(+)
> > > >
> > > > diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
> > > > index 459afdb256a1..3440dd2616b0 100644
> > > > --- a/tools/perf/tests/parse-events.c
> > > > +++ b/tools/perf/tests/parse-events.c
> > > > @@ -2237,6 +2237,19 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest
> > > > pr_debug("Test PMU event failed for '%s'", name);
> > > > ret = combine_test_results(ret, test_ret);
> > > >
> > >
> > > Hi Ian,
> > >
> > > }
> > > > + /*
> > > > + * Names containing '-' are recognized as prefixes and suffixes
> > > > + * due to '-' being a legacy PMU separator. This fails when the
> > > > + * prefix or suffix collides with an existing legacy token. For
> > > > + * example, branch-brs has a prefix (branch) that collides with
> > > > + * a PE_NAME_CACHE_TYPE token causing a parse error as a suffix
> > > > + * isn't expected after this.
> > >
> > > OK, so you want to skip anything with '-'. Will we now miss out on
> > > events which contain a '-' but don't clash with an existing legacy token?
> >
> > Yes. The long term solution here is to ditch the current parse event
> > code and its legacy support. An idea is to create a simplified parser
> > as part of libperf2 (libperf but with a libbpf style license), use the
> > new parser for metrics and events. In the events case, if the new
> > parser fails then use the legacy parser and its weird handling of
> > dashes.
> >
> > > > As event names in the config
> > > > + * slashes are allowed a '-' in the name we check this works
> > > > + * above.
> > >
> > > Sorry, I can't follow what you mean here. Do you mean that
> > > "cpu/branch-brs/" works ok and we continue to test it?
> >
> > Yep, as shown in the commit message. The comment isn't great, it
> > should be worded something like:
> >
> > If an event name is in the config slashes, such as cpu/branch-brs/, a
> > '-' in the name works as the dash doesn't separate the parts of the
> > name. This continues to be tested above.
>
> Ping. It'd be nice to merge this as otherwise we have a perf test
> failure on AMD.
I added it for perf/core, i.e. 6.2.
Thanks,
- Arnaldo
prev parent reply other threads:[~2022-10-28 19:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 1:12 [PATCH v1] perf test: Parse events workaround for dash/minus Ian Rogers
2022-10-13 12:11 ` John Garry
2022-10-17 23:07 ` Ian Rogers
2022-10-28 17:55 ` Ian Rogers
2022-10-28 19:45 ` Arnaldo Carvalho de Melo [this message]
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=Y1wxZgWWPwuRZ+xj@kernel.org \
--to=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=john.garry@huawei.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.