linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Andi Kleen <ak@linux.intel.com>
Cc: Andi Kleen <andi@firstfloor.org>,
	acme@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org,
	eranian@google.com, namhyung@kernel.org, peterz@infradead.org,
	mingo@kernel.org
Subject: Re: [PATCH 1/9] perf, tools: Dont stop PMU parsing on alias parse error
Date: Tue, 11 Aug 2015 16:39:17 +0200	[thread overview]
Message-ID: <20150811143917.GC10703@krava.brq.redhat.com> (raw)
In-Reply-To: <20150811134027.GE4524@tassilo.jf.intel.com>

On Tue, Aug 11, 2015 at 06:40:27AM -0700, Andi Kleen wrote:
> On Tue, Aug 11, 2015 at 03:24:27PM +0200, Jiri Olsa wrote:
> > On Tue, Aug 11, 2015 at 06:14:57AM -0700, Andi Kleen wrote:
> > > > Which attribute parsing is failing for you?
> > > 
> > > The new .agg-per-core attribute I added later in the series.
> > > I think it will happen to any not-yet-known attribute.
> > 
> > alias can contain only terms defined in formats directory,
> > and the *.XXX attributes parsing does not return error code
> > 
> > can't see the failure, please get some example
> 
> Apply the kernel patch that adds several .agg-per-core attributes
> Then try to use any cpu/.../ event
> 
> % perf stat -e cpu/event=0x3c/ true
> invalid or unsupported event: 'cpu/event=0x3c/'
> 
> because the PMU parsing bailed out.

ugh right, the new attribute wont be recognized..

how about recognizing attribute based on the '.' prefix being
existing file rather than the suffix like in the attached patch

jirka


---
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index d4b0e6454bc6..937ecc35a60e 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -258,21 +258,23 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
 	return __perf_pmu__new_alias(list, dir, name, NULL, buf);
 }
 
-static inline bool pmu_alias_info_file(char *name)
+static inline bool pmu_alias_attr_file(char *dir, char *name)
 {
-	size_t len;
-
-	len = strlen(name);
-	if (len > 5 && !strcmp(name + len - 5, ".unit"))
-		return true;
-	if (len > 6 && !strcmp(name + len - 6, ".scale"))
-		return true;
-	if (len > 8 && !strcmp(name + len - 8, ".per-pkg"))
-		return true;
-	if (len > 9 && !strcmp(name + len - 9, ".snapshot"))
-		return true;
+	bool ret = false;
+	struct stat st;
+	char *path, *s;
 
-	return false;
+	if (asprintf(&path, "%s/%s", dir, name) == -1)
+		return false;
+
+	s = strrchr(path, '.');
+	if (s) {
+		*s = 0;
+		ret = !stat(path, &st);
+	}
+
+	free(path);
+	return ret;
 }
 
 /*
@@ -300,7 +302,7 @@ static int pmu_aliases_parse(char *dir, struct list_head *head)
 		/*
 		 * skip info files parsed in perf_pmu__new_alias()
 		 */
-		if (pmu_alias_info_file(name))
+		if (pmu_alias_attr_file(dir, name))
 			continue;
 
 		snprintf(path, PATH_MAX, "%s/%s", dir, name);

  reply	other threads:[~2015-08-11 14:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-08  1:06 Add top down metrics to perf stat Andi Kleen
2015-08-08  1:06 ` [PATCH 1/9] perf, tools: Dont stop PMU parsing on alias parse error Andi Kleen
2015-08-11 13:07   ` Jiri Olsa
2015-08-11 13:14     ` Andi Kleen
2015-08-11 13:24       ` Jiri Olsa
2015-08-11 13:40         ` Andi Kleen
2015-08-11 14:39           ` Jiri Olsa [this message]
2015-08-11 16:59             ` Andi Kleen
2015-08-08  1:06 ` [PATCH 2/9] perf, tools, stat: Support up-scaling of events Andi Kleen
2015-08-11 13:25   ` Jiri Olsa
2015-08-11 13:38     ` Andi Kleen
2015-08-11 13:54       ` Jiri Olsa
2015-08-11 17:00         ` Andi Kleen
2015-08-11 17:13           ` Jiri Olsa
2015-08-11 17:17             ` Andi Kleen
2015-08-08  1:06 ` [PATCH 3/9] perf, tools, stat: Basic support for TopDown in perf stat Andi Kleen
2015-08-08  1:06 ` [PATCH 4/9] perf, tools, stat: Add computation of TopDown formulas Andi Kleen
2015-08-08  1:06 ` [PATCH 5/9] x86, perf: Support sysfs files depending on SMT status Andi Kleen
2015-08-08  1:06 ` [PATCH 6/9] x86, perf: Add Top Down events to Intel Core Andi Kleen
2015-08-08  1:06 ` [PATCH 7/9] x86, perf: Add Top Down events to Intel Atom Andi Kleen
2015-08-08  1:06 ` [PATCH 8/9] perf, tools, stat: Add extra output of counter values with -v Andi Kleen
2015-08-08  1:06 ` [PATCH 9/9] perf, tools, stat: Force --per-core mode for .agg-per-core aliases Andi Kleen

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=20150811143917.GC10703@krava.brq.redhat.com \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=eranian@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).