linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT
@ 2019-04-12 11:38 Adrian Hunter
  2019-04-12 11:38 ` [PATCH 1/8] perf scripts python: exported-sql-viewer.py: Change python2 to python Adrian Hunter
                   ` (8 more replies)
  0 siblings, 9 replies; 19+ messages in thread
From: Adrian Hunter @ 2019-04-12 11:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

Hi

Here are patches to add support for pyside2 to the db-export scripts,
and a couple of Intel PT patches.


Adrian Hunter (8):
      perf scripts python: exported-sql-viewer.py: Change python2 to python
      perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing
      perf scripts python: exported-sql-viewer.py: Add support for pyside2
      perf scripts python: export-to-sqlite.py: Add support for pyside2
      perf scripts python: export-to-postgresql.py: Add support for pyside2
      perf tools: perf-with-kcore.sh: Always allow fix_buildid_cache_permissions
      perf intel-pt: Improve sync_switch
      perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid

 tools/perf/perf-with-kcore.sh                     |  5 ---
 tools/perf/scripts/python/export-to-postgresql.py | 43 +++++++++++++++----
 tools/perf/scripts/python/export-to-sqlite.py     | 44 ++++++++++++++++---
 tools/perf/scripts/python/exported-sql-viewer.py  | 51 ++++++++++++++++-------
 tools/perf/util/intel-pt.c                        | 44 +++++++++++++++++--
 5 files changed, 150 insertions(+), 37 deletions(-)


Regards
Adrian

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/8] perf scripts python: exported-sql-viewer.py: Change python2 to python
  2019-04-12 11:38 [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
@ 2019-04-12 11:38 ` Adrian Hunter
  2019-05-30  8:17   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2019-04-12 11:38 ` [PATCH 2/8] perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing Adrian Hunter
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Adrian Hunter @ 2019-04-12 11:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

Now that there is also support for python3, there is no need to specify
python2 explicitly.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/scripts/python/exported-sql-viewer.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index 74ef92f1d19a..a3f1d05c9d4b 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
 # SPDX-License-Identifier: GPL-2.0
 # exported-sql-viewer.py: view data from sql database
 # Copyright (c) 2014-2018, Intel Corporation.
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 2/8] perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing
  2019-04-12 11:38 [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
  2019-04-12 11:38 ` [PATCH 1/8] perf scripts python: exported-sql-viewer.py: Change python2 to python Adrian Hunter
@ 2019-04-12 11:38 ` Adrian Hunter
  2019-05-30  8:18   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2019-04-12 11:38 ` [PATCH 3/8] perf scripts python: exported-sql-viewer.py: Add support for pyside2 Adrian Hunter
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Adrian Hunter @ 2019-04-12 11:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

argparse makes it easier to add new arguments.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 .../scripts/python/exported-sql-viewer.py     | 21 +++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index a3f1d05c9d4b..0fb0acc94058 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -91,6 +91,7 @@
 from __future__ import print_function
 
 import sys
+import argparse
 import weakref
 import threading
 import string
@@ -3035,18 +3036,26 @@ class DBRef():
 # Main
 
 def Main():
-	if (len(sys.argv) < 2):
-		printerr("Usage is: exported-sql-viewer.py {<database name> | --help-only}");
-		raise Exception("Too few arguments")
-
-	dbname = sys.argv[1]
-	if dbname == "--help-only":
+	usage_str =	"exported-sql-viewer.py [--pyside-version-1] <database name>\n" \
+			"   or: exported-sql-viewer.py --help-only"
+	ap = argparse.ArgumentParser(usage = usage_str, add_help = False)
+	ap.add_argument("dbname", nargs="?")
+	ap.add_argument("--help-only", action='store_true')
+	args = ap.parse_args()
+
+	if args.help_only:
 		app = QApplication(sys.argv)
 		mainwindow = HelpOnlyWindow()
 		mainwindow.show()
 		err = app.exec_()
 		sys.exit(err)
 
+	dbname = args.dbname
+	if dbname is None:
+		ap.print_usage()
+		print("Too few arguments")
+		sys.exit(1)
+
 	is_sqlite3 = False
 	try:
 		f = open(dbname, "rb")
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 3/8] perf scripts python: exported-sql-viewer.py: Add support for pyside2
  2019-04-12 11:38 [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
  2019-04-12 11:38 ` [PATCH 1/8] perf scripts python: exported-sql-viewer.py: Change python2 to python Adrian Hunter
  2019-04-12 11:38 ` [PATCH 2/8] perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing Adrian Hunter
@ 2019-04-12 11:38 ` Adrian Hunter
  2019-05-30  8:19   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2019-04-12 11:38 ` [PATCH 4/8] perf scripts python: export-to-sqlite.py: " Adrian Hunter
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Adrian Hunter @ 2019-04-12 11:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

pyside2 is the future for pyside support.

Note pyside use Qt4 whereas pyside2 uses Qt5.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 .../scripts/python/exported-sql-viewer.py     | 28 ++++++++++++++-----
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index 0fb0acc94058..c586abfb2b46 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -105,10 +105,23 @@ except ImportError:
 	glb_nsz = 16
 import re
 import os
-from PySide.QtCore import *
-from PySide.QtGui import *
-from PySide.QtSql import *
+
 pyside_version_1 = True
+if not "--pyside-version-1" in sys.argv:
+	try:
+		from PySide2.QtCore import *
+		from PySide2.QtGui import *
+		from PySide2.QtSql import *
+		from PySide2.QtWidgets import *
+		pyside_version_1 = False
+	except:
+		pass
+
+if pyside_version_1:
+	from PySide.QtCore import *
+	from PySide.QtGui import *
+	from PySide.QtSql import *
+
 from decimal import *
 from ctypes import *
 from multiprocessing import Process, Array, Value, Event
@@ -2502,7 +2515,7 @@ class WindowMenu():
 			action = self.window_menu.addAction(label)
 			action.setCheckable(True)
 			action.setChecked(sub_window == self.mdi_area.activeSubWindow())
-			action.triggered.connect(lambda x=nr: self.setActiveSubWindow(x))
+			action.triggered.connect(lambda a=None,x=nr: self.setActiveSubWindow(x))
 			self.window_menu.addAction(action)
 			nr += 1
 
@@ -2793,14 +2806,14 @@ class MainWindow(QMainWindow):
 			event = event.split(":")[0]
 			if event == "branches":
 				label = "All branches" if branches_events == 1 else "All branches " + "(id=" + dbid + ")"
-				reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda x=dbid: self.NewBranchView(x), self))
+				reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda a=None,x=dbid: self.NewBranchView(x), self))
 				label = "Selected branches" if branches_events == 1 else "Selected branches " + "(id=" + dbid + ")"
-				reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda x=dbid: self.NewSelectedBranchView(x), self))
+				reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda a=None,x=dbid: self.NewSelectedBranchView(x), self))
 
 	def TableMenu(self, tables, menu):
 		table_menu = menu.addMenu("&Tables")
 		for table in tables:
-			table_menu.addAction(CreateAction(table, "Create a new window containing a table view", lambda t=table: self.NewTableView(t), self))
+			table_menu.addAction(CreateAction(table, "Create a new window containing a table view", lambda a=None,t=table: self.NewTableView(t), self))
 
 	def NewCallGraph(self):
 		CallGraphWindow(self.glb, self)
@@ -3039,6 +3052,7 @@ def Main():
 	usage_str =	"exported-sql-viewer.py [--pyside-version-1] <database name>\n" \
 			"   or: exported-sql-viewer.py --help-only"
 	ap = argparse.ArgumentParser(usage = usage_str, add_help = False)
+	ap.add_argument("--pyside-version-1", action='store_true')
 	ap.add_argument("dbname", nargs="?")
 	ap.add_argument("--help-only", action='store_true')
 	args = ap.parse_args()
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 4/8] perf scripts python: export-to-sqlite.py: Add support for pyside2
  2019-04-12 11:38 [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
                   ` (2 preceding siblings ...)
  2019-04-12 11:38 ` [PATCH 3/8] perf scripts python: exported-sql-viewer.py: Add support for pyside2 Adrian Hunter
@ 2019-04-12 11:38 ` Adrian Hunter
  2019-05-30  8:19   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2019-04-12 11:38 ` [PATCH 5/8] perf scripts python: export-to-postgresql.py: " Adrian Hunter
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Adrian Hunter @ 2019-04-12 11:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

pyside2 is the future for pyside support.

Note pyside use Qt4 whereas pyside2 uses Qt5.

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

diff --git a/tools/perf/scripts/python/export-to-sqlite.py b/tools/perf/scripts/python/export-to-sqlite.py
index bf271fbc3a88..f617e518332f 100644
--- a/tools/perf/scripts/python/export-to-sqlite.py
+++ b/tools/perf/scripts/python/export-to-sqlite.py
@@ -21,6 +21,26 @@ import datetime
 # provides LGPL-licensed Python bindings for Qt.  You will also need the package
 # libqt4-sql-sqlite for Qt sqlite3 support.
 #
+# Examples of installing pyside:
+#
+# ubuntu:
+#
+#	$ sudo apt-get install python-pyside.qtsql libqt4-sql-psql
+#
+#	Alternately, to use Python3 and/or pyside 2, one of the following:
+#
+#		$ sudo apt-get install python3-pyside.qtsql libqt4-sql-psql
+#		$ sudo apt-get install python-pyside2.qtsql libqt5sql5-psql
+#		$ sudo apt-get install python3-pyside2.qtsql libqt5sql5-psql
+# fedora:
+#
+#	$ sudo yum install python-pyside
+#
+#	Alternately, to use Python3 and/or pyside 2, one of the following:
+#		$ sudo yum install python3-pyside
+#		$ pip install --user PySide2
+#		$ pip3 install --user PySide2
+#
 # An example of using this script with Intel PT:
 #
 #	$ perf record -e intel_pt//u ls
@@ -49,7 +69,16 @@ import datetime
 # difference is  the 'transaction' column of the 'samples' table which is
 # renamed 'transaction_' in sqlite because 'transaction' is a reserved word.
 
-from PySide.QtSql import *
+pyside_version_1 = True
+if not "pyside-version-1" in sys.argv:
+	try:
+		from PySide2.QtSql import *
+		pyside_version_1 = False
+	except:
+		pass
+
+if pyside_version_1:
+	from PySide.QtSql import *
 
 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
 	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
@@ -69,11 +98,12 @@ def printdate(*args, **kw_args):
         print(datetime.datetime.today(), *args, sep=' ', **kw_args)
 
 def usage():
-	printerr("Usage is: export-to-sqlite.py <database name> [<columns>] [<calls>] [<callchains>]");
-	printerr("where:	columns		'all' or 'branches'");
-	printerr("		calls		'calls' => create calls and call_paths table");
-	printerr("		callchains	'callchains' => create call_paths table");
-	raise Exception("Too few arguments")
+	printerr("Usage is: export-to-sqlite.py <database name> [<columns>] [<calls>] [<callchains>] [<pyside-version-1>]");
+	printerr("where:  columns            'all' or 'branches'");
+	printerr("        calls              'calls' => create calls and call_paths table");
+	printerr("        callchains         'callchains' => create call_paths table");
+	printerr("        pyside-version-1   'pyside-version-1' => use pyside version 1");
+	raise Exception("Too few or bad arguments")
 
 if (len(sys.argv) < 2):
 	usage()
@@ -95,6 +125,8 @@ for i in range(3,len(sys.argv)):
 		perf_db_export_calls = True
 	elif (sys.argv[i] == "callchains"):
 		perf_db_export_callchains = True
+	elif (sys.argv[i] == "pyside-version-1"):
+		pass
 	else:
 		usage()
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 5/8] perf scripts python: export-to-postgresql.py: Add support for pyside2
  2019-04-12 11:38 [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
                   ` (3 preceding siblings ...)
  2019-04-12 11:38 ` [PATCH 4/8] perf scripts python: export-to-sqlite.py: " Adrian Hunter
@ 2019-04-12 11:38 ` Adrian Hunter
  2019-05-30  8:20   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2019-04-12 11:38 ` [PATCH 6/8] perf tools: perf-with-kcore.sh: Always allow fix_buildid_cache_permissions Adrian Hunter
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Adrian Hunter @ 2019-04-12 11:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

pyside2 is the future for pyside support.

Note pyside use Qt4 whereas pyside2 uses Qt5.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 .../scripts/python/export-to-postgresql.py    | 43 +++++++++++++++----
 1 file changed, 34 insertions(+), 9 deletions(-)

diff --git a/tools/perf/scripts/python/export-to-postgresql.py b/tools/perf/scripts/python/export-to-postgresql.py
index c3eae1d77d36..b2f481b0d28d 100644
--- a/tools/perf/scripts/python/export-to-postgresql.py
+++ b/tools/perf/scripts/python/export-to-postgresql.py
@@ -27,18 +27,31 @@ import datetime
 #
 # fedora:
 #
-#	$ sudo yum install postgresql postgresql-server python-pyside qt-postgresql
+#	$ sudo yum install postgresql postgresql-server qt-postgresql
 #	$ sudo su - postgres -c initdb
 #	$ sudo service postgresql start
 #	$ sudo su - postgres
-#	$ createuser <your user id here>
+#	$ createuser -s <your user id here>    # Older versions may not support -s, in which case answer the prompt below:
 #	Shall the new role be a superuser? (y/n) y
+#	$ sudo yum install python-pyside
+#
+#	Alternately, to use Python3 and/or pyside 2, one of the following:
+#		$ sudo yum install python3-pyside
+#		$ pip install --user PySide2
+#		$ pip3 install --user PySide2
 #
 # ubuntu:
 #
-#	$ sudo apt-get install postgresql python-pyside.qtsql libqt4-sql-psql
+#	$ sudo apt-get install postgresql
 #	$ sudo su - postgres
 #	$ createuser -s <your user id here>
+#	$ sudo apt-get install python-pyside.qtsql libqt4-sql-psql
+#
+#	Alternately, to use Python3 and/or pyside 2, one of the following:
+#
+#		$ sudo apt-get install python3-pyside.qtsql libqt4-sql-psql
+#		$ sudo apt-get install python-pyside2.qtsql libqt5sql5-psql
+#		$ sudo apt-get install python3-pyside2.qtsql libqt5sql5-psql
 #
 # An example of using this script with Intel PT:
 #
@@ -199,7 +212,16 @@ import datetime
 #                   print "{0:>6}  {1:>10}  {2:>9}  {3:<30}  {4:>6}  {5:<30}".format(query.value(0), query.value(1), query.value(2), query.value(3), query.value(4), query.value(5))
 #                   call_path_id = query.value(6)
 
-from PySide.QtSql import *
+pyside_version_1 = True
+if not "pyside-version-1" in sys.argv:
+	try:
+		from PySide2.QtSql import *
+		pyside_version_1 = False
+	except:
+		pass
+
+if pyside_version_1:
+	from PySide.QtSql import *
 
 if sys.version_info < (3, 0):
 	def toserverstr(str):
@@ -255,11 +277,12 @@ def printdate(*args, **kw_args):
         print(datetime.datetime.today(), *args, sep=' ', **kw_args)
 
 def usage():
-	printerr("Usage is: export-to-postgresql.py <database name> [<columns>] [<calls>] [<callchains>]")
-	printerr("where:	columns		'all' or 'branches'")
-	printerr("		calls		'calls' => create calls and call_paths table")
-	printerr("		callchains	'callchains' => create call_paths table")
-	raise Exception("Too few arguments")
+	printerr("Usage is: export-to-postgresql.py <database name> [<columns>] [<calls>] [<callchains>] [<pyside-version-1>]");
+	printerr("where:  columns            'all' or 'branches'");
+	printerr("        calls              'calls' => create calls and call_paths table");
+	printerr("        callchains         'callchains' => create call_paths table");
+	printerr("        pyside-version-1   'pyside-version-1' => use pyside version 1");
+	raise Exception("Too few or bad arguments")
 
 if (len(sys.argv) < 2):
 	usage()
@@ -281,6 +304,8 @@ for i in range(3,len(sys.argv)):
 		perf_db_export_calls = True
 	elif (sys.argv[i] == "callchains"):
 		perf_db_export_callchains = True
+	elif (sys.argv[i] == "pyside-version-1"):
+		pass
 	else:
 		usage()
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 6/8] perf tools: perf-with-kcore.sh: Always allow fix_buildid_cache_permissions
  2019-04-12 11:38 [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
                   ` (4 preceding siblings ...)
  2019-04-12 11:38 ` [PATCH 5/8] perf scripts python: export-to-postgresql.py: " Adrian Hunter
@ 2019-04-12 11:38 ` Adrian Hunter
  2019-05-30  7:52   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2019-04-12 11:38 ` [PATCH 7/8] perf intel-pt: Improve sync_switch Adrian Hunter
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Adrian Hunter @ 2019-04-12 11:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

The user's buildid cache may contain entries added by root even if root
has its own home directory (e.g. by using perfconfig to specify the same
buildid dir), so remove that validation.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/perf-with-kcore.sh | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/tools/perf/perf-with-kcore.sh b/tools/perf/perf-with-kcore.sh
index 7e47a7cbc195..2ad2fffdb209 100644
--- a/tools/perf/perf-with-kcore.sh
+++ b/tools/perf/perf-with-kcore.sh
@@ -111,11 +111,6 @@ fix_buildid_cache_permissions()
 
 	USER_HOME=$(bash <<< "echo ~$SUDO_USER")
 
-	if [ "$HOME" != "$USER_HOME" ] ; then
-		echo "Fix unnecessary because root has a home: $HOME" >&2
-		exit 1
-	fi
-
 	echo "Fixing buildid cache permissions"
 
 	find "$USER_HOME/.debug" -xdev -type d          ! -user "$SUDO_USER" -ls -exec chown    "$SUDO_USER" \{\} \;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 7/8] perf intel-pt: Improve sync_switch
  2019-04-12 11:38 [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
                   ` (5 preceding siblings ...)
  2019-04-12 11:38 ` [PATCH 6/8] perf tools: perf-with-kcore.sh: Always allow fix_buildid_cache_permissions Adrian Hunter
@ 2019-04-12 11:38 ` Adrian Hunter
  2019-05-30  8:21   ` [tip:perf/core] perf intel-pt: Improve sync_switch by processing PERF_RECORD_SWITCH* in events tip-bot for Adrian Hunter
  2019-04-12 11:38 ` [PATCH 8/8] perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid Adrian Hunter
  2019-04-29  7:28 ` [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
  8 siblings, 1 reply; 19+ messages in thread
From: Adrian Hunter @ 2019-04-12 11:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

sync_switch is a facility to synchronize decoding more closely with the
point in the kernel when the context actually switched.

Improve it by processing "context switch in" events.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/intel-pt.c | 40 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 6d288237887b..deaf2888dc55 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1914,6 +1914,44 @@ static int intel_pt_process_switch(struct intel_pt *pt,
 	return machine__set_current_tid(pt->machine, cpu, -1, tid);
 }
 
+static int intel_pt_context_switch_in(struct intel_pt *pt,
+				      struct perf_sample *sample)
+{
+	pid_t pid = sample->pid;
+	pid_t tid = sample->tid;
+	int cpu = sample->cpu;
+
+	if (pt->sync_switch) {
+		struct intel_pt_queue *ptq;
+
+		ptq = intel_pt_cpu_to_ptq(pt, cpu);
+		if (ptq && ptq->sync_switch) {
+			ptq->next_tid = -1;
+			switch (ptq->switch_state) {
+			case INTEL_PT_SS_NOT_TRACING:
+			case INTEL_PT_SS_UNKNOWN:
+			case INTEL_PT_SS_TRACING:
+				break;
+			case INTEL_PT_SS_EXPECTING_SWITCH_EVENT:
+			case INTEL_PT_SS_EXPECTING_SWITCH_IP:
+				ptq->switch_state = INTEL_PT_SS_TRACING;
+				break;
+			default:
+				break;
+			}
+		}
+	}
+
+	/*
+	 * If the current tid has not been updated yet, ensure it is now that
+	 * a "switch in" event has occurred.
+	 */
+	if (machine__get_current_tid(pt->machine, cpu) == tid)
+		return 0;
+
+	return machine__set_current_tid(pt->machine, cpu, pid, tid);
+}
+
 static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event,
 				   struct perf_sample *sample)
 {
@@ -1925,7 +1963,7 @@ static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event,
 
 	if (pt->have_sched_switch == 3) {
 		if (!out)
-			return 0;
+			return intel_pt_context_switch_in(pt, sample);
 		if (event->header.type != PERF_RECORD_SWITCH_CPU_WIDE) {
 			pr_err("Expecting CPU-wide context switch event\n");
 			return -EINVAL;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 8/8] perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid
  2019-04-12 11:38 [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
                   ` (6 preceding siblings ...)
  2019-04-12 11:38 ` [PATCH 7/8] perf intel-pt: Improve sync_switch Adrian Hunter
@ 2019-04-12 11:38 ` Adrian Hunter
  2019-05-30  8:21   ` [tip:perf/core] " tip-bot for Adrian Hunter
  2019-04-29  7:28 ` [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
  8 siblings, 1 reply; 19+ messages in thread
From: Adrian Hunter @ 2019-04-12 11:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

Returning 1 from intel_pt_sync_switch() causes the current tid to be
set. That negates the need to keep next_tid anymore. Rationalize the code
to that effect.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/intel-pt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index deaf2888dc55..551ae10d1c7b 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1859,7 +1859,6 @@ static int intel_pt_sync_switch(struct intel_pt *pt, int cpu, pid_t tid,
 
 	switch (ptq->switch_state) {
 	case INTEL_PT_SS_NOT_TRACING:
-		ptq->next_tid = -1;
 		break;
 	case INTEL_PT_SS_UNKNOWN:
 	case INTEL_PT_SS_TRACING:
@@ -1879,13 +1878,14 @@ static int intel_pt_sync_switch(struct intel_pt *pt, int cpu, pid_t tid,
 		ptq->switch_state = INTEL_PT_SS_TRACING;
 		break;
 	case INTEL_PT_SS_EXPECTING_SWITCH_IP:
-		ptq->next_tid = tid;
 		intel_pt_log("ERROR: cpu %d expecting switch ip\n", cpu);
 		break;
 	default:
 		break;
 	}
 
+	ptq->next_tid = -1;
+
 	return 1;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT
  2019-04-12 11:38 [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
                   ` (7 preceding siblings ...)
  2019-04-12 11:38 ` [PATCH 8/8] perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid Adrian Hunter
@ 2019-04-29  7:28 ` Adrian Hunter
  2019-05-20 14:39   ` Arnaldo Carvalho de Melo
  8 siblings, 1 reply; 19+ messages in thread
From: Adrian Hunter @ 2019-04-29  7:28 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: Jiri Olsa, linux-kernel

On 12/04/19 2:38 PM, Adrian Hunter wrote:
> Hi
> 
> Here are patches to add support for pyside2 to the db-export scripts,
> and a couple of Intel PT patches.
> 
> 
> Adrian Hunter (8):
>       perf scripts python: exported-sql-viewer.py: Change python2 to python
>       perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing
>       perf scripts python: exported-sql-viewer.py: Add support for pyside2
>       perf scripts python: export-to-sqlite.py: Add support for pyside2
>       perf scripts python: export-to-postgresql.py: Add support for pyside2
>       perf tools: perf-with-kcore.sh: Always allow fix_buildid_cache_permissions
>       perf intel-pt: Improve sync_switch
>       perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid
> 
>  tools/perf/perf-with-kcore.sh                     |  5 ---
>  tools/perf/scripts/python/export-to-postgresql.py | 43 +++++++++++++++----
>  tools/perf/scripts/python/export-to-sqlite.py     | 44 ++++++++++++++++---
>  tools/perf/scripts/python/exported-sql-viewer.py  | 51 ++++++++++++++++-------
>  tools/perf/util/intel-pt.c                        | 44 +++++++++++++++++--
>  5 files changed, 150 insertions(+), 37 deletions(-)

Are these ok?


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT
  2019-04-29  7:28 ` [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
@ 2019-05-20 14:39   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 19+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-05-20 14:39 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: Jiri Olsa, linux-kernel

Em Mon, Apr 29, 2019 at 10:28:20AM +0300, Adrian Hunter escreveu:
> On 12/04/19 2:38 PM, Adrian Hunter wrote:
> > Hi
> > 
> > Here are patches to add support for pyside2 to the db-export scripts,
> > and a couple of Intel PT patches.
> > 
> > 
> > Adrian Hunter (8):
> >       perf scripts python: exported-sql-viewer.py: Change python2 to python
> >       perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing
> >       perf scripts python: exported-sql-viewer.py: Add support for pyside2
> >       perf scripts python: export-to-sqlite.py: Add support for pyside2
> >       perf scripts python: export-to-postgresql.py: Add support for pyside2
> >       perf tools: perf-with-kcore.sh: Always allow fix_buildid_cache_permissions
> >       perf intel-pt: Improve sync_switch
> >       perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid
> > 
> >  tools/perf/perf-with-kcore.sh                     |  5 ---
> >  tools/perf/scripts/python/export-to-postgresql.py | 43 +++++++++++++++----
> >  tools/perf/scripts/python/export-to-sqlite.py     | 44 ++++++++++++++++---
> >  tools/perf/scripts/python/exported-sql-viewer.py  | 51 ++++++++++++++++-------
> >  tools/perf/util/intel-pt.c                        | 44 +++++++++++++++++--
> >  5 files changed, 150 insertions(+), 37 deletions(-)
> 
> Are these ok?

Thanks, applied.

- Arnaldo

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tip:perf/core] perf-with-kcore.sh: Always allow fix_buildid_cache_permissions
  2019-04-12 11:38 ` [PATCH 6/8] perf tools: perf-with-kcore.sh: Always allow fix_buildid_cache_permissions Adrian Hunter
@ 2019-05-30  7:52   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Adrian Hunter @ 2019-05-30  7:52 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, tglx, mingo, adrian.hunter, jolsa, acme

Commit-ID:  a685c7a4a25c80f1f022b55830f2d894ee8847eb
Gitweb:     https://git.kernel.org/tip/a685c7a4a25c80f1f022b55830f2d894ee8847eb
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 12 Apr 2019 14:38:28 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 28 May 2019 18:37:42 -0300

perf-with-kcore.sh: Always allow fix_buildid_cache_permissions

The user's buildid cache may contain entries added by root even if root
has its own home directory (e.g. by using perfconfig to specify the same
buildid dir), so remove that validation.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190412113830.4126-7-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/perf-with-kcore.sh | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/tools/perf/perf-with-kcore.sh b/tools/perf/perf-with-kcore.sh
index 7e47a7cbc195..2ad2fffdb209 100644
--- a/tools/perf/perf-with-kcore.sh
+++ b/tools/perf/perf-with-kcore.sh
@@ -111,11 +111,6 @@ fix_buildid_cache_permissions()
 
 	USER_HOME=$(bash <<< "echo ~$SUDO_USER")
 
-	if [ "$HOME" != "$USER_HOME" ] ; then
-		echo "Fix unnecessary because root has a home: $HOME" >&2
-		exit 1
-	fi
-
 	echo "Fixing buildid cache permissions"
 
 	find "$USER_HOME/.debug" -xdev -type d          ! -user "$SUDO_USER" -ls -exec chown    "$SUDO_USER" \{\} \;

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [tip:perf/core] perf scripts python: exported-sql-viewer.py: Change python2 to python
  2019-04-12 11:38 ` [PATCH 1/8] perf scripts python: exported-sql-viewer.py: Change python2 to python Adrian Hunter
@ 2019-05-30  8:17   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Adrian Hunter @ 2019-05-30  8:17 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, jolsa, adrian.hunter, acme, linux-kernel, mingo, tglx

Commit-ID:  c6aba1bf258ff1ce201f112dafe1bdde601573dd
Gitweb:     https://git.kernel.org/tip/c6aba1bf258ff1ce201f112dafe1bdde601573dd
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 12 Apr 2019 14:38:23 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 28 May 2019 18:37:45 -0300

perf scripts python: exported-sql-viewer.py: Change python2 to python

Now that there is also support for python3, there is no need to specify
python2 explicitly.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190412113830.4126-2-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/scripts/python/exported-sql-viewer.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index affed7d149be..9ff92a130655 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
 # SPDX-License-Identifier: GPL-2.0
 # exported-sql-viewer.py: view data from sql database
 # Copyright (c) 2014-2018, Intel Corporation.

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [tip:perf/core] perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing
  2019-04-12 11:38 ` [PATCH 2/8] perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing Adrian Hunter
@ 2019-05-30  8:18   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Adrian Hunter @ 2019-05-30  8:18 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, hpa, linux-kernel, adrian.hunter, acme, mingo, tglx

Commit-ID:  1ed7f47fd3af3c09d2cd64d1aff1c5b96d238111
Gitweb:     https://git.kernel.org/tip/1ed7f47fd3af3c09d2cd64d1aff1c5b96d238111
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 12 Apr 2019 14:38:24 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 28 May 2019 18:37:45 -0300

perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing

The argparse module makes it easier to add new arguments.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190412113830.4126-3-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/scripts/python/exported-sql-viewer.py | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index 9ff92a130655..498b79454012 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -91,6 +91,7 @@
 from __future__ import print_function
 
 import sys
+import argparse
 import weakref
 import threading
 import string
@@ -3361,18 +3362,26 @@ class DBRef():
 # Main
 
 def Main():
-	if (len(sys.argv) < 2):
-		printerr("Usage is: exported-sql-viewer.py {<database name> | --help-only}");
-		raise Exception("Too few arguments")
-
-	dbname = sys.argv[1]
-	if dbname == "--help-only":
+	usage_str =	"exported-sql-viewer.py [--pyside-version-1] <database name>\n" \
+			"   or: exported-sql-viewer.py --help-only"
+	ap = argparse.ArgumentParser(usage = usage_str, add_help = False)
+	ap.add_argument("dbname", nargs="?")
+	ap.add_argument("--help-only", action='store_true')
+	args = ap.parse_args()
+
+	if args.help_only:
 		app = QApplication(sys.argv)
 		mainwindow = HelpOnlyWindow()
 		mainwindow.show()
 		err = app.exec_()
 		sys.exit(err)
 
+	dbname = args.dbname
+	if dbname is None:
+		ap.print_usage()
+		print("Too few arguments")
+		sys.exit(1)
+
 	is_sqlite3 = False
 	try:
 		f = open(dbname, "rb")

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [tip:perf/core] perf scripts python: exported-sql-viewer.py: Add support for pyside2
  2019-04-12 11:38 ` [PATCH 3/8] perf scripts python: exported-sql-viewer.py: Add support for pyside2 Adrian Hunter
@ 2019-05-30  8:19   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Adrian Hunter @ 2019-05-30  8:19 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, mingo, acme, hpa, tglx, jolsa, adrian.hunter

Commit-ID:  df8ea22a8fd9e4e8502f4fa917622801e1b4d09e
Gitweb:     https://git.kernel.org/tip/df8ea22a8fd9e4e8502f4fa917622801e1b4d09e
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 12 Apr 2019 14:38:25 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 28 May 2019 18:37:45 -0300

perf scripts python: exported-sql-viewer.py: Add support for pyside2

pyside2 is the future for pyside support.

Note pyside use Qt4 whereas pyside2 uses Qt5.

Committer testing:

On a system with just:

  # rpm -qa| grep -i pyside
  python2-pyside-1.2.4-7.fc29.x86_64
  #

Running:

  $ python ~acme/libexec/perf-core/scripts/python/exported-sql-viewer.py ~/c/adrian.hunter/simple-retpoline.db &
  [1] 7438

Makes it use the pyside 1 files:

  $ grep -i pyside /proc/7438/maps | cut -d ' ' -f 6- | sort -u
     /usr/lib64/libpyside-python2.7.so.1.2.4
     /usr/lib64/python2.7/site-packages/PySide/QtCore.so
     /usr/lib64/python2.7/site-packages/PySide/QtGui.so
     /usr/lib64/python2.7/site-packages/PySide/QtSql.so
  $ rpm -qf /usr/lib64/libpyside-python2.7.so.1.2.4
  python2-pyside-1.2.4-7.fc29.x86_64
  $

To get PySide2 I guess one needs to do:

  $ pip install PySide2

But thats a 142MiB download I can't do right now, perhaps before pushing
upstream...

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190412113830.4126-4-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/scripts/python/exported-sql-viewer.py | 28 ++++++++++++++++++------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index 498b79454012..6fe553258ce5 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -105,10 +105,23 @@ except ImportError:
 	glb_nsz = 16
 import re
 import os
-from PySide.QtCore import *
-from PySide.QtGui import *
-from PySide.QtSql import *
+
 pyside_version_1 = True
+if not "--pyside-version-1" in sys.argv:
+	try:
+		from PySide2.QtCore import *
+		from PySide2.QtGui import *
+		from PySide2.QtSql import *
+		from PySide2.QtWidgets import *
+		pyside_version_1 = False
+	except:
+		pass
+
+if pyside_version_1:
+	from PySide.QtCore import *
+	from PySide.QtGui import *
+	from PySide.QtSql import *
+
 from decimal import *
 from ctypes import *
 from multiprocessing import Process, Array, Value, Event
@@ -2755,7 +2768,7 @@ class WindowMenu():
 			action = self.window_menu.addAction(label)
 			action.setCheckable(True)
 			action.setChecked(sub_window == self.mdi_area.activeSubWindow())
-			action.triggered.connect(lambda x=nr: self.setActiveSubWindow(x))
+			action.triggered.connect(lambda a=None,x=nr: self.setActiveSubWindow(x))
 			self.window_menu.addAction(action)
 			nr += 1
 
@@ -3115,14 +3128,14 @@ class MainWindow(QMainWindow):
 			event = event.split(":")[0]
 			if event == "branches":
 				label = "All branches" if branches_events == 1 else "All branches " + "(id=" + dbid + ")"
-				reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda x=dbid: self.NewBranchView(x), self))
+				reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda a=None,x=dbid: self.NewBranchView(x), self))
 				label = "Selected branches" if branches_events == 1 else "Selected branches " + "(id=" + dbid + ")"
-				reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda x=dbid: self.NewSelectedBranchView(x), self))
+				reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda a=None,x=dbid: self.NewSelectedBranchView(x), self))
 
 	def TableMenu(self, tables, menu):
 		table_menu = menu.addMenu("&Tables")
 		for table in tables:
-			table_menu.addAction(CreateAction(table, "Create a new window containing a table view", lambda t=table: self.NewTableView(t), self))
+			table_menu.addAction(CreateAction(table, "Create a new window containing a table view", lambda a=None,t=table: self.NewTableView(t), self))
 
 	def NewCallGraph(self):
 		CallGraphWindow(self.glb, self)
@@ -3365,6 +3378,7 @@ def Main():
 	usage_str =	"exported-sql-viewer.py [--pyside-version-1] <database name>\n" \
 			"   or: exported-sql-viewer.py --help-only"
 	ap = argparse.ArgumentParser(usage = usage_str, add_help = False)
+	ap.add_argument("--pyside-version-1", action='store_true')
 	ap.add_argument("dbname", nargs="?")
 	ap.add_argument("--help-only", action='store_true')
 	args = ap.parse_args()

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [tip:perf/core] perf scripts python: export-to-sqlite.py: Add support for pyside2
  2019-04-12 11:38 ` [PATCH 4/8] perf scripts python: export-to-sqlite.py: " Adrian Hunter
@ 2019-05-30  8:19   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Adrian Hunter @ 2019-05-30  8:19 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: adrian.hunter, hpa, jolsa, linux-kernel, tglx, mingo, acme

Commit-ID:  bfb3170e2481b76a4f8aae94176e45d681a37f3e
Gitweb:     https://git.kernel.org/tip/bfb3170e2481b76a4f8aae94176e45d681a37f3e
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 12 Apr 2019 14:38:26 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 28 May 2019 18:37:45 -0300

perf scripts python: export-to-sqlite.py: Add support for pyside2

pyside2 is the future for pyside support.

Note pyside use Qt4 whereas pyside2 uses Qt5.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190412113830.4126-5-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/scripts/python/export-to-sqlite.py | 44 +++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 6 deletions(-)

diff --git a/tools/perf/scripts/python/export-to-sqlite.py b/tools/perf/scripts/python/export-to-sqlite.py
index bf271fbc3a88..f617e518332f 100644
--- a/tools/perf/scripts/python/export-to-sqlite.py
+++ b/tools/perf/scripts/python/export-to-sqlite.py
@@ -21,6 +21,26 @@ import datetime
 # provides LGPL-licensed Python bindings for Qt.  You will also need the package
 # libqt4-sql-sqlite for Qt sqlite3 support.
 #
+# Examples of installing pyside:
+#
+# ubuntu:
+#
+#	$ sudo apt-get install python-pyside.qtsql libqt4-sql-psql
+#
+#	Alternately, to use Python3 and/or pyside 2, one of the following:
+#
+#		$ sudo apt-get install python3-pyside.qtsql libqt4-sql-psql
+#		$ sudo apt-get install python-pyside2.qtsql libqt5sql5-psql
+#		$ sudo apt-get install python3-pyside2.qtsql libqt5sql5-psql
+# fedora:
+#
+#	$ sudo yum install python-pyside
+#
+#	Alternately, to use Python3 and/or pyside 2, one of the following:
+#		$ sudo yum install python3-pyside
+#		$ pip install --user PySide2
+#		$ pip3 install --user PySide2
+#
 # An example of using this script with Intel PT:
 #
 #	$ perf record -e intel_pt//u ls
@@ -49,7 +69,16 @@ import datetime
 # difference is  the 'transaction' column of the 'samples' table which is
 # renamed 'transaction_' in sqlite because 'transaction' is a reserved word.
 
-from PySide.QtSql import *
+pyside_version_1 = True
+if not "pyside-version-1" in sys.argv:
+	try:
+		from PySide2.QtSql import *
+		pyside_version_1 = False
+	except:
+		pass
+
+if pyside_version_1:
+	from PySide.QtSql import *
 
 sys.path.append(os.environ['PERF_EXEC_PATH'] + \
 	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
@@ -69,11 +98,12 @@ def printdate(*args, **kw_args):
         print(datetime.datetime.today(), *args, sep=' ', **kw_args)
 
 def usage():
-	printerr("Usage is: export-to-sqlite.py <database name> [<columns>] [<calls>] [<callchains>]");
-	printerr("where:	columns		'all' or 'branches'");
-	printerr("		calls		'calls' => create calls and call_paths table");
-	printerr("		callchains	'callchains' => create call_paths table");
-	raise Exception("Too few arguments")
+	printerr("Usage is: export-to-sqlite.py <database name> [<columns>] [<calls>] [<callchains>] [<pyside-version-1>]");
+	printerr("where:  columns            'all' or 'branches'");
+	printerr("        calls              'calls' => create calls and call_paths table");
+	printerr("        callchains         'callchains' => create call_paths table");
+	printerr("        pyside-version-1   'pyside-version-1' => use pyside version 1");
+	raise Exception("Too few or bad arguments")
 
 if (len(sys.argv) < 2):
 	usage()
@@ -95,6 +125,8 @@ for i in range(3,len(sys.argv)):
 		perf_db_export_calls = True
 	elif (sys.argv[i] == "callchains"):
 		perf_db_export_callchains = True
+	elif (sys.argv[i] == "pyside-version-1"):
+		pass
 	else:
 		usage()
 

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [tip:perf/core] perf scripts python: export-to-postgresql.py: Add support for pyside2
  2019-04-12 11:38 ` [PATCH 5/8] perf scripts python: export-to-postgresql.py: " Adrian Hunter
@ 2019-05-30  8:20   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Adrian Hunter @ 2019-05-30  8:20 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, acme, mingo, adrian.hunter, hpa, tglx, jolsa

Commit-ID:  3cd3216dbb421244b96b992f193e778a3baa2220
Gitweb:     https://git.kernel.org/tip/3cd3216dbb421244b96b992f193e778a3baa2220
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 12 Apr 2019 14:38:27 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 28 May 2019 18:37:45 -0300

perf scripts python: export-to-postgresql.py: Add support for pyside2

pyside2 is the future for pyside support.

Note pyside use Qt4 whereas pyside2 uses Qt5.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190412113830.4126-6-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/scripts/python/export-to-postgresql.py | 43 ++++++++++++++++++-----
 1 file changed, 34 insertions(+), 9 deletions(-)

diff --git a/tools/perf/scripts/python/export-to-postgresql.py b/tools/perf/scripts/python/export-to-postgresql.py
index c3eae1d77d36..b2f481b0d28d 100644
--- a/tools/perf/scripts/python/export-to-postgresql.py
+++ b/tools/perf/scripts/python/export-to-postgresql.py
@@ -27,18 +27,31 @@ import datetime
 #
 # fedora:
 #
-#	$ sudo yum install postgresql postgresql-server python-pyside qt-postgresql
+#	$ sudo yum install postgresql postgresql-server qt-postgresql
 #	$ sudo su - postgres -c initdb
 #	$ sudo service postgresql start
 #	$ sudo su - postgres
-#	$ createuser <your user id here>
+#	$ createuser -s <your user id here>    # Older versions may not support -s, in which case answer the prompt below:
 #	Shall the new role be a superuser? (y/n) y
+#	$ sudo yum install python-pyside
+#
+#	Alternately, to use Python3 and/or pyside 2, one of the following:
+#		$ sudo yum install python3-pyside
+#		$ pip install --user PySide2
+#		$ pip3 install --user PySide2
 #
 # ubuntu:
 #
-#	$ sudo apt-get install postgresql python-pyside.qtsql libqt4-sql-psql
+#	$ sudo apt-get install postgresql
 #	$ sudo su - postgres
 #	$ createuser -s <your user id here>
+#	$ sudo apt-get install python-pyside.qtsql libqt4-sql-psql
+#
+#	Alternately, to use Python3 and/or pyside 2, one of the following:
+#
+#		$ sudo apt-get install python3-pyside.qtsql libqt4-sql-psql
+#		$ sudo apt-get install python-pyside2.qtsql libqt5sql5-psql
+#		$ sudo apt-get install python3-pyside2.qtsql libqt5sql5-psql
 #
 # An example of using this script with Intel PT:
 #
@@ -199,7 +212,16 @@ import datetime
 #                   print "{0:>6}  {1:>10}  {2:>9}  {3:<30}  {4:>6}  {5:<30}".format(query.value(0), query.value(1), query.value(2), query.value(3), query.value(4), query.value(5))
 #                   call_path_id = query.value(6)
 
-from PySide.QtSql import *
+pyside_version_1 = True
+if not "pyside-version-1" in sys.argv:
+	try:
+		from PySide2.QtSql import *
+		pyside_version_1 = False
+	except:
+		pass
+
+if pyside_version_1:
+	from PySide.QtSql import *
 
 if sys.version_info < (3, 0):
 	def toserverstr(str):
@@ -255,11 +277,12 @@ def printdate(*args, **kw_args):
         print(datetime.datetime.today(), *args, sep=' ', **kw_args)
 
 def usage():
-	printerr("Usage is: export-to-postgresql.py <database name> [<columns>] [<calls>] [<callchains>]")
-	printerr("where:	columns		'all' or 'branches'")
-	printerr("		calls		'calls' => create calls and call_paths table")
-	printerr("		callchains	'callchains' => create call_paths table")
-	raise Exception("Too few arguments")
+	printerr("Usage is: export-to-postgresql.py <database name> [<columns>] [<calls>] [<callchains>] [<pyside-version-1>]");
+	printerr("where:  columns            'all' or 'branches'");
+	printerr("        calls              'calls' => create calls and call_paths table");
+	printerr("        callchains         'callchains' => create call_paths table");
+	printerr("        pyside-version-1   'pyside-version-1' => use pyside version 1");
+	raise Exception("Too few or bad arguments")
 
 if (len(sys.argv) < 2):
 	usage()
@@ -281,6 +304,8 @@ for i in range(3,len(sys.argv)):
 		perf_db_export_calls = True
 	elif (sys.argv[i] == "callchains"):
 		perf_db_export_callchains = True
+	elif (sys.argv[i] == "pyside-version-1"):
+		pass
 	else:
 		usage()
 

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [tip:perf/core] perf intel-pt: Improve sync_switch by processing PERF_RECORD_SWITCH* in events
  2019-04-12 11:38 ` [PATCH 7/8] perf intel-pt: Improve sync_switch Adrian Hunter
@ 2019-05-30  8:21   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Adrian Hunter @ 2019-05-30  8:21 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, acme, jolsa, tglx, mingo, adrian.hunter, hpa

Commit-ID:  c7b4f15ff79b539fed4c382e52e988548081bc9d
Gitweb:     https://git.kernel.org/tip/c7b4f15ff79b539fed4c382e52e988548081bc9d
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 12 Apr 2019 14:38:29 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 28 May 2019 18:37:45 -0300

perf intel-pt: Improve sync_switch by processing PERF_RECORD_SWITCH* in events

sync_switch is a facility to synchronize decoding more closely with the
point in the kernel when the context actually switched.

Improve it by processing "context switch in" events.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190412113830.4126-8-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/intel-pt.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 03b1da6d1da4..6aaba1146fc8 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1914,6 +1914,44 @@ static int intel_pt_process_switch(struct intel_pt *pt,
 	return machine__set_current_tid(pt->machine, cpu, -1, tid);
 }
 
+static int intel_pt_context_switch_in(struct intel_pt *pt,
+				      struct perf_sample *sample)
+{
+	pid_t pid = sample->pid;
+	pid_t tid = sample->tid;
+	int cpu = sample->cpu;
+
+	if (pt->sync_switch) {
+		struct intel_pt_queue *ptq;
+
+		ptq = intel_pt_cpu_to_ptq(pt, cpu);
+		if (ptq && ptq->sync_switch) {
+			ptq->next_tid = -1;
+			switch (ptq->switch_state) {
+			case INTEL_PT_SS_NOT_TRACING:
+			case INTEL_PT_SS_UNKNOWN:
+			case INTEL_PT_SS_TRACING:
+				break;
+			case INTEL_PT_SS_EXPECTING_SWITCH_EVENT:
+			case INTEL_PT_SS_EXPECTING_SWITCH_IP:
+				ptq->switch_state = INTEL_PT_SS_TRACING;
+				break;
+			default:
+				break;
+			}
+		}
+	}
+
+	/*
+	 * If the current tid has not been updated yet, ensure it is now that
+	 * a "switch in" event has occurred.
+	 */
+	if (machine__get_current_tid(pt->machine, cpu) == tid)
+		return 0;
+
+	return machine__set_current_tid(pt->machine, cpu, pid, tid);
+}
+
 static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event,
 				   struct perf_sample *sample)
 {
@@ -1925,7 +1963,7 @@ static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event,
 
 	if (pt->have_sched_switch == 3) {
 		if (!out)
-			return 0;
+			return intel_pt_context_switch_in(pt, sample);
 		if (event->header.type != PERF_RECORD_SWITCH_CPU_WIDE) {
 			pr_err("Expecting CPU-wide context switch event\n");
 			return -EINVAL;

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [tip:perf/core] perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid
  2019-04-12 11:38 ` [PATCH 8/8] perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid Adrian Hunter
@ 2019-05-30  8:21   ` tip-bot for Adrian Hunter
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Adrian Hunter @ 2019-05-30  8:21 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, acme, mingo, hpa, adrian.hunter, linux-kernel, tglx

Commit-ID:  14f1cfd4f7b4794e2f9d2ae214bcf049654b0b5c
Gitweb:     https://git.kernel.org/tip/14f1cfd4f7b4794e2f9d2ae214bcf049654b0b5c
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 12 Apr 2019 14:38:30 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 28 May 2019 18:37:45 -0300

perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid

Returning 1 from intel_pt_sync_switch() causes the current tid to be
set. That negates the need to keep next_tid anymore. Rationalize the
code to that effect.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190412113830.4126-9-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/intel-pt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 6aaba1146fc8..7a70693c1b91 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1859,7 +1859,6 @@ static int intel_pt_sync_switch(struct intel_pt *pt, int cpu, pid_t tid,
 
 	switch (ptq->switch_state) {
 	case INTEL_PT_SS_NOT_TRACING:
-		ptq->next_tid = -1;
 		break;
 	case INTEL_PT_SS_UNKNOWN:
 	case INTEL_PT_SS_TRACING:
@@ -1879,13 +1878,14 @@ static int intel_pt_sync_switch(struct intel_pt *pt, int cpu, pid_t tid,
 		ptq->switch_state = INTEL_PT_SS_TRACING;
 		break;
 	case INTEL_PT_SS_EXPECTING_SWITCH_IP:
-		ptq->next_tid = tid;
 		intel_pt_log("ERROR: cpu %d expecting switch ip\n", cpu);
 		break;
 	default:
 		break;
 	}
 
+	ptq->next_tid = -1;
+
 	return 1;
 }
 

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2019-05-30  8:22 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12 11:38 [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
2019-04-12 11:38 ` [PATCH 1/8] perf scripts python: exported-sql-viewer.py: Change python2 to python Adrian Hunter
2019-05-30  8:17   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-12 11:38 ` [PATCH 2/8] perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing Adrian Hunter
2019-05-30  8:18   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-12 11:38 ` [PATCH 3/8] perf scripts python: exported-sql-viewer.py: Add support for pyside2 Adrian Hunter
2019-05-30  8:19   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-12 11:38 ` [PATCH 4/8] perf scripts python: export-to-sqlite.py: " Adrian Hunter
2019-05-30  8:19   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-12 11:38 ` [PATCH 5/8] perf scripts python: export-to-postgresql.py: " Adrian Hunter
2019-05-30  8:20   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-12 11:38 ` [PATCH 6/8] perf tools: perf-with-kcore.sh: Always allow fix_buildid_cache_permissions Adrian Hunter
2019-05-30  7:52   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-12 11:38 ` [PATCH 7/8] perf intel-pt: Improve sync_switch Adrian Hunter
2019-05-30  8:21   ` [tip:perf/core] perf intel-pt: Improve sync_switch by processing PERF_RECORD_SWITCH* in events tip-bot for Adrian Hunter
2019-04-12 11:38 ` [PATCH 8/8] perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid Adrian Hunter
2019-05-30  8:21   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-29  7:28 ` [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
2019-05-20 14:39   ` Arnaldo Carvalho de Melo

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).