aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2019-05-30 03:47:57 -0400
committerIngo Molnar <mingo@kernel.org>2019-05-30 03:47:57 -0400
commitb33fb3cf6f5e039dea4a85a708a2c86f8a323575 (patch)
tree50daac162069c464a67b6509a2b92c88649b7210 /tools/perf/scripts/python
parent849e96f30068d4f6f8352715e02a10533a46deba (diff)
parent14f1cfd4f7b4794e2f9d2ae214bcf049654b0b5c (diff)
Merge tag 'perf-core-for-mingo-5.3-20190529' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: BPF: Jiri Olsa: - Preserve eBPF maps when loading kcore. - Fix up DSO name padding in 'perf script --call-trace', as BPF DSO names are much larger than what we used to have there. - Add --show-bpf-events to 'perf script'. perf trace: Arnaldo Carvalho de Melo: - Add string table generators and beautify arguments for the new fspick, fsmount, fsconfig, fsopen, move_mount and open_tree syscalls, as well as new values for arguments of clone and sync_file_range syscalls. perf version: Arnaldo Carvalho de Melo: - Append 12 git SHA chars to the version string. Namespaces: Namhyung Kim: - Add missing --namespaces option to 'perf top', to generate and process namespace events, just like present for 'perf record'. Intel PT: Andrian Hunter: - Fix itrace defaults for 'perf script', not using the 'use_browser' variable to figure out what options are better for 'script' and 'report' - Allow root fixing up buildid cache permissions in the perf-with-kcore.sh script when sharing that cache with another user. - Improve sync_switch, a facility used to synchronize decoding of HW traces more closely with the point in the kerne where a context switch took place, by processing the PERF_RECORD_CONTEXT_SWITCH "in" metadata records too. - Make the exported-sql-viewer.py GUI also support pyside2, which upgrades from qt4 used in pyside to qt5. Use the argparser module for more easily addition of new command line args. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python')
-rw-r--r--tools/perf/scripts/python/export-to-postgresql.py43
-rw-r--r--tools/perf/scripts/python/export-to-sqlite.py44
-rwxr-xr-xtools/perf/scripts/python/exported-sql-viewer.py51
3 files changed, 109 insertions, 29 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
27# 27#
28# fedora: 28# fedora:
29# 29#
30# $ sudo yum install postgresql postgresql-server python-pyside qt-postgresql 30# $ sudo yum install postgresql postgresql-server qt-postgresql
31# $ sudo su - postgres -c initdb 31# $ sudo su - postgres -c initdb
32# $ sudo service postgresql start 32# $ sudo service postgresql start
33# $ sudo su - postgres 33# $ sudo su - postgres
34# $ createuser <your user id here> 34# $ createuser -s <your user id here> # Older versions may not support -s, in which case answer the prompt below:
35# Shall the new role be a superuser? (y/n) y 35# Shall the new role be a superuser? (y/n) y
36# $ sudo yum install python-pyside
37#
38# Alternately, to use Python3 and/or pyside 2, one of the following:
39# $ sudo yum install python3-pyside
40# $ pip install --user PySide2
41# $ pip3 install --user PySide2
36# 42#
37# ubuntu: 43# ubuntu:
38# 44#
39# $ sudo apt-get install postgresql python-pyside.qtsql libqt4-sql-psql 45# $ sudo apt-get install postgresql
40# $ sudo su - postgres 46# $ sudo su - postgres
41# $ createuser -s <your user id here> 47# $ createuser -s <your user id here>
48# $ sudo apt-get install python-pyside.qtsql libqt4-sql-psql
49#
50# Alternately, to use Python3 and/or pyside 2, one of the following:
51#
52# $ sudo apt-get install python3-pyside.qtsql libqt4-sql-psql
53# $ sudo apt-get install python-pyside2.qtsql libqt5sql5-psql
54# $ sudo apt-get install python3-pyside2.qtsql libqt5sql5-psql
42# 55#
43# An example of using this script with Intel PT: 56# An example of using this script with Intel PT:
44# 57#
@@ -199,7 +212,16 @@ import datetime
199# 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)) 212# 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))
200# call_path_id = query.value(6) 213# call_path_id = query.value(6)
201 214
202from PySide.QtSql import * 215pyside_version_1 = True
216if not "pyside-version-1" in sys.argv:
217 try:
218 from PySide2.QtSql import *
219 pyside_version_1 = False
220 except:
221 pass
222
223if pyside_version_1:
224 from PySide.QtSql import *
203 225
204if sys.version_info < (3, 0): 226if sys.version_info < (3, 0):
205 def toserverstr(str): 227 def toserverstr(str):
@@ -255,11 +277,12 @@ def printdate(*args, **kw_args):
255 print(datetime.datetime.today(), *args, sep=' ', **kw_args) 277 print(datetime.datetime.today(), *args, sep=' ', **kw_args)
256 278
257def usage(): 279def usage():
258 printerr("Usage is: export-to-postgresql.py <database name> [<columns>] [<calls>] [<callchains>]") 280 printerr("Usage is: export-to-postgresql.py <database name> [<columns>] [<calls>] [<callchains>] [<pyside-version-1>]");
259 printerr("where: columns 'all' or 'branches'") 281 printerr("where: columns 'all' or 'branches'");
260 printerr(" calls 'calls' => create calls and call_paths table") 282 printerr(" calls 'calls' => create calls and call_paths table");
261 printerr(" callchains 'callchains' => create call_paths table") 283 printerr(" callchains 'callchains' => create call_paths table");
262 raise Exception("Too few arguments") 284 printerr(" pyside-version-1 'pyside-version-1' => use pyside version 1");
285 raise Exception("Too few or bad arguments")
263 286
264if (len(sys.argv) < 2): 287if (len(sys.argv) < 2):
265 usage() 288 usage()
@@ -281,6 +304,8 @@ for i in range(3,len(sys.argv)):
281 perf_db_export_calls = True 304 perf_db_export_calls = True
282 elif (sys.argv[i] == "callchains"): 305 elif (sys.argv[i] == "callchains"):
283 perf_db_export_callchains = True 306 perf_db_export_callchains = True
307 elif (sys.argv[i] == "pyside-version-1"):
308 pass
284 else: 309 else:
285 usage() 310 usage()
286 311
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
21# provides LGPL-licensed Python bindings for Qt. You will also need the package 21# provides LGPL-licensed Python bindings for Qt. You will also need the package
22# libqt4-sql-sqlite for Qt sqlite3 support. 22# libqt4-sql-sqlite for Qt sqlite3 support.
23# 23#
24# Examples of installing pyside:
25#
26# ubuntu:
27#
28# $ sudo apt-get install python-pyside.qtsql libqt4-sql-psql
29#
30# Alternately, to use Python3 and/or pyside 2, one of the following:
31#
32# $ sudo apt-get install python3-pyside.qtsql libqt4-sql-psql
33# $ sudo apt-get install python-pyside2.qtsql libqt5sql5-psql
34# $ sudo apt-get install python3-pyside2.qtsql libqt5sql5-psql
35# fedora:
36#
37# $ sudo yum install python-pyside
38#
39# Alternately, to use Python3 and/or pyside 2, one of the following:
40# $ sudo yum install python3-pyside
41# $ pip install --user PySide2
42# $ pip3 install --user PySide2
43#
24# An example of using this script with Intel PT: 44# An example of using this script with Intel PT:
25# 45#
26# $ perf record -e intel_pt//u ls 46# $ perf record -e intel_pt//u ls
@@ -49,7 +69,16 @@ import datetime
49# difference is the 'transaction' column of the 'samples' table which is 69# difference is the 'transaction' column of the 'samples' table which is
50# renamed 'transaction_' in sqlite because 'transaction' is a reserved word. 70# renamed 'transaction_' in sqlite because 'transaction' is a reserved word.
51 71
52from PySide.QtSql import * 72pyside_version_1 = True
73if not "pyside-version-1" in sys.argv:
74 try:
75 from PySide2.QtSql import *
76 pyside_version_1 = False
77 except:
78 pass
79
80if pyside_version_1:
81 from PySide.QtSql import *
53 82
54sys.path.append(os.environ['PERF_EXEC_PATH'] + \ 83sys.path.append(os.environ['PERF_EXEC_PATH'] + \
55 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') 84 '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
@@ -69,11 +98,12 @@ def printdate(*args, **kw_args):
69 print(datetime.datetime.today(), *args, sep=' ', **kw_args) 98 print(datetime.datetime.today(), *args, sep=' ', **kw_args)
70 99
71def usage(): 100def usage():
72 printerr("Usage is: export-to-sqlite.py <database name> [<columns>] [<calls>] [<callchains>]"); 101 printerr("Usage is: export-to-sqlite.py <database name> [<columns>] [<calls>] [<callchains>] [<pyside-version-1>]");
73 printerr("where: columns 'all' or 'branches'"); 102 printerr("where: columns 'all' or 'branches'");
74 printerr(" calls 'calls' => create calls and call_paths table"); 103 printerr(" calls 'calls' => create calls and call_paths table");
75 printerr(" callchains 'callchains' => create call_paths table"); 104 printerr(" callchains 'callchains' => create call_paths table");
76 raise Exception("Too few arguments") 105 printerr(" pyside-version-1 'pyside-version-1' => use pyside version 1");
106 raise Exception("Too few or bad arguments")
77 107
78if (len(sys.argv) < 2): 108if (len(sys.argv) < 2):
79 usage() 109 usage()
@@ -95,6 +125,8 @@ for i in range(3,len(sys.argv)):
95 perf_db_export_calls = True 125 perf_db_export_calls = True
96 elif (sys.argv[i] == "callchains"): 126 elif (sys.argv[i] == "callchains"):
97 perf_db_export_callchains = True 127 perf_db_export_callchains = True
128 elif (sys.argv[i] == "pyside-version-1"):
129 pass
98 else: 130 else:
99 usage() 131 usage()
100 132
diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
index affed7d149be..6fe553258ce5 100755
--- a/tools/perf/scripts/python/exported-sql-viewer.py
+++ b/tools/perf/scripts/python/exported-sql-viewer.py
@@ -1,4 +1,4 @@
1#!/usr/bin/env python2 1#!/usr/bin/env python
2# SPDX-License-Identifier: GPL-2.0 2# SPDX-License-Identifier: GPL-2.0
3# exported-sql-viewer.py: view data from sql database 3# exported-sql-viewer.py: view data from sql database
4# Copyright (c) 2014-2018, Intel Corporation. 4# Copyright (c) 2014-2018, Intel Corporation.
@@ -91,6 +91,7 @@
91from __future__ import print_function 91from __future__ import print_function
92 92
93import sys 93import sys
94import argparse
94import weakref 95import weakref
95import threading 96import threading
96import string 97import string
@@ -104,10 +105,23 @@ except ImportError:
104 glb_nsz = 16 105 glb_nsz = 16
105import re 106import re
106import os 107import os
107from PySide.QtCore import * 108
108from PySide.QtGui import *
109from PySide.QtSql import *
110pyside_version_1 = True 109pyside_version_1 = True
110if not "--pyside-version-1" in sys.argv:
111 try:
112 from PySide2.QtCore import *
113 from PySide2.QtGui import *
114 from PySide2.QtSql import *
115 from PySide2.QtWidgets import *
116 pyside_version_1 = False
117 except:
118 pass
119
120if pyside_version_1:
121 from PySide.QtCore import *
122 from PySide.QtGui import *
123 from PySide.QtSql import *
124
111from decimal import * 125from decimal import *
112from ctypes import * 126from ctypes import *
113from multiprocessing import Process, Array, Value, Event 127from multiprocessing import Process, Array, Value, Event
@@ -2754,7 +2768,7 @@ class WindowMenu():
2754 action = self.window_menu.addAction(label) 2768 action = self.window_menu.addAction(label)
2755 action.setCheckable(True) 2769 action.setCheckable(True)
2756 action.setChecked(sub_window == self.mdi_area.activeSubWindow()) 2770 action.setChecked(sub_window == self.mdi_area.activeSubWindow())
2757 action.triggered.connect(lambda x=nr: self.setActiveSubWindow(x)) 2771 action.triggered.connect(lambda a=None,x=nr: self.setActiveSubWindow(x))
2758 self.window_menu.addAction(action) 2772 self.window_menu.addAction(action)
2759 nr += 1 2773 nr += 1
2760 2774
@@ -3114,14 +3128,14 @@ class MainWindow(QMainWindow):
3114 event = event.split(":")[0] 3128 event = event.split(":")[0]
3115 if event == "branches": 3129 if event == "branches":
3116 label = "All branches" if branches_events == 1 else "All branches " + "(id=" + dbid + ")" 3130 label = "All branches" if branches_events == 1 else "All branches " + "(id=" + dbid + ")"
3117 reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda x=dbid: self.NewBranchView(x), self)) 3131 reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda a=None,x=dbid: self.NewBranchView(x), self))
3118 label = "Selected branches" if branches_events == 1 else "Selected branches " + "(id=" + dbid + ")" 3132 label = "Selected branches" if branches_events == 1 else "Selected branches " + "(id=" + dbid + ")"
3119 reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda x=dbid: self.NewSelectedBranchView(x), self)) 3133 reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda a=None,x=dbid: self.NewSelectedBranchView(x), self))
3120 3134
3121 def TableMenu(self, tables, menu): 3135 def TableMenu(self, tables, menu):
3122 table_menu = menu.addMenu("&Tables") 3136 table_menu = menu.addMenu("&Tables")
3123 for table in tables: 3137 for table in tables:
3124 table_menu.addAction(CreateAction(table, "Create a new window containing a table view", lambda t=table: self.NewTableView(t), self)) 3138 table_menu.addAction(CreateAction(table, "Create a new window containing a table view", lambda a=None,t=table: self.NewTableView(t), self))
3125 3139
3126 def NewCallGraph(self): 3140 def NewCallGraph(self):
3127 CallGraphWindow(self.glb, self) 3141 CallGraphWindow(self.glb, self)
@@ -3361,18 +3375,27 @@ class DBRef():
3361# Main 3375# Main
3362 3376
3363def Main(): 3377def Main():
3364 if (len(sys.argv) < 2): 3378 usage_str = "exported-sql-viewer.py [--pyside-version-1] <database name>\n" \
3365 printerr("Usage is: exported-sql-viewer.py {<database name> | --help-only}"); 3379 " or: exported-sql-viewer.py --help-only"
3366 raise Exception("Too few arguments") 3380 ap = argparse.ArgumentParser(usage = usage_str, add_help = False)
3367 3381 ap.add_argument("--pyside-version-1", action='store_true')
3368 dbname = sys.argv[1] 3382 ap.add_argument("dbname", nargs="?")
3369 if dbname == "--help-only": 3383 ap.add_argument("--help-only", action='store_true')
3384 args = ap.parse_args()
3385
3386 if args.help_only:
3370 app = QApplication(sys.argv) 3387 app = QApplication(sys.argv)
3371 mainwindow = HelpOnlyWindow() 3388 mainwindow = HelpOnlyWindow()
3372 mainwindow.show() 3389 mainwindow.show()
3373 err = app.exec_() 3390 err = app.exec_()
3374 sys.exit(err) 3391 sys.exit(err)
3375 3392
3393 dbname = args.dbname
3394 if dbname is None:
3395 ap.print_usage()
3396 print("Too few arguments")
3397 sys.exit(1)
3398
3376 is_sqlite3 = False 3399 is_sqlite3 = False
3377 try: 3400 try:
3378 f = open(dbname, "rb") 3401 f = open(dbname, "rb")