From: kan.liang@intel.com
To: a.p.zijlstra@chello.nl, acme@kernel.org
Cc: luto@kernel.org, mingo@redhat.com, eranian@google.com,
ak@linux.intel.com, mark.rutland@arm.com,
adrian.hunter@intel.com, jolsa@kernel.org, namhyung@kernel.org,
linux-kernel@vger.kernel.org, Kan Liang <kan.liang@intel.com>
Subject: [PATCH 3/5] perf,tools: save misc sample read value in struct perf_sample
Date: Thu, 23 Jul 2015 07:49:41 -0400 [thread overview]
Message-ID: <1437652183-62080-4-git-send-email-kan.liang@intel.com> (raw)
In-Reply-To: <1437652183-62080-1-git-send-email-kan.liang@intel.com>
From: Kan Liang <kan.liang@intel.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@intel.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 6dd20b5..939dfed 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -999,6 +999,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;
@@ -1011,6 +1013,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 df2094d..8c3cae8 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -46,16 +46,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
next prev parent reply other threads:[~2015-07-23 19:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-23 11:49 [PATCH 0/5] Freq/CPU%/CORE_BUSY% support kan.liang
2015-07-23 11:49 ` [PATCH 1/5] perf,tools: introduce get_cpu_max_freq kan.liang
2015-07-23 11:49 ` [PATCH 2/5] perf,tools: Dump per-sample freq/CPU%/CORE_BUSY% in report -D kan.liang
2015-07-23 11:49 ` kan.liang [this message]
2015-07-23 11:49 ` [PATCH 4/5] perf,tools: caculate and save freq/CPU%/CORE_BUSY% in he_stat kan.liang
2015-07-23 11:49 ` [PATCH 5/5] perf,tools: Show freq/CPU%/CORE_BUSY% in perf report --stdio kan.liang
-- strict thread matches above, loose matches on Subject: below --
2015-07-23 11:46 [PATCH 0/5] Freq/CPU%/CORE_BUSY% support Kan Liang
2015-07-23 11:46 ` [PATCH 3/5] perf,tools: save misc sample read value in struct perf_sample Kan Liang
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=1437652183-62080-4-git-send-email-kan.liang@intel.com \
--to=kan.liang@intel.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--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