You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5130c6e
Browse filesBrowse the repository at this point in the historyBrowse files
perf scripts python: export-to-sqlite.py: Export Intel PT power and ptwrite events
The format of synthesized events is determined by the attribute config.
For the formats for Intel PT power and ptwrite events, create tables and
populate them when the synth_data handler is called. If the tables
remain empty, drop them at the end.
The tables and views, including a combined power_events_view, will
display automatically from the tables menu of the exported
exported-sql-viewer.py script.
Note, currently only Atoms since Gemini Lake have support for ptwrite
and mwait, pwre, exstop and pwrx, but all Intel PT implementations
support cbr.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190622093248.581-7-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Copy file name to clipboardExpand all lines: tools/perf/scripts/python/export-to-sqlite.py
+239Lines changed: 239 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -271,6 +271,38 @@ def do_query_(q):
271
271
'insn_count bigint,'
272
272
'cyc_count bigint)')
273
273
274
+
do_query(query, 'CREATE TABLE ptwrite ('
275
+
'id integer NOT NULL PRIMARY KEY,'
276
+
'payload bigint,'
277
+
'exact_ip integer)')
278
+
279
+
do_query(query, 'CREATE TABLE cbr ('
280
+
'id integer NOT NULL PRIMARY KEY,'
281
+
'cbr integer,'
282
+
'mhz integer,'
283
+
'percent integer)')
284
+
285
+
do_query(query, 'CREATE TABLE mwait ('
286
+
'id integer NOT NULL PRIMARY KEY,'
287
+
'hints integer,'
288
+
'extensions integer)')
289
+
290
+
do_query(query, 'CREATE TABLE pwre ('
291
+
'id integer NOT NULL PRIMARY KEY,'
292
+
'cstate integer,'
293
+
'subcstate integer,'
294
+
'hw integer)')
295
+
296
+
do_query(query, 'CREATE TABLE exstop ('
297
+
'id integer NOT NULL PRIMARY KEY,'
298
+
'exact_ip integer)')
299
+
300
+
do_query(query, 'CREATE TABLE pwrx ('
301
+
'id integer NOT NULL PRIMARY KEY,'
302
+
'deepest_cstate integer,'
303
+
'last_cstate integer,'
304
+
'wake_reason integer)')
305
+
274
306
# printf was added to sqlite in version 3.8.3
275
307
sqlite_has_printf=False
276
308
try:
@@ -399,6 +431,102 @@ def emit_to_hex(x):
399
431
'CASE WHEN cyc_count=0 THEN CAST(0 AS FLOAT) ELSE ROUND(CAST(insn_count AS FLOAT) / cyc_count, 2) END AS IPC'
400
432
' FROM samples')
401
433
434
+
do_query(query, 'CREATE VIEW ptwrite_view AS '
435
+
'SELECT '
436
+
'ptwrite.id,'
437
+
'time,'
438
+
'cpu,'
439
+
+emit_to_hex('payload') +' AS payload_hex,'
440
+
'CASE WHEN exact_ip=0 THEN \'False\' ELSE \'True\' END AS exact_ip'
441
+
' FROM ptwrite'
442
+
' INNER JOIN samples ON samples.id = ptwrite.id')
443
+
444
+
do_query(query, 'CREATE VIEW cbr_view AS '
445
+
'SELECT '
446
+
'cbr.id,'
447
+
'time,'
448
+
'cpu,'
449
+
'cbr,'
450
+
'mhz,'
451
+
'percent'
452
+
' FROM cbr'
453
+
' INNER JOIN samples ON samples.id = cbr.id')
454
+
455
+
do_query(query, 'CREATE VIEW mwait_view AS '
456
+
'SELECT '
457
+
'mwait.id,'
458
+
'time,'
459
+
'cpu,'
460
+
+emit_to_hex('hints') +' AS hints_hex,'
461
+
+emit_to_hex('extensions') +' AS extensions_hex'
462
+
' FROM mwait'
463
+
' INNER JOIN samples ON samples.id = mwait.id')
464
+
465
+
do_query(query, 'CREATE VIEW pwre_view AS '
466
+
'SELECT '
467
+
'pwre.id,'
468
+
'time,'
469
+
'cpu,'
470
+
'cstate,'
471
+
'subcstate,'
472
+
'CASE WHEN hw=0 THEN \'False\' ELSE \'True\' END AS hw'
473
+
' FROM pwre'
474
+
' INNER JOIN samples ON samples.id = pwre.id')
475
+
476
+
do_query(query, 'CREATE VIEW exstop_view AS '
477
+
'SELECT '
478
+
'exstop.id,'
479
+
'time,'
480
+
'cpu,'
481
+
'CASE WHEN exact_ip=0 THEN \'False\' ELSE \'True\' END AS exact_ip'
482
+
' FROM exstop'
483
+
' INNER JOIN samples ON samples.id = exstop.id')
484
+
485
+
do_query(query, 'CREATE VIEW pwrx_view AS '
486
+
'SELECT '
487
+
'pwrx.id,'
488
+
'time,'
489
+
'cpu,'
490
+
'deepest_cstate,'
491
+
'last_cstate,'
492
+
'CASE WHEN wake_reason=1 THEN \'Interrupt\''
493
+
' WHEN wake_reason=2 THEN \'Timer Deadline\''
494
+
' WHEN wake_reason=4 THEN \'Monitored Address\''
495
+
' WHEN wake_reason=8 THEN \'HW\''
496
+
' ELSE wake_reason '
497
+
'END AS wake_reason'
498
+
' FROM pwrx'
499
+
' INNER JOIN samples ON samples.id = pwrx.id')
500
+
501
+
do_query(query, 'CREATE VIEW power_events_view AS '
502
+
'SELECT '
503
+
'samples.id,'
504
+
'time,'
505
+
'cpu,'
506
+
'selected_events.name AS event,'
507
+
'CASE WHEN selected_events.name=\'cbr\' THEN (SELECT cbr FROM cbr WHERE cbr.id = samples.id) ELSE "" END AS cbr,'
508
+
'CASE WHEN selected_events.name=\'cbr\' THEN (SELECT mhz FROM cbr WHERE cbr.id = samples.id) ELSE "" END AS mhz,'
509
+
'CASE WHEN selected_events.name=\'cbr\' THEN (SELECT percent FROM cbr WHERE cbr.id = samples.id) ELSE "" END AS percent,'
510
+
'CASE WHEN selected_events.name=\'mwait\' THEN (SELECT '+emit_to_hex('hints') +' FROM mwait WHERE mwait.id = samples.id) ELSE "" END AS hints_hex,'
511
+
'CASE WHEN selected_events.name=\'mwait\' THEN (SELECT '+emit_to_hex('extensions') +' FROM mwait WHERE mwait.id = samples.id) ELSE "" END AS extensions_hex,'
512
+
'CASE WHEN selected_events.name=\'pwre\' THEN (SELECT cstate FROM pwre WHERE pwre.id = samples.id) ELSE "" END AS cstate,'
513
+
'CASE WHEN selected_events.name=\'pwre\' THEN (SELECT subcstate FROM pwre WHERE pwre.id = samples.id) ELSE "" END AS subcstate,'
514
+
'CASE WHEN selected_events.name=\'pwre\' THEN (SELECT hw FROM pwre WHERE pwre.id = samples.id) ELSE "" END AS hw,'
515
+
'CASE WHEN selected_events.name=\'exstop\' THEN (SELECT exact_ip FROM exstop WHERE exstop.id = samples.id) ELSE "" END AS exact_ip,'
516
+
'CASE WHEN selected_events.name=\'pwrx\' THEN (SELECT deepest_cstate FROM pwrx WHERE pwrx.id = samples.id) ELSE "" END AS deepest_cstate,'
517
+
'CASE WHEN selected_events.name=\'pwrx\' THEN (SELECT last_cstate FROM pwrx WHERE pwrx.id = samples.id) ELSE "" END AS last_cstate,'
518
+
'CASE WHEN selected_events.name=\'pwrx\' THEN (SELECT '
519
+
'CASE WHEN wake_reason=1 THEN \'Interrupt\''
520
+
' WHEN wake_reason=2 THEN \'Timer Deadline\''
521
+
' WHEN wake_reason=4 THEN \'Monitored Address\''
522
+
' WHEN wake_reason=8 THEN \'HW\''
523
+
' ELSE wake_reason '
524
+
'END'
525
+
' FROM pwrx WHERE pwrx.id = samples.id) ELSE "" END AS wake_reason'
526
+
' FROM samples'
527
+
' INNER JOIN selected_events ON selected_events.id = evsel_id'
528
+
' WHERE selected_events.name IN (\'cbr\',\'mwait\',\'exstop\',\'pwre\',\'pwrx\')')
0 commit comments