From: Jiri Olsa <jolsa@redhat.com>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Clark Williams <williams@redhat.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Jiri Olsa <jolsa@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
David Ahern <dsahern@gmail.com>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
kan.liang@linux.intel.com
Subject: Re: [PATCH 05/12] perf pmu: Fix pmu events parsing rule
Date: Fri, 4 May 2018 18:02:28 +0200 [thread overview]
Message-ID: <20180504160228.GA25229@krava> (raw)
In-Reply-To: <0c33d3f9-4b76-c94c-7306-e93e8cd8d4aa@intel.com>
On Thu, May 03, 2018 at 02:38:15PM +0300, Adrian Hunter wrote:
SNIP
> >>> index 7afeb80cc39e..d14464c42714 100644
> >>> --- a/tools/perf/util/parse-events.y
> >>> +++ b/tools/perf/util/parse-events.y
> >>> @@ -224,15 +224,15 @@ event_def: event_pmu |
> >>> event_bpf_file
> >>>
> >>> event_pmu:
> >>> -PE_NAME opt_event_config
> >>> +PE_NAME '/' event_config '/'
> >>
> >> These are not equivalent because opt_event_config allows '//'
> >> but event_config cannot be an empty string.
> >
> > yep, overlooked this one, how about patch below
>
> Seems to work but gives build warnings:
>
> util/parse-events.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
> util/parse-events.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
I had to make an explicit rule, so I moved the original rule code
into separate function.. hence the patch is little bigger ;-)
cc-ing Kan Liang, who recently changed this code,
I'll still have to rebase this one his recent change,
once it gets in, but should be easy
jirka
---
tools/perf/util/parse-events.c | 43 +++++++++++++++++++++++++++++++++++
tools/perf/util/parse-events.h | 3 +++
tools/perf/util/parse-events.y | 51 +++++++++++++-----------------------------
3 files changed, 62 insertions(+), 35 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 2fb0272146d8..33e3fc147f35 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -8,6 +8,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/param.h>
+#include <fnmatch.h>
#include "term.h"
#include "../perf.h"
#include "evlist.h"
@@ -1287,6 +1288,48 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
return evsel ? 0 : -ENOMEM;
}
+int parse_events_pmu(struct parse_events_state *parse_state,
+ struct list_head *list, char *name,
+ struct list_head *head_config)
+{
+ struct list_head *orig_terms;
+ struct perf_pmu *pmu = NULL;
+ char *pattern = NULL;
+ int ok = 0;
+
+ if (!parse_events_add_pmu(parse_state, list, name, head_config, false))
+ return 0;
+
+ if (parse_events_copy_term_list(head_config, &orig_terms))
+ return -1;
+
+ if (asprintf(&pattern, "%s*", name) < 0)
+ goto out;
+
+ while ((pmu = perf_pmu__scan(pmu)) != NULL) {
+ struct list_head *terms;
+ char *tmp = pmu->name;
+
+ if (!strncmp(tmp, "uncore_", 7) &&
+ strncmp(tmp, "uncore_", 7))
+ tmp += 7;
+ if (!fnmatch(pattern, tmp, 0)) {
+ if (parse_events_copy_term_list(orig_terms, &terms)) {
+ ok = 0;
+ goto out;
+ }
+ if (!parse_events_add_pmu(parse_state, list, pmu->name, terms, true))
+ ok++;
+ parse_events_terms__delete(terms);
+ }
+ }
+
+out:
+ parse_events_terms__delete(orig_terms);
+ free(pattern);
+ return ok ? 0 : -1;
+}
+
int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
char *str, struct list_head **listp)
{
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 5015cfd58277..743586213ee4 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -168,6 +168,9 @@ int parse_events_add_breakpoint(struct list_head *list, int *idx,
int parse_events_add_pmu(struct parse_events_state *parse_state,
struct list_head *list, char *name,
struct list_head *head_config, bool auto_merge_stats);
+int parse_events_pmu(struct parse_events_state *parse_state,
+ struct list_head *list, char *name,
+ struct list_head *head_config);
int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
char *str,
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index d14464c42714..a93f8c660395 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -8,7 +8,6 @@
#define YYDEBUG 1
-#include <fnmatch.h>
#include <linux/compiler.h>
#include <linux/list.h>
#include <linux/types.h>
@@ -226,44 +225,26 @@ event_def: event_pmu |
event_pmu:
PE_NAME '/' event_config '/'
{
- struct list_head *list, *orig_terms, *terms;
+ struct list_head *list;
+
+ ALLOC_LIST(list);
- if (parse_events_copy_term_list($3, &orig_terms))
+ if (parse_events_pmu(_parse_state, list, $1, $3))
YYABORT;
- ALLOC_LIST(list);
- if (parse_events_add_pmu(_parse_state, list, $1, $3, false)) {
- struct perf_pmu *pmu = NULL;
- int ok = 0;
- char *pattern;
-
- if (asprintf(&pattern, "%s*", $1) < 0)
- YYABORT;
-
- while ((pmu = perf_pmu__scan(pmu)) != NULL) {
- char *name = pmu->name;
-
- if (!strncmp(name, "uncore_", 7) &&
- strncmp($1, "uncore_", 7))
- name += 7;
- if (!fnmatch(pattern, name, 0)) {
- if (parse_events_copy_term_list(orig_terms, &terms)) {
- free(pattern);
- YYABORT;
- }
- if (!parse_events_add_pmu(_parse_state, list, pmu->name, terms, true))
- ok++;
- parse_events_terms__delete(terms);
- }
- }
-
- free(pattern);
-
- if (!ok)
- YYABORT;
- }
parse_events_terms__delete($3);
- parse_events_terms__delete(orig_terms);
+ $$ = list;
+}
+|
+PE_NAME '/' '/'
+{
+ struct list_head *list;
+
+ ALLOC_LIST(list);
+
+ if (parse_events_pmu(_parse_state, list, $1, NULL))
+ YYABORT;
+
$$ = list;
}
|
--
2.13.6
next prev parent reply other threads:[~2018-05-04 16:02 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-25 15:59 [GIT PULL 00/12] perf/urgent fixes Arnaldo Carvalho de Melo
2018-04-25 15:59 ` Arnaldo Carvalho de Melo
2018-04-25 15:59 ` [PATCH 01/12] perf machine: Set main kernel end address properly Arnaldo Carvalho de Melo
2018-04-25 15:59 ` [PATCH 02/12] perf list: Remove s390 specific strcmp_cpuid_cmp function Arnaldo Carvalho de Melo
2018-04-25 15:59 ` [PATCH 03/12] perf test: Adapt test case record+probe_libc_inet_pton.sh for s390 Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 04/12] perf stat: Keep the / modifier separator in fallback Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 05/12] perf pmu: Fix pmu events parsing rule Arnaldo Carvalho de Melo
2018-05-03 8:25 ` Adrian Hunter
2018-05-03 10:37 ` Jiri Olsa
2018-05-03 11:38 ` Adrian Hunter
2018-05-03 11:47 ` Jiri Olsa
2018-05-04 16:02 ` Jiri Olsa [this message]
2018-05-06 3:43 ` Andi Kleen
2018-05-06 14:28 ` [PATCH] perf tools: Fix parser for empty pmu terms case Jiri Olsa
2018-05-06 16:34 ` Liang, Kan
2018-05-07 7:21 ` Adrian Hunter
2018-05-07 8:12 ` Jiri Olsa
2018-05-07 15:04 ` Arnaldo Carvalho de Melo
2018-05-07 18:37 ` [PATCH 05/12] perf pmu: Fix pmu events parsing rule Arnaldo Carvalho de Melo
2018-05-07 19:16 ` Jiri Olsa
2018-05-07 19:26 ` Arnaldo Carvalho de Melo
2018-05-07 19:24 ` Arnaldo Carvalho de Melo
2018-05-07 19:24 ` Arnaldo Carvalho de Melo
2018-05-07 19:42 ` Jiri Olsa
2018-04-25 16:00 ` [PATCH 06/12] perf evsel: Disable write_backward for leader sampling group events Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 07/12] perf mem: Document incorrect and missing options Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 08/12] perf record: Fix s390 undefined record__auxtrace_init() return value Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 09/12] perf pmu: Fix core PMU alias list for X86 platform Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 10/12] perf stat: Print out hint for mixed PMU group error Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 11/12] perf evsel: Only fall back group read for leader Arnaldo Carvalho de Melo
2018-04-25 16:00 ` [PATCH 12/12] perf stat: Fix duplicate PMU name for interval print Arnaldo Carvalho de Melo
2018-04-26 5:33 ` [GIT PULL 00/12] perf/urgent fixes Ingo Molnar
2018-04-26 5:33 ` Ingo Molnar
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=20180504160228.GA25229@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dsahern@gmail.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=williams@redhat.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.