From: Jiri Olsa <jolsa@redhat.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@kernel.org>, Wang Nan <wangnan0@huawei.com>,
linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
He Kuang <hekuang@huawei.com>, Alexei Starovoitov <ast@fb.com>
Subject: Re: [PATCH 2/2] perf, tools: Don't force MetricExprs to lower case
Date: Mon, 9 Oct 2017 15:41:51 +0200 [thread overview]
Message-ID: <20171009134151.GA15127@krava> (raw)
In-Reply-To: <20171004162711.GF2482@two.firstfloor.org>
On Wed, Oct 04, 2017 at 09:27:11AM -0700, Andi Kleen wrote:
> On Wed, Oct 04, 2017 at 12:30:52PM +0200, Jiri Olsa wrote:
> > On Tue, Oct 03, 2017 at 01:06:05PM -0300, Arnaldo Carvalho de Melo wrote:
> > > Em Tue, Sep 12, 2017 at 12:56:43PM -0700, Andi Kleen escreveu:
> > > > From: Andi Kleen <ak@linux.intel.com>
> > > >
> > > > There are still problems with BPF misinterpreting some events
> > > > that include .c. An earlier fix made it work for stand alone
> > > > aliases, but it still fails for more complex constructs.
> > >
> > > Hi Wang, Jiri,
> > >
> > > Can you please take a look at this and see if there is something
> > > we can do to help Andi?
> > >
> > > - Arnaldo
> > >
> > > > REJECT keeps trying and trying a shorter string until
> > > > .c is matched and it appears like a valid BPF path.
> > > >
> > > > % perf stat -e cpu/uops_executed.core,cmask=1/ true
> > > > bpf: builtin compilation failed: -95, try external compiler
> > > > ERROR: problems with path cpu/uops_executed.c: No such file or directory
> > > > event syntax error: 'cpu/uops_executed.core,cmask=1/'
> > > > \___ Failed to load cpu/uops_executed.c from source: Error when compiling BPF scriptlet
> > > >
> > > > I tried to fix it, but it exceeds my flex knowledge, because
> > > > REJECT does not interact well with BEGIN states.
> > > >
> > > > The BPF syntax in its current form really causes an ambigious
> > > > grammar.
> >
> > right, it looks like we allow whole path (including / char)
> > for BPF file, which messes up with out pmu/.../ syntax
> >
> > do we need that? (Cc-ed some bpf folks)
> >
> > if not attached patch seems to fix things.. otherwise
> > we need to come up with another fix
>
> I tried similar patches, but I always ran into more complex
> situations where it still matched incorrectly.
>
> e.g. try it with cpu/uops_executed.core,... vs uops_executed.core
hm, both works for me with the change:
perf stat -e cpu/uops_executed.core/ ls
perf stat -e uops_executed.core ls
> The only real fix would be probably to add some unique
> prefix for BPF, but that would break all existing users.
yea, there was no response from bpf folks, but it's probably not an option
how about checking if the file exist like below..
jirka
---
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index ea2426daf7e8..38a42bdf1492 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -8,6 +8,9 @@
%{
#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include "../perf.h"
#include "parse-events.h"
#include "parse-events-bison.h"
@@ -53,9 +56,8 @@ static int str(yyscan_t scanner, int token)
return token;
}
-static bool isbpf(yyscan_t scanner)
+static bool isbpf_suffix(char *text)
{
- char *text = parse_events_get_text(scanner);
int len = strlen(text);
if (len < 2)
@@ -68,6 +70,17 @@ static bool isbpf(yyscan_t scanner)
return false;
}
+static bool isbpf(yyscan_t scanner)
+{
+ char *text = parse_events_get_text(scanner);
+ struct stat st;
+
+ if (!isbpf_suffix(text))
+ return false;
+
+ return stat(text, &st) == 0;
+}
+
/*
* This function is called when the parser gets two kind of input:
*
next prev parent reply other threads:[~2017-10-09 13:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-12 19:56 [PATCH 1/2] perf, tools, json: Fix ILP metrics Andi Kleen
2017-09-12 19:56 ` [PATCH 2/2] perf, tools: Don't force MetricExprs to lower case Andi Kleen
2017-10-03 16:06 ` Arnaldo Carvalho de Melo
2017-10-04 10:30 ` Jiri Olsa
2017-10-04 16:27 ` Andi Kleen
2017-10-09 13:41 ` Jiri Olsa [this message]
2017-10-09 14:07 ` Andi Kleen
2017-10-09 14:12 ` Arnaldo Carvalho de Melo
2017-10-09 14:39 ` Jiri Olsa
2017-10-09 14:51 ` Arnaldo Carvalho de Melo
2017-10-09 15:39 ` Andi Kleen
2017-10-12 15:31 ` Wangnan (F)
2017-10-12 15:59 ` Jiri Olsa
2017-10-12 16:07 ` Wangnan (F)
2017-10-09 14:43 ` Jiri Olsa
2017-10-09 14:09 ` Arnaldo Carvalho de Melo
2017-10-09 14:41 ` Jiri Olsa
2017-10-12 15:13 ` Jiri Olsa
2017-10-12 21:53 ` Andi Kleen
2017-10-28 23:10 ` [tip:perf/urgent] perf tools: Unwind properly location after REJECT tip-bot for Jiri Olsa
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=20171009134151.GA15127@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=andi@firstfloor.org \
--cc=ast@fb.com \
--cc=hekuang@huawei.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wangnan0@huawei.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