perf scripts python: Support pyside2 and misc Intel PT
Adrian Hunter
reviewercover perf scripts python: Support pyside2 and misc Intel PT
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
Adrian Hunter
reviewerPATCH 1/8 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.
--- tools/perf/scripts/python/exported-sql-viewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/scripts/python/exported-sql-viewer.py +1 -1
@@ -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.
Signature · 1 line
2.17.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf scripts python: exported-sql-viewer.py: Change python2 to python
perf scripts python: exported-sql-viewer.py: Change python2 to python
Commit-ID: c6aba1bf258ff1ce201f112dafe1bdde601573dd Gitweb: https://git.kernel.org/tip/c6aba1bf258ff1ce201f112dafe1bdde601573dd Author: Adrian Hunter <[email protected]> AuthorDate: Fri, 12 Apr 2019 14:38:23 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- tools/perf/scripts/python/exported-sql-viewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/scripts/python/exported-sql-viewer.py +1 -1
@@ -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.
Adrian Hunter
reviewerPATCH 2/8 perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing
In reply to Adrian Hunterargparse makes it easier to add new arguments.
--- .../scripts/python/exported-sql-viewer.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
tools/perf/scripts/python/exported-sql-viewer.py +15 -6
@@ -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")
Signature · 1 line
2.17.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing
perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing
Commit-ID: 1ed7f47fd3af3c09d2cd64d1aff1c5b96d238111 Gitweb: https://git.kernel.org/tip/1ed7f47fd3af3c09d2cd64d1aff1c5b96d238111 Author: Adrian Hunter <[email protected]> AuthorDate: Fri, 12 Apr 2019 14:38:24 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- tools/perf/scripts/python/exported-sql-viewer.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
tools/perf/scripts/python/exported-sql-viewer.py +15 -6
@@ -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")
Adrian Hunter
reviewerPATCH 3/8 perf scripts python: exported-sql-viewer.py: Add support for pyside2
In reply to Adrian Hunterpyside2 is the future for pyside support.
Note pyside use Qt4 whereas pyside2 uses Qt5.
--- .../scripts/python/exported-sql-viewer.py | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-)
tools/perf/scripts/python/exported-sql-viewer.py +21 -7
@@ -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()
Signature · 1 line
2.17.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf scripts python: exported-sql-viewer.py: Add support for pyside2
perf scripts python: exported-sql-viewer.py: Add support for pyside2
Commit-ID: df8ea22a8fd9e4e8502f4fa917622801e1b4d09e Gitweb: https://git.kernel.org/tip/df8ea22a8fd9e4e8502f4fa917622801e1b4d09e Author: Adrian Hunter <[email protected]> AuthorDate: Fri, 12 Apr 2019 14:38:25 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> 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...
--- tools/perf/scripts/python/exported-sql-viewer.py | 28 ++++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-)
tools/perf/scripts/python/exported-sql-viewer.py +21 -7
@@ -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()
Adrian Hunter
reviewerPATCH 4/8 perf scripts python: export-to-sqlite.py: Add support for pyside2
In reply to Adrian Hunterpyside2 is the future for pyside support.
Note pyside use Qt4 whereas pyside2 uses Qt5.
--- tools/perf/scripts/python/export-to-sqlite.py | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-)
tools/perf/scripts/python/export-to-sqlite.py +38 -6
@@ -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()
Signature · 1 line
2.17.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf scripts python: export-to-sqlite.py: Add support for pyside2
perf scripts python: export-to-sqlite.py: Add support for pyside2
Commit-ID: bfb3170e2481b76a4f8aae94176e45d681a37f3e Gitweb: https://git.kernel.org/tip/bfb3170e2481b76a4f8aae94176e45d681a37f3e Author: Adrian Hunter <[email protected]> AuthorDate: Fri, 12 Apr 2019 14:38:26 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- tools/perf/scripts/python/export-to-sqlite.py | 44 +++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 6 deletions(-)
tools/perf/scripts/python/export-to-sqlite.py +38 -6
@@ -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()
Adrian Hunter
reviewerPATCH 5/8 perf scripts python: export-to-postgresql.py: Add support for pyside2
In reply to Adrian Hunterpyside2 is the future for pyside support.
Note pyside use Qt4 whereas pyside2 uses Qt5.
--- .../scripts/python/export-to-postgresql.py | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-)
tools/perf/scripts/python/export-to-postgresql.py +34 -9
@@ -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()
Signature · 1 line
2.17.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf scripts python: export-to-postgresql.py: Add support for pyside2
perf scripts python: export-to-postgresql.py: Add support for pyside2
Commit-ID: 3cd3216dbb421244b96b992f193e778a3baa2220 Gitweb: https://git.kernel.org/tip/3cd3216dbb421244b96b992f193e778a3baa2220 Author: Adrian Hunter <[email protected]> AuthorDate: Fri, 12 Apr 2019 14:38:27 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- tools/perf/scripts/python/export-to-postgresql.py | 43 ++++++++++++++++++----- 1 file changed, 34 insertions(+), 9 deletions(-)
tools/perf/scripts/python/export-to-postgresql.py +34 -9
@@ -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()
Adrian Hunter
reviewerPATCH 6/8 perf tools: perf-with-kcore.sh: Always allow fix_buildid_cache_permissions
In reply to Adrian HunterThe 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.
--- tools/perf/perf-with-kcore.sh | 5 ----- 1 file changed, 5 deletions(-)
tools/perf/perf-with-kcore.sh +0 -5
@@ -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" \{\} \;
Signature · 1 line
2.17.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf-with-kcore.sh: Always allow fix_buildid_cache_permissions
perf-with-kcore.sh: Always allow fix_buildid_cache_permissions
Commit-ID: a685c7a4a25c80f1f022b55830f2d894ee8847eb Gitweb: https://git.kernel.org/tip/a685c7a4a25c80f1f022b55830f2d894ee8847eb Author: Adrian Hunter <[email protected]> AuthorDate: Fri, 12 Apr 2019 14:38:28 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- tools/perf/perf-with-kcore.sh | 5 ----- 1 file changed, 5 deletions(-)
tools/perf/perf-with-kcore.sh +0 -5
@@ -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" \{\} \;
Adrian Hunter
reviewerPATCH 7/8 perf intel-pt: Improve sync_switch
In reply to Adrian Huntersync_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.
--- tools/perf/util/intel-pt.c | 40 +++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-)
tools/perf/util/intel-pt.c +39 -1
@@ -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 ;
Signature · 1 line
2.17.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf intel-pt: Improve sync_switch by processing PERF_RECORD_SWITCH* in events
perf intel-pt: Improve sync_switch by processing PERF_RECORD_SWITCH* in events
Commit-ID: c7b4f15ff79b539fed4c382e52e988548081bc9d Gitweb: https://git.kernel.org/tip/c7b4f15ff79b539fed4c382e52e988548081bc9d Author: Adrian Hunter <[email protected]> AuthorDate: Fri, 12 Apr 2019 14:38:29 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- tools/perf/util/intel-pt.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-)
tools/perf/util/intel-pt.c +39 -1
@@ -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 ;
Adrian Hunter
reviewerPATCH 8/8 perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid
In reply to Adrian HunterReturning 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.
--- tools/perf/util/intel-pt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/intel-pt.c +2 -2
@@ -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 ; }
Signature · 1 line
2.17.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid
perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid
Commit-ID: 14f1cfd4f7b4794e2f9d2ae214bcf049654b0b5c Gitweb: https://git.kernel.org/tip/14f1cfd4f7b4794e2f9d2ae214bcf049654b0b5c Author: Adrian Hunter <[email protected]> AuthorDate: Fri, 12 Apr 2019 14:38:30 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- tools/perf/util/intel-pt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/intel-pt.c +2 -2
@@ -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 ; }
Adrian Hunter
reviewerQuoted 16 lines · Adrian Hunter
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 allowfix_buildid_cache_permissionsperf intel-pt: Improvesync_switch
perf intel-pt: Rationalize intel_pt_sync_switch()'s use ofnext_tid
Quoted 6 lines
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?
Arnaldo Carvalho de Melo
AppliedEm Mon, Apr 29, 2019 at 10:28:20AM +0300, Adrian Hunter escreveu:
Quoted 17 lines · Adrian Hunter
Quoted 16 lines
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 allowfix_buildid_cache_permissionsperf intel-pt: Improvesync_switch
perf intel-pt: Rationalize intel_pt_sync_switch()'s use ofnext_tid
Quoted 8 lines
Quoted 6 lines
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