From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752602AbdGAIzr (ORCPT ); Sat, 1 Jul 2017 04:55:47 -0400 Received: from terminus.zytor.com ([65.50.211.136]:58039 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752148AbdGAIzq (ORCPT ); Sat, 1 Jul 2017 04:55:46 -0400 Date: Sat, 1 Jul 2017 01:54:37 -0700 From: tip-bot for Adrian Hunter Message-ID: Cc: hpa@zytor.com, acme@redhat.com, ak@linux.intel.com, adrian.hunter@intel.com, tglx@linutronix.de, mingo@kernel.org, linux-kernel@vger.kernel.org Reply-To: linux-kernel@vger.kernel.org, mingo@kernel.org, tglx@linutronix.de, ak@linux.intel.com, adrian.hunter@intel.com, acme@redhat.com, hpa@zytor.com In-Reply-To: <1495786658-18063-33-git-send-email-adrian.hunter@intel.com> References: <1495786658-18063-33-git-send-email-adrian.hunter@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf intel-pt: Move code in intel_pt_synth_events() to simplify attr setting Git-Commit-ID: 4a9fd4e0effc94b9ec79250946a0054d4dd1a963 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 4a9fd4e0effc94b9ec79250946a0054d4dd1a963 Gitweb: http://git.kernel.org/tip/4a9fd4e0effc94b9ec79250946a0054d4dd1a963 Author: Adrian Hunter AuthorDate: Fri, 26 May 2017 11:17:33 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 30 Jun 2017 11:44:36 -0300 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 Cc: Andi Kleen Link: http://lkml.kernel.org/r/1495786658-18063-33-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/intel-pt.c | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index a20712e..ace79a4 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, if (!id) id = 1; + if (pt->synth_opts.branches) { + attr.config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS; + attr.sample_period = 1; + attr.sample_type |= PERF_SAMPLE_ADDR; + err = intel_pt_synth_event(session, "branches", &attr, id); + if (err) + return err; + pt->sample_branches = true; + pt->branches_sample_type = attr.sample_type; + pt->branches_id = id; + id += 1; + attr.sample_type &= ~(u64)PERF_SAMPLE_ADDR; + } + + if (pt->synth_opts.callchain) + attr.sample_type |= PERF_SAMPLE_CALLCHAIN; + if (pt->synth_opts.last_branch) + attr.sample_type |= PERF_SAMPLE_BRANCH_STACK; + if (pt->synth_opts.instructions) { attr.config = PERF_COUNT_HW_INSTRUCTIONS; if (pt->synth_opts.period_type == PERF_ITRACE_PERIOD_NANOSECS) @@ -2004,10 +2023,6 @@ static int intel_pt_synth_events(struct intel_pt *pt, intel_pt_ns_to_ticks(pt, pt->synth_opts.period); else attr.sample_period = pt->synth_opts.period; - if (pt->synth_opts.callchain) - attr.sample_type |= PERF_SAMPLE_CALLCHAIN; - if (pt->synth_opts.last_branch) - attr.sample_type |= PERF_SAMPLE_BRANCH_STACK; err = intel_pt_synth_event(session, "instructions", &attr, id); if (err) return err; @@ -2017,13 +2032,11 @@ static int intel_pt_synth_events(struct intel_pt *pt, id += 1; } + attr.sample_type &= ~(u64)PERF_SAMPLE_PERIOD; + attr.sample_period = 1; + if (pt->synth_opts.transactions) { attr.config = PERF_COUNT_HW_INSTRUCTIONS; - attr.sample_period = 1; - if (pt->synth_opts.callchain) - attr.sample_type |= PERF_SAMPLE_CALLCHAIN; - if (pt->synth_opts.last_branch) - attr.sample_type |= PERF_SAMPLE_BRANCH_STACK; err = intel_pt_synth_event(session, "transactions", &attr, id); if (err) return err; @@ -2034,20 +2047,6 @@ static int intel_pt_synth_events(struct intel_pt *pt, id += 1; } - if (pt->synth_opts.branches) { - attr.config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS; - attr.sample_period = 1; - attr.sample_type |= PERF_SAMPLE_ADDR; - attr.sample_type &= ~(u64)PERF_SAMPLE_CALLCHAIN; - attr.sample_type &= ~(u64)PERF_SAMPLE_BRANCH_STACK; - err = intel_pt_synth_event(session, "branches", &attr, id); - if (err) - return err; - pt->sample_branches = true; - pt->branches_sample_type = attr.sample_type; - pt->branches_id = id; - } - pt->synth_needs_swap = evsel->needs_swap; return 0;