summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/pmu.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-01-25 11:12:23 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-25 11:12:23 -0800
commit82c477669a4665eb4e52030792051e0559ee2a36 (patch)
tree02542b4e7d33f157aac83f0dadc988c5d4511544 /tools/perf/util/pmu.c
parentf6d13daaddeb6e63b15a93bf36a80173bafd29bf (diff)
parent993e5ee67a90c7b6a5dbb61b9c31df2955afff46 (diff)
downloadblackbird-op-linux-82c477669a4665eb4e52030792051e0559ee2a36.tar.gz
blackbird-op-linux-82c477669a4665eb4e52030792051e0559ee2a36.zip
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar: "A handful of tooling fixes" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf symbols: Load map before using map->map_ip() perf tools: Fix traceevent plugin path definitions perf symbols: Fix JIT symbol resolution on heap perf stat: Fix memory corruption of xyarray when cpumask is used perf evsel: Remove duplicate member zeroing after free perf tools: Ensure sscanf does not overrun the "mem" field perf stat: fix NULL pointer reference bug with event unit perf tools: Add support for the xtensa architecture perf session: Free cpu_map in perf_session__cpu_bitmap perf timechart: Fix wrong SVG height
Diffstat (limited to 'tools/perf/util/pmu.c')
-rw-r--r--tools/perf/util/pmu.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index d9cab4d27192..b752ecb40d86 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -105,7 +105,7 @@ static int perf_pmu__parse_scale(struct perf_pmu_alias *alias, char *dir, char *
char scale[128];
int fd, ret = -1;
char path[PATH_MAX];
- char *lc;
+ const char *lc;
snprintf(path, PATH_MAX, "%s/%s.scale", dir, name);
@@ -609,7 +609,7 @@ static struct perf_pmu_alias *pmu_find_alias(struct perf_pmu *pmu,
static int check_unit_scale(struct perf_pmu_alias *alias,
- char **unit, double *scale)
+ const char **unit, double *scale)
{
/*
* Only one term in event definition can
@@ -634,14 +634,18 @@ static int check_unit_scale(struct perf_pmu_alias *alias,
* defined for the alias
*/
int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
- char **unit, double *scale)
+ const char **unit, double *scale)
{
struct parse_events_term *term, *h;
struct perf_pmu_alias *alias;
int ret;
+ /*
+ * Mark unit and scale as not set
+ * (different from default values, see below)
+ */
*unit = NULL;
- *scale = 0;
+ *scale = 0.0;
list_for_each_entry_safe(term, h, head_terms, list) {
alias = pmu_find_alias(pmu, term);
@@ -658,6 +662,18 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
list_del(&term->list);
free(term);
}
+
+ /*
+ * if no unit or scale foundin aliases, then
+ * set defaults as for evsel
+ * unit cannot left to NULL
+ */
+ if (*unit == NULL)
+ *unit = "";
+
+ if (*scale == 0.0)
+ *scale = 1.0;
+
return 0;
}
OpenPOWER on IntegriCloud