From: Matt Fleming <matt@console-pimps.org>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>, Jiri Olsa <jolsa@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Andi Kleen <andi@firstfloor.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Kanaka Juvva <kanaka.d.juvva@intel.com>,
Jiri Olsa <jolsa@kernel.org>
Subject: [PATCH 02/11] perf tools: Implement snapshot event file logic
Date: Fri, 14 Nov 2014 21:15:03 +0000 [thread overview]
Message-ID: <1415999712-5850-3-git-send-email-matt@console-pimps.org> (raw)
In-Reply-To: <1415999712-5850-1-git-send-email-matt@console-pimps.org>
From: Jiri Olsa <jolsa@kernel.org>
Adding support to parse and read the snapshot file,
and using this information to omit the compute_delta
function logic.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/evsel.c | 6 ++++--
tools/perf/util/evsel.h | 1 +
tools/perf/util/parse-events.c | 1 +
tools/perf/util/pmu.c | 47 ++++++++++++++++++++++++++++++++----------
tools/perf/util/pmu.h | 2 ++
5 files changed, 44 insertions(+), 13 deletions(-)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 4aced93672a8..a7a26b46e21c 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -900,7 +900,8 @@ int __perf_evsel__read_on_cpu(struct perf_evsel *evsel,
if (readn(FD(evsel, cpu, thread), &count, nv * sizeof(u64)) < 0)
return -errno;
- compute_deltas(evsel, cpu, &count);
+ if (!evsel->snapshot)
+ compute_deltas(evsel, cpu, &count);
if (scale) {
if (count.run == 0)
@@ -947,7 +948,8 @@ int __perf_evsel__read(struct perf_evsel *evsel,
}
}
- compute_deltas(evsel, -1, aggr);
+ if (!evsel->snapshot)
+ compute_deltas(evsel, -1, aggr);
evsel->counts->scaled = 0;
if (scale) {
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 13ca8a7693e4..d9fa85e203f8 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -73,6 +73,7 @@ struct perf_evsel {
char *name;
double scale;
const char *unit;
+ bool snapshot;
struct event_format *tp_format;
union {
void *priv;
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 5a373483f0e4..77b43fe43d55 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -682,6 +682,7 @@ int parse_events_add_pmu(struct list_head *list, int *idx,
evsel->unit = info.unit;
evsel->scale = info.scale;
evsel->per_pkg = info.per_pkg;
+ evsel->snapshot = info.snapshot;
}
return evsel ? 0 : -ENOMEM;
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index f003b5a9e059..5c9c4947cfb4 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -181,6 +181,23 @@ perf_pmu__parse_per_pkg(struct perf_pmu_alias *alias, char *dir, char *name)
return 0;
}
+static int perf_pmu__parse_snapshot(struct perf_pmu_alias *alias,
+ char *dir, char *name)
+{
+ char path[PATH_MAX];
+ int fd;
+
+ snprintf(path, PATH_MAX, "%s/%s.snapshot", dir, name);
+
+ fd = open(path, O_RDONLY);
+ if (fd == -1)
+ return -1;
+
+ alias->snapshot = true;
+ close(fd);
+ return 0;
+}
+
static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FILE *file)
{
struct perf_pmu_alias *alias;
@@ -214,6 +231,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
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);
list_add_tail(&alias->list, list);
@@ -231,6 +249,8 @@ static inline bool pmu_alias_info_file(char *name)
return true;
if (len > 8 && !strcmp(name + len - 8, ".per-pkg"))
return true;
+ if (len > 9 && !strcmp(name + len - 9, ".snapshot"))
+ return true;
return false;
}
@@ -639,23 +659,27 @@ static struct perf_pmu_alias *pmu_find_alias(struct perf_pmu *pmu,
}
-static int check_unit_scale(struct perf_pmu_alias *alias,
- const char **unit, double *scale)
+static int check_info_data(struct perf_pmu_alias *alias,
+ struct perf_pmu_info *info)
{
/*
* Only one term in event definition can
- * define unit and scale, fail if there's
- * more than one.
+ * define unit, scale and snapshot, fail
+ * if there's more than one.
*/
- if ((*unit && alias->unit) ||
- (*scale && alias->scale))
+ if ((info->unit && alias->unit) ||
+ (info->scale && alias->scale) ||
+ (info->snapshot && alias->snapshot))
return -EINVAL;
if (alias->unit)
- *unit = alias->unit;
+ info->unit = alias->unit;
if (alias->scale)
- *scale = alias->scale;
+ info->scale = alias->scale;
+
+ if (alias->snapshot)
+ info->snapshot = alias->snapshot;
return 0;
}
@@ -677,8 +701,9 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
* Mark unit and scale as not set
* (different from default values, see below)
*/
- info->unit = NULL;
- info->scale = 0.0;
+ info->unit = NULL;
+ info->scale = 0.0;
+ info->snapshot = false;
list_for_each_entry_safe(term, h, head_terms, list) {
alias = pmu_find_alias(pmu, term);
@@ -688,7 +713,7 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
if (ret)
return ret;
- ret = check_unit_scale(alias, &info->unit, &info->scale);
+ ret = check_info_data(alias, info);
if (ret)
return ret;
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index c3a74e0e17a2..6b1249fbdb5f 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -30,6 +30,7 @@ struct perf_pmu_info {
const char *unit;
double scale;
bool per_pkg;
+ bool snapshot;
};
#define UNIT_MAX_LEN 31 /* max length for event unit name */
@@ -41,6 +42,7 @@ struct perf_pmu_alias {
char unit[UNIT_MAX_LEN+1];
double scale;
bool per_pkg;
+ bool snapshot;
};
struct perf_pmu *perf_pmu__find(const char *name);
--
1.9.3
next prev parent reply other threads:[~2014-11-14 21:18 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-14 21:15 [PATCH v4 00/11] perf: Intel Cache QoS Monitoring support Matt Fleming
2014-11-14 21:15 ` [PATCH 01/11] perf tools: Parse event per-package info files Matt Fleming
2014-11-14 21:15 ` Matt Fleming [this message]
2014-11-14 21:15 ` [PATCH 03/11] perf: Make perf_cgroup_from_task() global Matt Fleming
2014-11-14 21:15 ` [PATCH 04/11] perf: Add ->count() function to read per-package counters Matt Fleming
2014-11-14 21:15 ` [PATCH 05/11] perf: Move cgroup init before PMU ->event_init() Matt Fleming
2014-11-14 21:15 ` [PATCH 06/11] x86: Add support for Intel Cache QoS Monitoring (CQM) detection Matt Fleming
2014-11-14 21:15 ` [PATCH 07/11] perf/x86/intel: Add Intel Cache QoS Monitoring support Matt Fleming
2014-11-14 21:15 ` [PATCH 08/11] perf/x86/intel: Implement LRU monitoring ID allocation for CQM Matt Fleming
2014-11-14 21:15 ` [PATCH v4 09/11] perf/x86/intel: Support task events with Intel CQM Matt Fleming
2014-11-14 21:15 ` [PATCH v4 10/11] perf/x86/intel: Perform rotation on Intel CQM RMIDs Matt Fleming
2015-01-06 16:13 ` Peter Zijlstra
2015-01-06 17:17 ` Peter Zijlstra
2015-01-09 12:14 ` Matt Fleming
2015-01-09 13:02 ` Peter Zijlstra
2015-01-09 15:24 ` Matt Fleming
2015-01-09 15:58 ` Peter Zijlstra
2015-01-15 15:31 ` Matt Fleming
2015-01-15 19:37 ` Matt Fleming
2015-01-06 17:36 ` Peter Zijlstra
2015-01-09 12:22 ` Matt Fleming
2015-01-09 12:59 ` Peter Zijlstra
2015-01-07 12:16 ` Peter Zijlstra
2015-01-09 12:55 ` Matt Fleming
2015-01-09 12:58 ` Peter Zijlstra
2015-01-11 10:45 ` Matt Fleming
2014-11-14 21:15 ` [PATCH 11/11] perf/x86/intel: Enable conflicting event scheduling for CQM Matt Fleming
2015-01-08 11:49 ` Peter Zijlstra
2015-01-09 12:56 ` Matt Fleming
2015-01-08 11:51 ` Peter Zijlstra
2015-01-09 14:27 ` Matt Fleming
2014-11-25 14:55 ` [PATCH v4 00/11] perf: Intel Cache QoS Monitoring support Matt Fleming
2014-12-18 7:59 ` Matt Fleming
-- strict thread matches above, loose matches on Subject: below --
2014-11-06 12:23 [PATCH v3 " Matt Fleming
2014-11-06 12:23 ` [PATCH 02/11] perf tools: Implement snapshot event file logic Matt Fleming
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=1415999712-5850-3-git-send-email-matt@console-pimps.org \
--to=matt@console-pimps.org \
--cc=acme@kernel.org \
--cc=andi@firstfloor.org \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=kanaka.d.juvva@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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).