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]
Date:	Fri, 24 Jul 2015 09:48:30 -0400
From:	kan.liang@...el.com
To:	a.p.zijlstra@...llo.nl, acme@...nel.org
Cc:	luto@...nel.org, mingo@...hat.com, eranian@...gle.com,
	ak@...ux.intel.com, mark.rutland@....com, adrian.hunter@...el.com,
	jolsa@...nel.org, namhyung@...nel.org,
	linux-kernel@...r.kernel.org, Kan Liang <kan.liang@...el.com>
Subject: [PATCH V2 4/6] perf,tools: save misc sample read value in struct perf_sample

From: Kan Liang <kan.liang@...el.com>

Save group read results from cycles/ref-cycles/TSC/ASTATE/MSTATE in
struct perf_sample. The following sample process function can easily
use them to caculate freq/CPU%/CORE_BUSY% and add them in hists.

Signed-off-by: Kan Liang <kan.liang@...el.com>
---
 tools/perf/util/event.h   | 11 +++++++++++
 tools/perf/util/session.c | 16 ++++++++++++++++
 tools/perf/util/session.h | 10 ----------
 3 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index c53f363..f7aabe3 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -176,6 +176,16 @@ enum {
 	PERF_IP_FLAG_TRACE_BEGIN	|\
 	PERF_IP_FLAG_TRACE_END)
 
+enum perf_freq_perf_index {
+	FREQ_PERF_TSC		= 0,
+	FREQ_PERF_APERF		= 1,
+	FREQ_PERF_MPERF		= 2,
+	FREQ_PERF_CYCLES	= 3,
+	FREQ_PERF_REF_CYCLES	= 4,
+
+	FREQ_PERF_MAX
+};
+
 struct perf_sample {
 	u64 ip;
 	u32 pid, tid;
@@ -191,6 +201,7 @@ struct perf_sample {
 	u64 data_src;
 	u32 flags;
 	u16 insn_len;
+	u64 freq_perf_data[FREQ_PERF_MAX];
 	void *raw_data;
 	struct ip_callchain *callchain;
 	struct branch_stack *branch_stack;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 7f628d9..7da36b1 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -998,6 +998,8 @@ static int deliver_sample_value(struct perf_evlist *evlist,
 				struct machine *machine)
 {
 	struct perf_sample_id *sid = perf_evlist__id2sid(evlist, v->id);
+	struct perf_evsel *evsel;
+	u64 nr = 0;
 
 	if (sid) {
 		sample->id     = v->id;
@@ -1010,6 +1012,20 @@ static int deliver_sample_value(struct perf_evlist *evlist,
 		return 0;
 	}
 
+	if (perf_evsel__is_group_leader(sid->evsel)) {
+		evsel = sid->evsel;
+		SET_FREQ_PERF_VALUE(evsel, sample->freq_perf_data,
+				    sample->read.group.values[nr].value);
+		evlist__for_each_continue(evlist, evsel) {
+			if ((evsel->leader != sid->evsel) ||
+			    (++nr >= sample->read.group.nr))
+				break;
+
+			SET_FREQ_PERF_VALUE(evsel, sample->freq_perf_data,
+					    sample->read.group.values[nr].value);
+		}
+	}
+
 	return tool->sample(tool, event, sample, sid->evsel, machine);
 }
 
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index db218ba..ee23872 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -47,16 +47,6 @@ struct perf_session {
 #define PERF_MSR_APERF		1
 #define PERF_MSR_MPERF		2
 
-enum perf_freq_perf_index {
-	FREQ_PERF_TSC		= 0,
-	FREQ_PERF_APERF		= 1,
-	FREQ_PERF_MPERF		= 2,
-	FREQ_PERF_CYCLES	= 3,
-	FREQ_PERF_REF_CYCLES	= 4,
-
-	FREQ_PERF_MAX
-};
-
 #define SET_FREQ_PERF_VALUE(event, array, value)			\
 {									\
 	if (event->attr.type == msr_pmu_type) {				\
-- 
1.8.3.1

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