From: Robert Richter <robert.richter@amd.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: <acme@redhat.com>, <a.p.zijlstra@chello.nl>, <mingo@elte.hu>,
<paulus@samba.org>, <cjashfor@linux.vnet.ibm.com>,
<fweisbec@gmail.com>, <linux-kernel@vger.kernel.org>,
<tglx@linutronix.de>, <andi@firstfloor.org>
Subject: Re: [PATCH 5/8] perf, tool: Separate 'mem:' event scanner bits
Date: Wed, 11 Apr 2012 15:28:18 +0200 [thread overview]
Message-ID: <20120411132818.GA5046@erda.amd.com> (raw)
In-Reply-To: <1333574176-11388-6-git-send-email-jolsa@redhat.com>
On 04.04.12 23:16:13, Jiri Olsa wrote:
> Separating 'mem:' scanner processing, so we can parse out
> modifier specifically and dont clash with other rules.
>
> This is just precaution for the future, so we dont need to worry
> about the rules clashing where we need to parse out any sub-rule
> of global rules.
>
> Learning bison/flex as I go... ;)
All this lex/yacc thing is over-engineered. Having this for just
parsing events events is overkill and introduces more problems than it
solves.
I am looking at this because I want to extend perf tools to have
support for dynamic allocated pmus, esp. for IBS. I have had to
completly rework my code because of this change and it is still hard
to find a solution for this. I guess there was a reason to use
lex/yacc, but I don't think we need it for parsing *all* types of
events.
First, not every developer knows about lex and yacc, so this raises
the bar to modify and improve the code. I already had worked with
lex/yacc some years ago. What I remember and learned from it is to
avoid using it because there are easier ways to solve the same
problems. Esp. I learned to keep things simple and not to invent
complex syntax or languages. Unfortunatlly, this is what happens here
(remember, we just want to parse events, nothing more).
It also adds a more complex tool chain and the result of the generated
code is heavily affected by them and the used distro. The discussion
about having precompiled code in the repository had shown its
problems. There is also no control of the quality of the generated
code. With something like the following you are actually stucked to
build perf:
$ make
...
CC util/parse-events-flex.o
cc1: warnings being treated as errors
<stdout>: In function 'yy_get_next_buffer':
<stdout>:1504:3: error: comparison between signed and unsigned integer expressions
util/parse-events.l: In function 'parse_events_lex':
util/parse-events.l:122:1: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result
make: *** [util/parse-events-flex.o] Error 1
But the main problem I see are side effects of the syntax for one
event type to another. The lexer generates a token stream and the
syntax of each token is predefined, e.g. the word 'config' always
returns the PE_TERM token. Thus, you are not able to use that word for
other purposes, let's say in a tracepoint. Another example is the word
'race' that is always detected as a raw-event token. This side effects
are not easy to discover and to test.
This makes it also hard to extend the syntax. Since certain token
patterns are already defined for a special event type, the same
pattern can not be used again. If the setup of this event fails the
parser is not able to setup a different event type. See this example:
<pmu>:<some_string>:<modifier>
<pmu>:<raw_config>:<modifier>
This syntax is already used for a single event type (tracepoints) and
can't be reused anymore. There are options to solve this by defining
the syntax different:
<pmu>::<some_string>::<modifier>
<pmu>/<some_string>/:<modifier>
... or so. Alternativly one could write a more complex lexer that goes
back and forth in the buffer using yyless() or so.
One could also argument here that the syntax needs to be well defined,
which would prevent the problems above, but I don't want to implement
a nice syntax, I want to parse events.
The previous implementation worked simple and straightforward by
passing the event string to the event parsers until there was a
match. I haven't had the feeling of unresolvable issues with the plain
C implementation. So why lex/yacc?
But maybe it's already too late for this discussion. Hmm...
-Robert
--
Advanced Micro Devices, Inc.
Operating System Research Center
next prev parent reply other threads:[~2012-04-11 13:28 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-04 21:16 [RFCv2 0/8] perf tool: Add new event group management Jiri Olsa
2012-04-04 21:16 ` [PATCH 1/8] perf, tool: Add support to parse event group syntax Jiri Olsa
2012-04-04 21:16 ` [PATCH 2/8] perf, tool: Enable grouping logic for parsed events Jiri Olsa
2012-04-04 21:16 ` [PATCH 3/8] perf: Add PERF_EVENT_IOC_ID ioctl to return event ID Jiri Olsa
2012-04-04 21:16 ` [PATCH 4/8] perf, tool: Use PERF_EVENT_IOC_ID perf ioctl to read event id Jiri Olsa
2012-04-04 21:16 ` [PATCH 5/8] perf, tool: Separate 'mem:' event scanner bits Jiri Olsa
2012-04-11 13:28 ` Robert Richter [this message]
2012-04-11 14:33 ` Jiri Olsa
2012-04-13 17:02 ` Robert Richter
2012-04-04 21:16 ` [PATCH 6/8] perf, tool: Add modifier support to group event syntax Jiri Olsa
2012-04-04 21:16 ` [PATCH 7/8] perf, tool: Add support for parsing PERF_SAMPLE_READ Jiri Olsa
2012-04-04 21:16 ` [PATCH 8/8] perf, tool: Enable sampling on specified event group leader Jiri Olsa
2012-04-04 21:21 ` [RFCv2 0/8] perf tool: Add new event group management Jiri Olsa
2012-04-15 15:16 ` Peter Zijlstra
2012-04-16 12:16 ` Jiri Olsa
2012-04-16 14:23 ` Peter Zijlstra
2012-04-16 15:26 ` Peter Zijlstra
2012-04-16 15:37 ` Jiri Olsa
2012-04-17 2:16 ` Namhyung Kim
2012-04-17 9:09 ` Namhyung Kim
2012-04-17 9:33 ` Jiri Olsa
2012-05-25 22:36 ` Andi Kleen
2012-05-26 12:38 ` Jiri Olsa
2012-05-26 19:23 ` Andi Kleen
2012-05-27 7:56 ` Ulrich Drepper
2012-05-27 15:08 ` Andi Kleen
2012-05-28 19:21 ` Jiri Olsa
2012-05-29 8:39 ` Peter Zijlstra
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=20120411132818.GA5046@erda.amd.com \
--to=robert.richter@amd.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=andi@firstfloor.org \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
/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