mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: Jiri Olsa <jolsa@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"irogers@google.com" <irogers@google.com>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>
Subject: [Question] perf tools: lex parsing issue
Date: Mon, 23 Aug 2021 12:27:43 +0100	[thread overview]
Message-ID: <2e52bc21-8e60-f1fc-804b-d8993ca7c482@huawei.com> (raw)

Hi jirka,

If you remember from some time ago we discussed how the lex parsing 
creates strange aliases:

https://lore.kernel.org/lkml/20200320093006.GA1343171@krava/

I am no expert on l+y, but it seems that we simply don't set the term 
config field for known term types. Well, not for 
PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD type anyway.

This super hack resolves that issue:

--->8----

--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -765,7 +765,12 @@ event_config ',' event_term
struct list_head *head = $1;
struct parse_events_term *term = $3

+ if (term->type_term == PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD) {
+ 	term->config = strdup("period");
+ }
+
if (!head) {
	parse_events_term__delete(term);
	YYABORT;
-- 

----8-----

So we get "umask=0x80,period=0x30d40,event=0x6" now, rather than 
"umask=0x80,(null)=0x30d40,event=0x6", for the perf_pmu_alias.str, as an 
example.

Did you ever get a chance to look into this issue? Do you know how could 
or should this field be set properly?

Some more background:
The reason I was looking at this is because I think it causes a problem 
for pmu-events (JSONs) aliasing for some PMUs. Specifically it's PMU 
which use "config=xxx" in sysfs files in 
/sys/bus/event_source/devices/PMUx/events/, rather than "event=xxx". The 
actual problem is that I trigger this warn in pmu.c:

static void perf_pmu_assign_str(char *name, const char *field, char 
**old_str,
char **new_str)
{

if (*new_str) { /* Have new string, check with old */
	if (strcasecmp(*old_str, *new_str))
		pr_debug("alias %s differs i ... <---

As I get "config=event=0xXXX" vs "config=(null)=0xXXX"

As I am not sure how to solve that yet, but, since we have 
config=(null), I thought it best to solve the first issue first.

Thanks,
John

             reply	other threads:[~2021-08-23 11:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 11:27 John Garry [this message]
2021-08-25  0:13 ` Ian Rogers
2021-08-25 14:36   ` John Garry
2021-08-25 16:47     ` Ian Rogers
2021-08-25 16:58       ` John Garry

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=2e52bc21-8e60-f1fc-804b-d8993ca7c482@huawei.com \
    --to=john.garry@huawei.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@redhat.com \
    --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 \
    /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

all inboxes | Powered by JetHome®