lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1444161335-26734-21-git-send-email-jolsa@kernel.org>
Date:	Tue,  6 Oct 2015 21:54:59 +0200
From:	Jiri Olsa <jolsa@...nel.org>
To:	Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:	lkml <linux-kernel@...r.kernel.org>,
	David Ahern <dsahern@...il.com>,
	Ingo Molnar <mingo@...nel.org>,
	Namhyung Kim <namhyung@...nel.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	"Liang, Kan" <kan.liang@...el.com>
Subject: [PATCH 20/56] perf tools: Add attr_update event scale type

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@...nel.org>
---
 tools/perf/tests/attr_update.c | 17 +++++++++++++++++
 tools/perf/util/event.h        |  3 +++
 tools/perf/util/header.c       | 22 ++++++++++++++++++++++
 tools/perf/util/header.h       |  3 +++
 4 files changed, 45 insertions(+)

diff --git a/tools/perf/tests/attr_update.c b/tools/perf/tests/attr_update.c
index cfdb56cf3a95..bb190d3aaefd 100644
--- a/tools/perf/tests/attr_update.c
+++ b/tools/perf/tests/attr_update.c
@@ -17,6 +17,18 @@ 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;
+
+	TEST_ASSERT_VAL("wrong id", ev->id == 123);
+	TEST_ASSERT_VAL("wrong scale", ev->scale = 0.123);
+	return 0;
+}
+
 int test__attr_update(void)
 {
 	struct perf_evlist *evlist;
@@ -37,5 +49,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 501bb4a40982..d9248975585b 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -285,6 +285,7 @@ struct attr_event {
 
 enum {
 	PERF_ATTR_UPDATE__UNIT  = 0,
+	PERF_ATTR_UPDATE__SCALE = 1,
 };
 
 struct attr_update_event {
@@ -292,6 +293,8 @@ struct attr_update_event {
 	u64 type;
 	u64 id;
 
+	double scale;
+
 	/* Having 'str' for all string updates. */
 	char str[];
 };
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index a3f4bd45d880..a47ac44f6a59 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2723,6 +2723,25 @@ 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;
+	int err;
+
+	ev = attr_update_event__alloc(0, PERF_ATTR_UPDATE__SCALE, evsel->id[0]);
+	if (ev == NULL)
+		return -ENOMEM;
+
+	ev->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)
@@ -2802,6 +2821,9 @@ int perf_event__process_attr_update(struct perf_tool *tool __maybe_unused,
 	switch (ev->type) {
 	case PERF_ATTR_UPDATE__UNIT:
 		evsel->unit = strdup(ev->str);
+		break;
+	case PERF_ATTR_UPDATE__SCALE:
+		evsel->scale = ev->scale;
 	default:
 		break;
 	}
diff --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

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ