linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>, linux-kernel@vger.kernel.org
Subject: [PATCH 16/22] perf scripts python: export-to-sqlite.py: Export IPC information
Date: Mon, 20 May 2019 14:37:22 +0300	[thread overview]
Message-ID: <20190520113728.14389-17-adrian.hunter@intel.com> (raw)
In-Reply-To: <20190520113728.14389-1-adrian.hunter@intel.com>

Export cycle and instruction counts on samples and calls tables.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/scripts/python/export-to-sqlite.py | 36 ++++++++++++-------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/tools/perf/scripts/python/export-to-sqlite.py b/tools/perf/scripts/python/export-to-sqlite.py
index f617e518332f..4542ce89034b 100644
--- a/tools/perf/scripts/python/export-to-sqlite.py
+++ b/tools/perf/scripts/python/export-to-sqlite.py
@@ -218,7 +218,9 @@ if branches:
 		'to_ip		bigint,'
 		'branch_type	integer,'
 		'in_tx		boolean,'
-		'call_path_id	bigint)')
+		'call_path_id	bigint,'
+		'insn_count	bigint,'
+		'cyc_count	bigint)')
 else:
 	do_query(query, 'CREATE TABLE samples ('
 		'id		integer		NOT NULL	PRIMARY KEY,'
@@ -242,7 +244,9 @@ else:
 		'data_src	bigint,'
 		'branch_type	integer,'
 		'in_tx		boolean,'
-		'call_path_id	bigint)')
+		'call_path_id	bigint,'
+		'insn_count	bigint,'
+		'cyc_count	bigint)')
 
 if perf_db_export_calls or perf_db_export_callchains:
 	do_query(query, 'CREATE TABLE call_paths ('
@@ -263,7 +267,9 @@ if perf_db_export_calls:
 		'return_id	bigint,'
 		'parent_call_path_id	bigint,'
 		'flags		integer,'
-		'parent_id	bigint)')
+		'parent_id	bigint,'
+		'insn_count	bigint,'
+		'cyc_count	bigint)')
 
 # printf was added to sqlite in version 3.8.3
 sqlite_has_printf = False
@@ -359,6 +365,9 @@ if perf_db_export_calls:
 			'return_time,'
 			'return_time - call_time AS elapsed_time,'
 			'branch_count,'
+			'insn_count,'
+			'cyc_count,'
+			'CASE WHEN cyc_count=0 THEN CAST(0 AS FLOAT) ELSE ROUND(CAST(insn_count AS FLOAT) / cyc_count, 2) END AS IPC,'
 			'call_id,'
 			'return_id,'
 			'CASE WHEN flags=0 THEN \'\' WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' WHEN flags=6 THEN \'jump\' ELSE flags END AS flags,'
@@ -384,7 +393,10 @@ do_query(query, 'CREATE VIEW samples_view AS '
 		'to_sym_offset,'
 		'(SELECT short_name FROM dsos WHERE id = to_dso_id) AS to_dso_short_name,'
 		'(SELECT name FROM branch_types WHERE id = branch_type) AS branch_type_name,'
-		'in_tx'
+		'in_tx,'
+		'insn_count,'
+		'cyc_count,'
+		'CASE WHEN cyc_count=0 THEN CAST(0 AS FLOAT) ELSE ROUND(CAST(insn_count AS FLOAT) / cyc_count, 2) END AS IPC'
 	' FROM samples')
 
 do_query(query, 'END TRANSACTION')
@@ -407,15 +419,15 @@ branch_type_query = QSqlQuery(db)
 branch_type_query.prepare("INSERT INTO branch_types VALUES (?, ?)")
 sample_query = QSqlQuery(db)
 if branches:
-	sample_query.prepare("INSERT INTO samples VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
+	sample_query.prepare("INSERT INTO samples VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
 else:
-	sample_query.prepare("INSERT INTO samples VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
+	sample_query.prepare("INSERT INTO samples VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
 if perf_db_export_calls or perf_db_export_callchains:
 	call_path_query = QSqlQuery(db)
 	call_path_query.prepare("INSERT INTO call_paths VALUES (?, ?, ?, ?)")
 if perf_db_export_calls:
 	call_query = QSqlQuery(db)
-	call_query.prepare("INSERT INTO calls VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
+	call_query.prepare("INSERT INTO calls VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
 
 def trace_begin():
 	printdate("Writing records...")
@@ -427,10 +439,10 @@ def trace_begin():
 	comm_table(0, "unknown")
 	dso_table(0, 0, "unknown", "unknown", "")
 	symbol_table(0, 0, 0, 0, 0, "unknown")
-	sample_table(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+	sample_table(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 	if perf_db_export_calls or perf_db_export_callchains:
 		call_path_table(0, 0, 0, 0)
-		call_return_table(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+		call_return_table(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 
 unhandled_count = 0
 
@@ -486,14 +498,14 @@ def sample_table(*x):
 	if branches:
 		for xx in x[0:15]:
 			sample_query.addBindValue(str(xx))
-		for xx in x[19:22]:
+		for xx in x[19:24]:
 			sample_query.addBindValue(str(xx))
 		do_query_(sample_query)
 	else:
-		bind_exec(sample_query, 22, x)
+		bind_exec(sample_query, 24, x)
 
 def call_path_table(*x):
 	bind_exec(call_path_query, 4, x)
 
 def call_return_table(*x):
-	bind_exec(call_query, 12, x)
+	bind_exec(call_query, 14, x)
-- 
2.17.1


  parent reply	other threads:[~2019-05-20 11:38 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-20 11:37 [PATCH 00/22] perf intel-pt: Add support for instructions-per-cycle (IPC) Adrian Hunter
2019-05-20 11:37 ` [PATCH 01/22] perf intel-pt: Fix itrace defaults for perf script Adrian Hunter
2019-05-20 13:58   ` Sasha Levin
2019-05-20 14:45   ` Arnaldo Carvalho de Melo
2019-05-31 16:45     ` Arnaldo Carvalho de Melo
2019-06-04 11:32       ` Adrian Hunter
2019-06-04 13:20         ` Arnaldo Carvalho de Melo
2019-05-30  7:53   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 02/22] perf auxtrace: " Adrian Hunter
2019-05-30  7:54   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 03/22] perf intel-pt: Fix itrace defaults for perf script intel-pt documentation Adrian Hunter
2019-05-30  7:54   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 04/22] perf intel-pt: Factor out intel_pt_update_sample_time Adrian Hunter
2019-06-17 18:59   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 05/22] perf intel-pt: Accumulate cycle count from CYC packets Adrian Hunter
2019-06-17 18:59   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 06/22] perf tools: Add IPC information to perf_sample Adrian Hunter
2019-06-17 19:00   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 07/22] perf intel-pt: Add support for samples to contain IPC ratio Adrian Hunter
2019-06-17 19:01   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 08/22] perf script: Add output of " Adrian Hunter
2019-06-17 19:01   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 09/22] perf intel-pt: Record when decoding PSB+ packets Adrian Hunter
2019-06-17 19:02   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 10/22] perf intel-pt: Re-factor TIP cases in intel_pt_walk_to_ip Adrian Hunter
2019-06-17 19:03   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 11/22] perf intel-pt: Accumulate cycle count from TSC/TMA/MTC packets Adrian Hunter
2019-06-17 19:04   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 12/22] perf intel-pt: Document IPC usage Adrian Hunter
2019-06-17 19:04   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 13/22] perf thread-stack: Accumulate IPC information Adrian Hunter
2019-06-17 19:05   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 14/22] perf db-export: Add brief documentation Adrian Hunter
2019-06-17 19:06   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 15/22] perf db-export: Export IPC information Adrian Hunter
2019-06-17 19:07   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` Adrian Hunter [this message]
2019-06-17 19:07   ` [tip:perf/core] perf scripts python: export-to-sqlite.py: " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 17/22] perf scripts python: export-to-postgresql.py: " Adrian Hunter
2019-06-17 19:08   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 18/22] perf scripts python: exported-sql-viewer.py: Add IPC information to the Branch reports Adrian Hunter
2019-05-31 16:44   ` Arnaldo Carvalho de Melo
2019-06-03  5:50     ` Adrian Hunter
2019-06-17 19:09   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 19/22] perf scripts python: exported-sql-viewer.py: Add CallGraphModelParams Adrian Hunter
2019-06-17 19:09   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 20/22] perf scripts python: exported-sql-viewer.py: Add IPC information to Call Graph Graph Adrian Hunter
2019-06-17 19:10   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 21/22] perf scripts python: exported-sql-viewer.py: Add IPC information to Call Tree Adrian Hunter
2019-06-17 19:11   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-05-20 11:37 ` [PATCH 22/22] perf scripts python: exported-sql-viewer.py: Select find text when find bar is activated Adrian Hunter
2019-06-17 19:11   ` [tip:perf/core] " tip-bot for Adrian Hunter

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=20190520113728.14389-17-adrian.hunter@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).