From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
David Ahern <dsahern@gmail.com>, Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
"Liang, Kan" <kan.liang@intel.com>
Subject: [PATCH 21/57] perf tools: Add attr_update event scale type
Date: Fri, 16 Oct 2015 12:40:56 +0200 [thread overview]
Message-ID: <1444992092-17897-22-git-send-email-jolsa@kernel.org> (raw)
In-Reply-To: <1444992092-17897-1-git-send-email-jolsa@kernel.org>
Adding scale type attr update event, that stores/transfer
events scale value. The PMU events can define the scale
value which is used to multiply events data.
Link: http://lkml.kernel.org/n/tip-by8wb1atqzhtpx86ybjhwge2@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/tests/attr_update.c | 21 +++++++++++++++++++++
tools/perf/util/event.h | 5 +++++
| 26 ++++++++++++++++++++++++++
| 3 +++
4 files changed, 55 insertions(+)
diff --git a/tools/perf/tests/attr_update.c b/tools/perf/tests/attr_update.c
index a564c3827da4..854a04c37ad6 100644
--- a/tools/perf/tests/attr_update.c
+++ b/tools/perf/tests/attr_update.c
@@ -18,6 +18,22 @@ static int process_event_unit(struct perf_tool *tool __maybe_unused,
return 0;
}
+static int process_event_scale(struct perf_tool *tool __maybe_unused,
+ union perf_event *event,
+ struct perf_sample *sample __maybe_unused,
+ struct machine *machine __maybe_unused)
+{
+ struct attr_update_event *ev = (struct attr_update_event *) event;
+ struct attr_update_event_scale *ev_data;
+
+ ev_data = (struct attr_update_event_scale *) ev->data;
+
+ TEST_ASSERT_VAL("wrong id", ev->id == 123);
+ TEST_ASSERT_VAL("wrong id", ev->type == PERF_ATTR_UPDATE__SCALE);
+ TEST_ASSERT_VAL("wrong scale", ev_data->scale = 0.123);
+ return 0;
+}
+
int test__attr_update(void)
{
struct perf_evlist *evlist;
@@ -38,5 +54,10 @@ int test__attr_update(void)
TEST_ASSERT_VAL("failed to synthesize attr update unit",
!perf_event__synthesize_attr_update_unit(NULL, evsel, process_event_unit));
+ evsel->scale = 0.123;
+
+ TEST_ASSERT_VAL("failed to synthesize attr update scale",
+ !perf_event__synthesize_attr_update_scale(NULL, evsel, process_event_scale));
+
return 0;
}
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 1bccac1b22ec..c3c5085a2855 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -311,6 +311,11 @@ struct attr_event {
enum {
PERF_ATTR_UPDATE__UNIT = 0,
+ PERF_ATTR_UPDATE__SCALE = 1,
+};
+
+struct attr_update_event_scale {
+ double scale;
};
struct attr_update_event {
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 50c6b28486e0..b7a9237ff0b9 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2723,6 +2723,27 @@ perf_event__synthesize_attr_update_unit(struct perf_tool *tool,
return err;
}
+int
+perf_event__synthesize_attr_update_scale(struct perf_tool *tool,
+ struct perf_evsel *evsel,
+ perf_event__handler_t process)
+{
+ struct attr_update_event *ev;
+ struct attr_update_event_scale *ev_data;
+ int err;
+
+ ev = attr_update_event__alloc(sizeof(*ev_data), PERF_ATTR_UPDATE__SCALE, evsel->id[0]);
+ if (ev == NULL)
+ return -ENOMEM;
+
+ ev_data = (struct attr_update_event_scale *) ev->data;
+ ev_data->scale = evsel->scale;
+ err = process(tool, (union perf_event*) ev, NULL, NULL);
+ free(ev);
+ return err;
+}
+
+
int perf_event__synthesize_attrs(struct perf_tool *tool,
struct perf_session *session,
perf_event__handler_t process)
@@ -2787,6 +2808,7 @@ int perf_event__process_attr_update(struct perf_tool *tool __maybe_unused,
struct perf_evlist **pevlist)
{
struct attr_update_event *ev = &event->attr_update;
+ struct attr_update_event_scale *ev_scale;
struct perf_evlist *evlist;
struct perf_evsel *evsel;
@@ -2802,6 +2824,10 @@ int perf_event__process_attr_update(struct perf_tool *tool __maybe_unused,
switch (ev->type) {
case PERF_ATTR_UPDATE__UNIT:
evsel->unit = strdup(ev->data);
+ break;
+ case PERF_ATTR_UPDATE__SCALE:
+ ev_scale = (struct attr_update_event_scale *) ev->data;
+ evsel->scale = ev_scale->scale;
default:
break;
}
--git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 0f00ff55f451..628ee46e14fd 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -108,6 +108,9 @@ int perf_event__synthesize_attrs(struct perf_tool *tool,
int perf_event__synthesize_attr_update_unit(struct perf_tool *tool,
struct perf_evsel *evsel,
perf_event__handler_t process);
+int perf_event__synthesize_attr_update_scale(struct perf_tool *tool,
+ struct perf_evsel *evsel,
+ perf_event__handler_t process);
int perf_event__process_attr(struct perf_tool *tool, union perf_event *event,
struct perf_evlist **pevlist);
int perf_event__process_attr_update(struct perf_tool *tool __maybe_unused,
--
2.4.3
next prev parent reply other threads:[~2015-10-16 10:53 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-16 10:40 [PATCHv4 00/57] perf stat: Add scripting support Jiri Olsa
2015-10-16 10:40 ` [PATCH 01/57] perf tools: Add thread_map event Jiri Olsa
2015-10-16 10:40 ` [PATCH 02/57] perf tools: Add thread_map event sythesize function Jiri Olsa
2015-10-16 10:40 ` [PATCH 03/57] perf tools: Add thread_map__new_event function Jiri Olsa
2015-10-16 10:40 ` [PATCH 04/57] perf tools: Add perf_event__fprintf_thread_map function Jiri Olsa
2015-10-16 10:40 ` [PATCH 05/57] perf tools: Add cpu_map event Jiri Olsa
2015-10-19 20:45 ` Arnaldo Carvalho de Melo
2015-10-22 7:56 ` Jiri Olsa
2015-10-16 10:40 ` [PATCH 06/57] perf tools: Add cpu_map event synthesize function Jiri Olsa
2015-10-16 10:40 ` [PATCH 07/57] perf tools: Add cpu_map__empty_new function Jiri Olsa
2015-10-16 10:40 ` [PATCH 08/57] perf tools: Add cpu_map__new_event function Jiri Olsa
2015-10-16 10:40 ` [PATCH 09/57] perf tools: Add perf_event__fprintf_cpu_map function Jiri Olsa
2015-10-16 10:40 ` [PATCH 10/57] perf tools: Add stat config event Jiri Olsa
2015-10-16 10:40 ` [PATCH 11/57] perf tools: Add stat config event synthesize function Jiri Olsa
2015-10-16 10:40 ` [PATCH 12/57] perf tools: Add stat config event read function Jiri Olsa
2015-10-16 10:40 ` [PATCH 13/57] perf tools: Add stat event Jiri Olsa
2015-10-16 10:40 ` [PATCH 14/57] perf tools: Add stat event synthesize function Jiri Olsa
2015-10-16 10:40 ` [PATCH 15/57] perf tools: Add stat event read function Jiri Olsa
2015-10-16 10:40 ` [PATCH 16/57] perf tools: Add stat round event Jiri Olsa
2015-10-16 10:40 ` [PATCH 17/57] perf tools: Add stat round event synthesize function Jiri Olsa
2015-10-16 10:40 ` [PATCH 18/57] perf tools: Add stat events fprintf functions Jiri Olsa
2015-10-16 10:40 ` [PATCH 19/57] perf tools: Add attr_update event Jiri Olsa
2015-10-19 21:00 ` Arnaldo Carvalho de Melo
2015-10-22 8:01 ` Jiri Olsa
2015-10-25 12:27 ` Jiri Olsa
2015-10-16 10:40 ` [PATCH 20/57] perf tools: Add attr_update event unit type Jiri Olsa
2015-10-16 10:40 ` Jiri Olsa [this message]
2015-10-16 10:40 ` [PATCH 22/57] perf tools: Add attr_update event name type Jiri Olsa
2015-10-16 10:40 ` [PATCH 23/57] perf tools: Add attr_update event cpus type Jiri Olsa
2015-10-16 10:40 ` [PATCH 24/57] perf tools: Add perf_event__fprintf_attr_update function Jiri Olsa
2015-10-16 10:41 ` [PATCH 25/57] perf report: Display newly added events in raw dump Jiri Olsa
2015-10-16 10:41 ` [PATCH 26/57] perf tools: Introduce stat feature Jiri Olsa
2015-10-16 10:41 ` [PATCH 27/57] perf tools: Move id_offset out of struct perf_evsel union Jiri Olsa
2015-10-16 10:41 ` [PATCH 28/57] perf stat: Rename perf_stat struct into perf_stat_evsel Jiri Olsa
2015-10-19 21:01 ` Arnaldo Carvalho de Melo
2015-10-20 7:48 ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-10-16 10:41 ` [PATCH 29/57] perf stat: Add AGGR_UNSET mode Jiri Olsa
2015-10-19 21:02 ` Arnaldo Carvalho de Melo
2015-10-20 7:48 ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-10-16 10:41 ` [PATCH 30/57] perf stat record: Add record command Jiri Olsa
2015-10-16 10:41 ` [PATCH 31/57] perf stat record: Initialize record features Jiri Olsa
2015-10-16 10:41 ` [PATCH 32/57] perf stat record: Synthesize stat record data Jiri Olsa
2015-10-16 10:41 ` [PATCH 33/57] perf stat record: Store events IDs in perf data file Jiri Olsa
2015-10-16 10:41 ` [PATCH 34/57] perf stat record: Add pipe support for record command Jiri Olsa
2015-10-16 10:41 ` [PATCH 35/57] perf stat record: Write stat events on record Jiri Olsa
2015-10-16 10:41 ` [PATCH 36/57] perf stat record: Write stat round " Jiri Olsa
2015-10-16 10:41 ` [PATCH 37/57] perf stat record: Do not allow record with multiple runs mode Jiri Olsa
2015-10-16 10:41 ` [PATCH 38/57] perf stat record: Synthesize attr update events Jiri Olsa
2015-10-16 10:41 ` [PATCH 39/57] perf tools: Make cpu_map__build_map global Jiri Olsa
2015-10-19 21:03 ` Arnaldo Carvalho de Melo
2015-10-20 7:49 ` [tip:perf/core] perf cpu_map: " tip-bot for Jiri Olsa
2015-10-16 10:41 ` [PATCH 40/57] perf tools: Add data arg to cpu_map__build_map callback Jiri Olsa
2015-10-19 21:04 ` Arnaldo Carvalho de Melo
2015-10-20 7:49 ` [tip:perf/core] perf cpu_map: " tip-bot for Jiri Olsa
2015-10-16 10:41 ` [PATCH 41/57] perf stat report: Cache aggregated map entries in extra cpumap Jiri Olsa
2015-10-16 10:41 ` [PATCH 42/57] perf stat report: Add report command Jiri Olsa
2015-10-16 10:41 ` [PATCH 43/57] perf stat report: Process cpu/threads maps Jiri Olsa
2015-10-16 10:41 ` [PATCH 44/57] perf stat report: Process stat config event Jiri Olsa
2015-10-16 10:41 ` [PATCH 45/57] perf stat report: Add support to initialize aggr_map from file Jiri Olsa
2015-10-16 10:41 ` [PATCH 46/57] perf stat report: Process stat and stat round events Jiri Olsa
2015-10-16 10:41 ` [PATCH 47/57] perf stat report: Process attr update events Jiri Olsa
2015-10-16 10:41 ` [PATCH 48/57] perf stat report: Move csv_sep initialization before report command Jiri Olsa
2015-10-16 10:41 ` [PATCH 49/57] perf stat report: Allow to override aggr_mode Jiri Olsa
2015-10-16 10:41 ` [PATCH 50/57] perf script: Check output fields only for samples Jiri Olsa
2015-10-19 21:06 ` Arnaldo Carvalho de Melo
2015-10-20 7:49 ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-10-16 10:41 ` [PATCH 51/57] perf script: Process cpu/threads maps Jiri Olsa
2015-10-16 10:41 ` [PATCH 52/57] perf script: Process stat config event Jiri Olsa
2015-10-16 10:41 ` [PATCH 53/57] perf script: Add process_stat/process_stat_interval scripting interface Jiri Olsa
2015-10-16 10:41 ` [PATCH 54/57] perf script: Add stat default handlers Jiri Olsa
2015-10-16 10:41 ` [PATCH 55/57] perf script: Display stat events by default Jiri Olsa
2015-10-16 10:41 ` [PATCH 56/57] perf script: Add python support for stat events Jiri Olsa
2015-10-16 10:41 ` [PATCH 57/57] perf script: Add stat-cpi.py script Jiri Olsa
2015-10-19 19:48 ` [PATCHv4 00/57] perf stat: Add scripting support Liang, Kan
2015-10-21 2:03 ` Namhyung Kim
2015-10-21 10:22 ` Jiri Olsa
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=1444992092-17897-22-git-send-email-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=dsahern@gmail.com \
--cc=kan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.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
Powered by JetHome