[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1428993665-2133-3-git-send-email-sukadev@linux.vnet.ibm.com>
Date: Mon, 13 Apr 2015 23:40:55 -0700
From: Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>
To: mingo@...hat.com, ak@...ux.intel.com,
Michael Ellerman <mpe@...erman.id.au>,
Jiri Olsa <jolsa@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: peterz@...radead.org, namhyung@...nel.org,
linuxppc-dev@...ts.ozlabs.org, <linux-kernel@...r.kernel.org>
Subject: [PATCH v9 02/11] perf, tools: Add support for text descriptions of events and alias add
From: Andi Kleen <ak@...ux.intel.com>
Change pmu.c to allow descriptions of events and add interfaces
to add aliases at runtime from another file. To be used by jevents in
a followon patch
Acked-by: Namhyung Kim <namhyung@...nel.org>
Signed-off-by: Andi Kleen <ak@...ux.intel.com>
Signed-off-by: Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>
---
Changelog[v9] by Sukadev Bhattiprolu
Rebase to 4.0
v2: Move perf list changes to other patch.
---
tools/perf/util/json.c | 1 +
tools/perf/util/pmu.c | 48 +++++++++++++++++++++++++++++++++---------------
tools/perf/util/pmu.h | 1 +
3 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/tools/perf/util/json.c b/tools/perf/util/json.c
index e20001f..2219844 100644
--- a/tools/perf/util/json.c
+++ b/tools/perf/util/json.c
@@ -38,6 +38,7 @@
#include "jsmn.h"
#include "json.h"
#include <linux/kernel.h>
+#include "debug.h"
static char *mapfile(const char *fn, size_t *size)
{
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 4841167..527da74 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -198,17 +198,12 @@ static int perf_pmu__parse_snapshot(struct perf_pmu_alias *alias,
return 0;
}
-static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FILE *file)
+static int __perf_pmu__new_alias(struct list_head *list, char *name, char *dir,
+ char *desc, char *val)
{
struct perf_pmu_alias *alias;
- char buf[256];
int ret;
- ret = fread(buf, 1, sizeof(buf), file);
- if (ret == 0)
- return -EINVAL;
- buf[ret] = 0;
-
alias = malloc(sizeof(*alias));
if (!alias)
return -ENOMEM;
@@ -218,26 +213,49 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
alias->unit[0] = '\0';
alias->per_pkg = false;
- ret = parse_events_terms(&alias->terms, buf);
+ ret = parse_events_terms(&alias->terms, val);
if (ret) {
+ pr_err("Cannot parse alias %s: %d\n", val, ret);
free(alias);
return ret;
}
alias->name = strdup(name);
- /*
- * load unit name and scale if available
- */
- perf_pmu__parse_unit(alias, dir, name);
- perf_pmu__parse_scale(alias, dir, name);
- perf_pmu__parse_per_pkg(alias, dir, name);
- perf_pmu__parse_snapshot(alias, dir, name);
+
+ if (dir) {
+ /*
+ * load unit name and scale if available
+ */
+ perf_pmu__parse_unit(alias, dir, name);
+ perf_pmu__parse_scale(alias, dir, name);
+ perf_pmu__parse_per_pkg(alias, dir, name);
+ perf_pmu__parse_snapshot(alias, dir, name);
+ }
+
+ alias->desc = desc ? strdup(desc) : NULL;
list_add_tail(&alias->list, list);
return 0;
}
+static int perf_pmu__new_alias(struct list_head *list,
+ char *dir,
+ char *name,
+ FILE *file)
+{
+ char buf[256];
+ int ret;
+
+ ret = fread(buf, 1, sizeof(buf), file);
+ if (ret == 0)
+ return -EINVAL;
+ buf[ret] = 0;
+
+ return __perf_pmu__new_alias(list, name, dir, NULL, buf);
+}
+
+
static inline bool pmu_alias_info_file(char *name)
{
size_t len;
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 6b1249f..d06496d 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -37,6 +37,7 @@ struct perf_pmu_info {
struct perf_pmu_alias {
char *name;
+ char *desc;
struct list_head terms; /* HEAD struct parse_events_term -> list */
struct list_head list; /* ELEM */
char unit[UNIT_MAX_LEN+1];
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists