diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2017-05-26 04:17:33 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-06-30 10:44:36 -0400 |
commit | 4a9fd4e0effc94b9ec79250946a0054d4dd1a963 (patch) | |
tree | 32ac2de0a16631dbc2d8a28e0fb9476f1ec54d4f /tools | |
parent | bbac88ed64436201d6b6f2b00177d58081d56707 (diff) |
perf intel-pt: Move code in intel_pt_synth_events() to simplify attr setting
intel_pt_synth_events() uses the same attr structure to create each event.
Move the code around a bit to simplify that.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1495786658-18063-33-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/intel-pt.c | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index a20712e1ed28..ace79a405f98 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c | |||
@@ -1997,6 +1997,25 @@ static int intel_pt_synth_events(struct intel_pt *pt, | |||
1997 | if (!id) | 1997 | if (!id) |
1998 | id = 1; | 1998 | id = 1; |
1999 | 1999 | ||
2000 | if (pt->synth_opts.branches) { | ||
2001 | attr.config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS; | ||
2002 | attr.sample_period = 1; | ||
2003 | attr.sample_type |= PERF_SAMPLE_ADDR; | ||
2004 | err = intel_pt_synth_event(session, "branches", &attr, id); | ||
2005 | if (err) | ||
2006 | return err; | ||
2007 | pt->sample_branches = true; | ||
2008 | pt->branches_sample_type = attr.sample_type; | ||
2009 | pt->branches_id = id; | ||
2010 | id += 1; | ||
2011 | attr.sample_type &= ~(u64)PERF_SAMPLE_ADDR; | ||
2012 | } | ||
2013 | |||
2014 | if (pt->synth_opts.callchain) | ||
2015 | attr.sample_type |= PERF_SAMPLE_CALLCHAIN; | ||
2016 | if (pt->synth_opts.last_branch) | ||
2017 | attr.sample_type |= PERF_SAMPLE_BRANCH_STACK; | ||
2018 | |||
2000 | if (pt->synth_opts.instructions) { | 2019 | if (pt->synth_opts.instructions) { |
2001 | attr.config = PERF_COUNT_HW_INSTRUCTIONS; | 2020 | attr.config = PERF_COUNT_HW_INSTRUCTIONS; |
2002 | if (pt->synth_opts.period_type == PERF_ITRACE_PERIOD_NANOSECS) | 2021 | if (pt->synth_opts.period_type == PERF_ITRACE_PERIOD_NANOSECS) |
@@ -2004,10 +2023,6 @@ static int intel_pt_synth_events(struct intel_pt *pt, | |||
2004 | intel_pt_ns_to_ticks(pt, pt->synth_opts.period); | 2023 | intel_pt_ns_to_ticks(pt, pt->synth_opts.period); |
2005 | else | 2024 | else |
2006 | attr.sample_period = pt->synth_opts.period; | 2025 | attr.sample_period = pt->synth_opts.period; |
2007 | if (pt->synth_opts.callchain) | ||
2008 | attr.sample_type |= PERF_SAMPLE_CALLCHAIN; | ||
2009 | if (pt->synth_opts.last_branch) | ||
2010 | attr.sample_type |= PERF_SAMPLE_BRANCH_STACK; | ||
2011 | err = intel_pt_synth_event(session, "instructions", &attr, id); | 2026 | err = intel_pt_synth_event(session, "instructions", &attr, id); |
2012 | if (err) | 2027 | if (err) |
2013 | return err; | 2028 | return err; |
@@ -2017,13 +2032,11 @@ static int intel_pt_synth_events(struct intel_pt *pt, | |||
2017 | id += 1; | 2032 | id += 1; |
2018 | } | 2033 | } |
2019 | 2034 | ||
2035 | attr.sample_type &= ~(u64)PERF_SAMPLE_PERIOD; | ||
2036 | attr.sample_period = 1; | ||
2037 | |||
2020 | if (pt->synth_opts.transactions) { | 2038 | if (pt->synth_opts.transactions) { |
2021 | attr.config = PERF_COUNT_HW_INSTRUCTIONS; | 2039 | attr.config = PERF_COUNT_HW_INSTRUCTIONS; |
2022 | attr.sample_period = 1; | ||
2023 | if (pt->synth_opts.callchain) | ||
2024 | attr.sample_type |= PERF_SAMPLE_CALLCHAIN; | ||
2025 | if (pt->synth_opts.last_branch) | ||
2026 | attr.sample_type |= PERF_SAMPLE_BRANCH_STACK; | ||
2027 | err = intel_pt_synth_event(session, "transactions", &attr, id); | 2040 | err = intel_pt_synth_event(session, "transactions", &attr, id); |
2028 | if (err) | 2041 | if (err) |
2029 | return err; | 2042 | return err; |
@@ -2034,20 +2047,6 @@ static int intel_pt_synth_events(struct intel_pt *pt, | |||
2034 | id += 1; | 2047 | id += 1; |
2035 | } | 2048 | } |
2036 | 2049 | ||
2037 | if (pt->synth_opts.branches) { | ||
2038 | attr.config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS; | ||
2039 | attr.sample_period = 1; | ||
2040 | attr.sample_type |= PERF_SAMPLE_ADDR; | ||
2041 | attr.sample_type &= ~(u64)PERF_SAMPLE_CALLCHAIN; | ||
2042 | attr.sample_type &= ~(u64)PERF_SAMPLE_BRANCH_STACK; | ||
2043 | err = intel_pt_synth_event(session, "branches", &attr, id); | ||
2044 | if (err) | ||
2045 | return err; | ||
2046 | pt->sample_branches = true; | ||
2047 | pt->branches_sample_type = attr.sample_type; | ||
2048 | pt->branches_id = id; | ||
2049 | } | ||
2050 | |||
2051 | pt->synth_needs_swap = evsel->needs_swap; | 2050 | pt->synth_needs_swap = evsel->needs_swap; |
2052 | 2051 | ||
2053 | return 0; | 2052 | return 0; |