summaryrefslogtreecommitdiffstats
path: root/tools/perf/python
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2015-12-02 09:33:25 -0800
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-12-02 09:33:25 -0800
commit0eea505058740aa45486145296ef4fefbd8cab85 (patch)
tree1bc265d615b8353405a04630f610a42c48302f47 /tools/perf/python
parent5e0baca8b3247f459af50947eaafc68bb8168b33 (diff)
parent31ade3b83e1821da5fbb2f11b5b3d4ab2ec39db8 (diff)
downloadcachepc-linux-0eea505058740aa45486145296ef4fefbd8cab85.tar.gz
cachepc-linux-0eea505058740aa45486145296ef4fefbd8cab85.zip
Merge tag 'v4.4-rc3' into next
Merge with Linux 4.4-rc3 to bring in helpers for multiu-driver modules.
Diffstat (limited to 'tools/perf/python')
-rwxr-xr-xtools/perf/python/twatch.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/tools/perf/python/twatch.py b/tools/perf/python/twatch.py
index b9d508336ae6..c235c22b107a 100755
--- a/tools/perf/python/twatch.py
+++ b/tools/perf/python/twatch.py
@@ -15,14 +15,14 @@
import perf
-def main():
+def main(context_switch = 0, thread = -1):
cpus = perf.cpu_map()
- threads = perf.thread_map()
+ threads = perf.thread_map(thread)
evsel = perf.evsel(type = perf.TYPE_SOFTWARE,
config = perf.COUNT_SW_DUMMY,
task = 1, comm = 1, mmap = 0, freq = 0,
wakeup_events = 1, watermark = 1,
- sample_id_all = 1,
+ sample_id_all = 1, context_switch = context_switch,
sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU)
"""What we want are just the PERF_RECORD_ lifetime events for threads,
@@ -48,4 +48,21 @@ def main():
print event
if __name__ == '__main__':
+ """
+ To test the PERF_RECORD_SWITCH record, pick a pid and replace
+ in the following line.
+
+ Example output:
+
+cpu: 3, pid: 31463, tid: 31593 { type: context_switch, next_prev_pid: 31463, next_prev_tid: 31593, switch_out: 1 }
+cpu: 1, pid: 31463, tid: 31489 { type: context_switch, next_prev_pid: 31463, next_prev_tid: 31489, switch_out: 1 }
+cpu: 2, pid: 31463, tid: 31496 { type: context_switch, next_prev_pid: 31463, next_prev_tid: 31496, switch_out: 1 }
+cpu: 3, pid: 31463, tid: 31491 { type: context_switch, next_prev_pid: 31463, next_prev_tid: 31491, switch_out: 0 }
+
+ It is possible as well to use event.misc & perf.PERF_RECORD_MISC_SWITCH_OUT
+ to figure out if this is a context switch in or out of the monitored threads.
+
+ If bored, please add command line option parsing support for these options :-)
+ """
+ # main(context_switch = 1, thread = 31463)
main()