Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1679184

[PATCH 23/30] perf intel-pt: Tidy messages into called function intel_pt_synth_event()

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 23/30] perf intel-pt: Tidy messages into called function intel_pt_synth_event()
Date 2017-07-01 00:30 +0200
Message-ID <tYcAk-2OP-55@gated-at.bofh.it> (permalink)
References <tYcAh-2OP-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Adrian Hunter <adrian.hunter@intel.com>

Tidy print messages into called function intel_pt_synth_event().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1495786658-18063-31-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/intel-pt.c | 42 ++++++++++++++++++------------------------
 1 file changed, 18 insertions(+), 24 deletions(-)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index a9486b57584f..81907f60e7da 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1910,16 +1910,25 @@ static int intel_pt_event_synth(struct perf_tool *tool,
 						 NULL);
 }
 
-static int intel_pt_synth_event(struct perf_session *session,
+static int intel_pt_synth_event(struct perf_session *session, const char *name,
 				struct perf_event_attr *attr, u64 id)
 {
 	struct intel_pt_synth intel_pt_synth;
+	int err;
+
+	pr_debug("Synthesizing '%s' event with id %" PRIu64 " sample type %#" PRIx64 "\n",
+		 name, id, (u64)attr->sample_type);
 
 	memset(&intel_pt_synth, 0, sizeof(struct intel_pt_synth));
 	intel_pt_synth.session = session;
 
-	return perf_event__synthesize_attr(&intel_pt_synth.dummy_tool, attr, 1,
-					   &id, intel_pt_event_synth);
+	err = perf_event__synthesize_attr(&intel_pt_synth.dummy_tool, attr, 1,
+					  &id, intel_pt_event_synth);
+	if (err)
+		pr_err("%s: failed to synthesize '%s' event type\n",
+		       __func__, name);
+
+	return err;
 }
 
 static struct perf_evsel *intel_pt_evsel(struct intel_pt *pt,
@@ -1984,14 +1993,9 @@ static int intel_pt_synth_events(struct intel_pt *pt,
 			attr.sample_type |= PERF_SAMPLE_CALLCHAIN;
 		if (pt->synth_opts.last_branch)
 			attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
-		pr_debug("Synthesizing 'instructions' event with id %" PRIu64 " sample type %#" PRIx64 "\n",
-			 id, (u64)attr.sample_type);
-		err = intel_pt_synth_event(session, &attr, id);
-		if (err) {
-			pr_err("%s: failed to synthesize 'instructions' event type\n",
-			       __func__);
+		err = intel_pt_synth_event(session, "instructions", &attr, id);
+		if (err)
 			return err;
-		}
 		pt->sample_instructions = true;
 		pt->instructions_sample_type = attr.sample_type;
 		pt->instructions_id = id;
@@ -2005,14 +2009,9 @@ static int intel_pt_synth_events(struct intel_pt *pt,
 			attr.sample_type |= PERF_SAMPLE_CALLCHAIN;
 		if (pt->synth_opts.last_branch)
 			attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
-		pr_debug("Synthesizing 'transactions' event with id %" PRIu64 " sample type %#" PRIx64 "\n",
-			 id, (u64)attr.sample_type);
-		err = intel_pt_synth_event(session, &attr, id);
-		if (err) {
-			pr_err("%s: failed to synthesize 'transactions' event type\n",
-			       __func__);
+		err = intel_pt_synth_event(session, "transactions", &attr, id);
+		if (err)
 			return err;
-		}
 		pt->sample_transactions = true;
 		pt->transactions_sample_type = attr.sample_type;
 		pt->transactions_id = id;
@@ -2033,14 +2032,9 @@ static int intel_pt_synth_events(struct intel_pt *pt,
 		attr.sample_type |= PERF_SAMPLE_ADDR;
 		attr.sample_type &= ~(u64)PERF_SAMPLE_CALLCHAIN;
 		attr.sample_type &= ~(u64)PERF_SAMPLE_BRANCH_STACK;
-		pr_debug("Synthesizing 'branches' event with id %" PRIu64 " sample type %#" PRIx64 "\n",
-			 id, (u64)attr.sample_type);
-		err = intel_pt_synth_event(session, &attr, id);
-		if (err) {
-			pr_err("%s: failed to synthesize 'branches' event type\n",
-			       __func__);
+		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;
-- 
2.9.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 00/30] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 03/30] perf help: Elliminate dup code for reporting Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 12/30] x86/insn: perf tools: Add new ptwrite instruction Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 19/30] perf intel-pt: Factor out common code synthesizing event samples Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 30/30] perf auxtrace: Add CPU filter support Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 08/30] perf tools: Replace error() with pr_err() Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 05/30] perf config: Use pr_warning() Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 22/30] perf intel-pt: Tidy Intel PT evsel lookup into separate function Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 25/30] perf intel-pt: Move code in intel_pt_synth_events() to simplify attr setting Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 11/30] perf jit: fix typo: "incalid" -> "invalid" Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 24/30] perf intel-pt: Factor out intel_pt_set_event_name() Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 20/30] perf intel-pt: Remove unused instructions_sample_period Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 14/30] tools include: Add byte-swapping macros to kernel.h Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 04/30] perf help: Use pr_warning() Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 27/30] perf intel-pt: Add example script for power events and PTWRITE Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 29/30] perf intel-pt: Do not use TSC packets for calculating CPU cycles to TSC Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 17/30] perf script: Add 'synth' field for synthesized event payloads Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 26/30] perf intel-pt: Synthesize new power and "ptwrite" events Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 15/30] perf auxtrace: Add itrace option to output ptwrite events Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 01/30] perf tests: Add platform dependency to test 15 Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 23/30] perf intel-pt: Tidy messages into called function intel_pt_synth_event() Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 28/30] perf intel-pt: Update documentation to include new ptwrite and power events Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 21/30] perf intel-pt: Join needlessly wrapped lines Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 18/30] perf script: Add synthesized Intel PT power and ptwrite events Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:30 +0200
  [PATCH 13/30] perf script: Add 'synth' event type for synthesized events Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:40 +0200
  [PATCH 02/30] perf help: Introduce exec_failed() to avoid code duplication Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:40 +0200
  [PATCH 10/30] perf tools: Kill die() Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:40 +0200
  [PATCH 07/30] perf tools: Remove warning() Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:40 +0200
  [PATCH 09/30] perf config: Do not die when parsing u64 or int config values Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:40 +0200
  [PATCH 16/30] perf auxtrace: Add itrace option to output power events Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-01 00:40 +0200
  Re: [GIT PULL 00/30] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2017-07-01 10:50 +0200

csiph-web