23 Sep, 2020

2 commits

  • Average is quite informative, but the outliners - especially max - are
    also of interest.

    Before:

    mutex-locker[793299] lock 5637ec61e080 contended 3400 times, 446 avg ns
    mutex-locker[793301] lock 5637ec61e080 contended 3563 times, 385 avg ns
    mutex-locker[793300] lock 5637ec61e080 contended 3110 times, 1855 avg ns

    After:

    mutex-locker[795251] lock 55b14e6dd080 contended 3853 times, 1279 avg ns [max: 12270 ns, min 340 ns]
    mutex-locker[795253] lock 55b14e6dd080 contended 2911 times, 518 avg ns [max: 51660261 ns, min 347 ns]
    mutex-locker[795252] lock 55b14e6dd080 contended 3843 times, 385 avg ns [max: 24323998 ns, min 338 ns]

    Committer testing:

    [root@five ~]# perf script record futex-contention -a
    ^C[ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 1.877 MB perf.data (923 samples) ]

    [root@five ~]# perf evlist
    syscalls:sys_enter_futex
    syscalls:sys_exit_futex
    dummy:HG
    # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
    #

    Before:

    [root@five ~]# perf script report futex-contention
    JS Helper[2457] lock 55fe0cf82610 contended 4 times, 6657 avg ns
    ibus-daemon[2975] lock 56227f6d0210 contended 4 times, 1020 avg ns
    chromium-browse[1905801] lock 7ffe573f5088 contended 8 times, 108463 avg ns
    gnome-shell[2240] lock 55fe0cf82678 contended 1 times, 8616 avg ns
    gnome-shel:cs0[2292] lock 55fe0d0ab768 contended 3 times, 606016034 avg ns
    JS Helper[2458] lock 55fe0cf82690 contended 1 times, 1167840 avg ns
    chromium-browse[1905470] lock 7ffe573f5358 contended 1 times, 551504 avg ns
    chromium-browse[1905948] lock 7ffe573f5358 contended 1 times, 577422 avg ns
    gnome-shell[2240] lock 55fe0cf82660 contended 6 times, 202696 avg ns
    pool[2602] lock 7fd600008ef0 contended 1 times, 500046007 avg ns
    chromium-browse[1905801] lock 7ffe573f5128 contended 4 times, 285083 avg ns
    JS Helper[2460] lock 55fe0cf82690 contended 1 times, 680877 avg ns
    JS Helper[2459] lock 55fe0cf82610 contended 7 times, 4224 avg ns
    chromium-browse[1905434] lock 7ffe573f5358 contended 1 times, 697038 avg ns
    chromium-browse[212592] lock 7ffe573f53c8 contended 4 times, 460601 avg ns
    gnome-shel:cs0[2292] lock 55fe0d0ab76c contended 2 times, 601237648 avg ns
    JS Helper[2460] lock 55fe0cf82610 contended 4 times, 3340 avg ns
    JS Helper[2462] lock 55fe0cf82694 contended 1 times, 237275 avg ns
    chromium-browse[1905605] lock 7ffe573f5358 contended 2 times, 634555 avg ns
    chromium-browse[1905992] lock 7ffe573f5358 contended 1 times, 583965 avg ns
    chromium-browse[1905647] lock 7ffe573f5368 contended 8 times, 549800 avg ns
    JS Helper[2462] lock 55fe0cf82610 contended 2 times, 4694 avg ns
    JS Helper[2461] lock 55fe0cf82694 contended 1 times, 257793 avg ns
    JS Helper[2456] lock 55fe0cf82690 contended 1 times, 677771 avg ns
    JS Helper[2463] lock 55fe0cf82610 contended 3 times, 5139 avg ns
    gdbus[2980] lock 56227f6d0210 contended 2 times, 2465 avg ns
    gnome-shell[2240] lock 55fe0cf82664 contended 5 times, 8036 avg ns
    chromium-browse[1906308] lock 7ffe573f5358 contended 1 times, 210735 avg ns
    JS Helper[2463] lock 55fe0cf82694 contended 1 times, 251531 avg ns
    chromium-browse[1905801] lock 7ffe573f4f58 contended 4 times, 399927 avg ns
    [root@five ~]#

    After:

    [root@five ~]# perf script report futex-contention
    JS Helper[2457] lock 55fe0cf82610 contended 4 times, 6657 avg ns [max: 11502 ns, min 792 ns]
    ibus-daemon[2975] lock 56227f6d0210 contended 4 times, 1020 avg ns [max: 1813 ns, min 581 ns]
    chromium-browse[1905801] lock 7ffe573f5088 contended 8 times, 108463 avg ns [max: 380103 ns, min 57989 ns]
    gnome-shell[2240] lock 55fe0cf82678 contended 1 times, 8616 avg ns [max: 8616 ns, min 8616 ns]
    gnome-shel:cs0[2292] lock 55fe0d0ab768 contended 3 times, 606016034 avg ns [max: 611295960 ns, min 600191357 ns]
    JS Helper[2458] lock 55fe0cf82690 contended 1 times, 1167840 avg ns [max: 1167840 ns, min 1167840 ns]
    chromium-browse[1905470] lock 7ffe573f5358 contended 1 times, 551504 avg ns [max: 551504 ns, min 551504 ns]
    chromium-browse[1905948] lock 7ffe573f5358 contended 1 times, 577422 avg ns [max: 577422 ns, min 577422 ns]
    gnome-shell[2240] lock 55fe0cf82660 contended 6 times, 202696 avg ns [max: 398998 ns, min 5050 ns]
    pool[2602] lock 7fd600008ef0 contended 1 times, 500046007 avg ns [max: 500046007 ns, min 500046007 ns]
    chromium-browse[1905801] lock 7ffe573f5128 contended 4 times, 285083 avg ns [max: 389531 ns, min 76183 ns]
    JS Helper[2460] lock 55fe0cf82690 contended 1 times, 680877 avg ns [max: 680877 ns, min 680877 ns]
    JS Helper[2459] lock 55fe0cf82610 contended 7 times, 4224 avg ns [max: 12724 ns, min 1012 ns]
    chromium-browse[1905434] lock 7ffe573f5358 contended 1 times, 697038 avg ns [max: 697038 ns, min 697038 ns]
    chromium-browse[212592] lock 7ffe573f53c8 contended 4 times, 460601 avg ns [max: 594956 ns, min 232996 ns]
    gnome-shel:cs0[2292] lock 55fe0d0ab76c contended 2 times, 601237648 avg ns [max: 601255863 ns, min 601219434 ns]
    JS Helper[2460] lock 55fe0cf82610 contended 4 times, 3340 avg ns [max: 9168 ns, min 962 ns]
    JS Helper[2462] lock 55fe0cf82694 contended 1 times, 237275 avg ns [max: 237275 ns, min 237275 ns]
    chromium-browse[1905605] lock 7ffe573f5358 contended 2 times, 634555 avg ns [max: 1024060 ns, min 245050 ns]
    chromium-browse[1905992] lock 7ffe573f5358 contended 1 times, 583965 avg ns [max: 583965 ns, min 583965 ns]
    chromium-browse[1905647] lock 7ffe573f5368 contended 8 times, 549800 avg ns [max: 775293 ns, min 258375 ns]
    JS Helper[2462] lock 55fe0cf82610 contended 2 times, 4694 avg ns [max: 8556 ns, min 832 ns]
    JS Helper[2461] lock 55fe0cf82694 contended 1 times, 257793 avg ns [max: 257793 ns, min 257793 ns]
    JS Helper[2456] lock 55fe0cf82690 contended 1 times, 677771 avg ns [max: 677771 ns, min 677771 ns]
    JS Helper[2463] lock 55fe0cf82610 contended 3 times, 5139 avg ns [max: 6873 ns, min 931 ns]
    gdbus[2980] lock 56227f6d0210 contended 2 times, 2465 avg ns [max: 4188 ns, min 742 ns]
    gnome-shell[2240] lock 55fe0cf82664 contended 5 times, 8036 avg ns [max: 13105 ns, min 401 ns]
    chromium-browse[1906308] lock 7ffe573f5358 contended 1 times, 210735 avg ns [max: 210735 ns, min 210735 ns]
    JS Helper[2463] lock 55fe0cf82694 contended 1 times, 251531 avg ns [max: 251531 ns, min 251531 ns]
    chromium-browse[1905801] lock 7ffe573f4f58 contended 4 times, 399927 avg ns [max: 476904 ns, min 178495 ns]
    [root@five ~]#

    Signed-off-by: Hagen Paul Pfeifer
    Tested-by: Arnaldo Carvalho de Melo
    Link: http://lore.kernel.org/lkml/20200922200922.1306034-1-hagen@jauu.net
    Signed-off-by: Arnaldo Carvalho de Melo

    Hagen Paul Pfeifer
     
  • 10 years leaves its mark! Python has evolved and so has its style guide.
    Even with vim it is getting hard to follow the no longer valid
    guidelines (spaces vs. tabs).

    Autopep8 this code to modernize it!

    Signed-off-by: Hagen Paul Pfeifer
    Link: http://lore.kernel.org/lkml/20200921201928.799498-1-hagen@jauu.net
    Signed-off-by: Arnaldo Carvalho de Melo

    Hagen Paul Pfeifer
     

03 Jul, 2020

5 commits

  • Using Python version 3.8.2 and PySide2 version 5.14.0, time chart call tree
    would not expand the tree to the result. Fix by using setExpanded().

    Example:

    $ perf record -e intel_pt//u uname
    Linux
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.034 MB perf.data ]
    $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
    2020-06-26 15:32:14.928997 Creating database ...
    2020-06-26 15:32:14.933971 Writing records...
    2020-06-26 15:32:15.535251 Adding indexes
    2020-06-26 15:32:15.542993 Dropping unused tables
    2020-06-26 15:32:15.549716 Done
    $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db

    Select: Charts -> Time chart by CPU
    Move mouse over middle of chart
    Right-click and select Show Call Tree

    Before: displays Call Tree but not expanded to selected time
    After: displays Call Tree expanded to selected time

    Fixes: e69d5df75d74d ("perf scripts python: exported-sql-viewer.py: Add ability for Call tree to open at a specified task and time")
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200629091955.17090-7-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Using ctrl-F ('Find') would not find 'unknown' because it matches id
    zero. Fix by excluding id zero from selection.

    Example:

    $ perf record -e intel_pt//u uname
    Linux
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.034 MB perf.data ]
    $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
    2020-06-26 15:32:14.928997 Creating database ...
    2020-06-26 15:32:14.933971 Writing records...
    2020-06-26 15:32:15.535251 Adding indexes
    2020-06-26 15:32:15.542993 Dropping unused tables
    2020-06-26 15:32:15.549716 Done
    $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db

    Select: Reports -> Call Tree
    Press: Ctrl-F
    Enter: unknown
    Press: Enter

    Before: displays 'unknown' not found
    After: tree is expanded to line showing 'unknown'

    Fixes: ae8b887c00d3f ("perf scripts python: exported-sql-viewer.py: Add call tree")
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200629091955.17090-6-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Using ctrl-F ('Find') would not find 'unknown' because it matches id zero.
    Fix by excluding id zero from selection.

    Example:

    $ perf record -e intel_pt//u uname
    Linux
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.034 MB perf.data ]
    $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
    2020-06-26 15:32:14.928997 Creating database ...
    2020-06-26 15:32:14.933971 Writing records...
    2020-06-26 15:32:15.535251 Adding indexes
    2020-06-26 15:32:15.542993 Dropping unused tables
    2020-06-26 15:32:15.549716 Done
    $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db

    Select: Reports -> Context-Sensitive Call Graph
    Press: Ctrl-F
    Enter: unknown
    Press: Enter

    Before: gets stuck
    After: tree is expanded to line showing 'unknown'

    Fixes: 254c0d820b86d ("perf scripts python: exported-sql-viewer.py: Factor out CallGraphModelBase")
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200629091955.17090-5-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Using Python version 3.8.2 and PySide2 version 5.14.0, ctrl-F ('Find')
    would not expand the tree to the result. Fix by using setExpanded().

    Example:

    $ perf record -e intel_pt//u uname
    Linux
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.034 MB perf.data ]
    $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
    2020-06-26 15:32:14.928997 Creating database ...
    2020-06-26 15:32:14.933971 Writing records...
    2020-06-26 15:32:15.535251 Adding indexes
    2020-06-26 15:32:15.542993 Dropping unused tables
    2020-06-26 15:32:15.549716 Done
    $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db

    Select: Reports -> Context-Sensitive Call Graph or Reports -> Call Tree
    Press: Ctrl-F
    Enter: main
    Press: Enter

    Before: line showing 'main' does not display

    After: tree is expanded to line showing 'main'

    Fixes: ebd70c7dc2f5f ("perf scripts python: exported-sql-viewer.py: Add ability to find symbols in the call-graph")
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200629091955.17090-4-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Python 3.8 is requiring that arguments being packed as integers are also
    integers. Add int() accordingly.

    Before:

    $ perf record -e intel_pt//u uname
    $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-postgresql.py perf_data_db branches calls
    2020-06-25 16:09:10.547256 Creating database...
    2020-06-25 16:09:10.733185 Writing to intermediate files...
    Traceback (most recent call last):
    File "/home/ahunter/libexec/perf-core/scripts/python/export-to-postgresql.py", line 1106, in synth_data
    cbr(id, raw_buf)
    File "/home/ahunter/libexec/perf-core/scripts/python/export-to-postgresql.py", line 1058, in cbr
    value = struct.pack("!hiqiiiiii", 4, 8, id, 4, cbr, 4, MHz, 4, percent)
    struct.error: required argument is not an integer
    Fatal Python error: problem in Python trace event handler
    Python runtime state: initialized

    Current thread 0x00007f35d3695780 (most recent call first):

    Aborted (core dumped)

    After:

    $ dropdb perf_data_db
    $ rm -rf perf_data_db-perf-data
    $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-postgresql.py perf_data_db branches calls
    2020-06-25 16:09:40.990267 Creating database...
    2020-06-25 16:09:41.207009 Writing to intermediate files...
    2020-06-25 16:09:41.270915 Copying to database...
    2020-06-25 16:09:41.382030 Removing intermediate files...
    2020-06-25 16:09:41.384630 Adding primary keys
    2020-06-25 16:09:41.541894 Adding foreign keys
    2020-06-25 16:09:41.677044 Dropping unused tables
    2020-06-25 16:09:41.703761 Done

    Fixes: aba44287a224 ("perf scripts python: export-to-postgresql.py: Export Intel PT power and ptwrite events")
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200629091955.17090-2-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

23 Jun, 2020

1 commit

  • On some platforms the default encoding is not utf-8, which causes an
    UnicodeDecodeError when reading the flamegraph template and writing the
    flamegraph

    Signed-off-by: Andreas Gerstmayr
    Cc: Alexander Shishkin
    Cc: Jiri Olsa
    Cc: Mark Rutland
    Cc: Michael Petlan
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lore.kernel.org/lkml/20200619153232.203537-1-agerstmayr@redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Andreas Gerstmayr
     

06 May, 2020

1 commit

  • As all the other tools/perf/scripts/python/bin/*-{report,record}
    scripts, fixing the this problem reported by Daniel Diaz:

    Our OpenEmbedded builds detected an issue with 5287f9269206 ("perf
    script: Add flamegraph.py script"):
    ERROR: perf-1.0-r9 do_package_qa: QA Issue:
    /usr/libexec/perf-core/scripts/python/bin/flamegraph-report contained
    in package perf-python requires /usr/bin/sh, but no providers found in
    RDEPENDS_perf-python? [file-rdeps]

    This means that there is a new binary pulled in in the shebang line
    which was unaccounted for: `/usr/bin/sh`. I don't see any other usage
    of /usr/bin/sh in the kernel tree (does not even exist on my Ubuntu
    dev machine) but plenty of /bin/sh. This patch is needed:
    -----88---------->8---------->8-----

    Fixes: 5287f9269206 ("perf script: Add flamegraph.py script")
    Reported-by: Daniel Díaz
    Acked-by: Andreas Gerstmayr
    Cc: Adrian Hunter
    Cc: Jiri Olsa
    Cc: lkft-triage@lists.linaro.org
    Cc: Namhyung Kim
    Link: http://lore.kernel.org/lkml/CAEUSe7_wmKS361mKLTB1eYbzYXcKkXdU26BX5BojdKRz8MfPCw@mail.gmail.com
    Link: http://lore.kernel.org/lkml/20200505170320.GZ30487@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

16 Apr, 2020

1 commit

  • This script works in tandem with d3-flame-graph to generate flame graphs
    from perf. It supports two output formats: JSON and HTML (the default).
    The HTML format will look for a standalone d3-flame-graph template file
    in /usr/share/d3-flame-graph/d3-flamegraph-base.html and fill in the
    collected stacks.

    Usage:

    perf record -a -g -F 99 sleep 60
    perf script report flamegraph

    Combined:

    perf script flamegraph -a -F 99 sleep 60

    Committer testing:

    Tested both with "PYTHON=python3" and with the default, that uses
    python2-devel:

    Complete set of instructions:

    $ mkdir /tmp/build/perf
    $ make PYTHON=python3 -C tools/perf O=/tmp/build/perf install-bin
    $ export PATH=~/bin:$PATH
    $ perf record -a -g -F 99 sleep 60
    $ perf script report flamegraph

    Now go and open the generated flamegraph.html file in a browser.

    At first this required building with PYTHON=python3, but after I
    reported this Andreas was kind enough to send a patch making it work
    with both python and python3.

    Signed-off-by: Andreas Gerstmayr
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: Jiri Olsa
    Cc: Mark Rutland
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Brendan Gregg
    Cc: Martin Spier
    Link: http://lore.kernel.org/lkml/20200320151355.66302-1-agerstmayr@redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Andreas Gerstmayr
     

11 Mar, 2020

1 commit

  • Since common_callchain has been added to the argument array, we need to
    reflect it in perl-based scripts, because otherwise the following args
    would be shifted and thus incorrect. E.g. rw-by-pid and calculation of
    read and written bytes:

    Before:

    read counts by pid:
    pid comm # reads bytes_requested bytes_read
    ------ -------------------- ----------- ---------- ----------
    19301 dd 4 424510450039736 0

    After:

    read counts by pid:
    pid comm # reads bytes_requested bytes_read
    ------ -------------------- ----------- ---------- ----------
    19301 dd 4 9536 4341

    Committer testing:

    To see before after first do:

    # perf script record rw-by-pid
    ^C

    Now you'll have a perf.data file to report on, then do before and after
    using:

    # perf script report rw-by-pid

    Anbd notice the bytes_request/bytes_read, as above.

    Signed-off-by: Michael Petlan
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Benjamin Salon
    Cc: Jiri Olsa
    LPU-Reference: 20200311132836.12693-1-mpetlan@redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Michael Petlan
     

13 Nov, 2019

1 commit

  • Prior to version 3.23 SQLite does not support TRUE or FALSE, so always
    use 1 and 0 for SQLite.

    Fixes: 26c11206f433 ("perf scripts python: exported-sql-viewer.py: Use new 'has_calls' column")
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: stable@vger.kernel.org # v5.3+
    Link: http://lore.kernel.org/lkml/20191113120206.26957-1-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

07 Oct, 2019

6 commits


30 Aug, 2019

1 commit


11 Jul, 2019

1 commit

  • Export switch events to a new table 'context_switches' and create a view
    'context_switches_view'. The table and view will show automatically in the
    exported-sql-viewer.py script.

    If the table ends up empty, then it and the view are dropped.

    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190710085810.1650-22-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

10 Jul, 2019

7 commits

  • Export switch events to a new table 'context_switches' and create a view
    'context_switches_view'. The table and view will show automatically in
    the exported-sql-viewer.py script.

    If the table ends up empty, then it and the view are dropped.

    Committer testing:

    Use the exported-sql-viewer.py and look at "Tables" ->
    "context_switches":

    id machine_id time cpu thread_out_id comm_out_id thread_in_id comm_in_id flags
    1 1 187836111885918 7 1 1 2 2 3
    2 1 187836111889369 7 1 1 2 2 0
    3 1 187836112464618 7 2 3 1 1 1
    4 1 187836112465511 7 2 3 1 1 0

    Signed-off-by: Adrian Hunter
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190710085810.1650-21-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • If the new 'has_calls' column is present, use it with the call graph and
    call tree to select only comms that have calls.

    Committer testing:

    Just started the exported-sql-view.py and accessed all the reports, no
    backtraces.

    Signed-off-by: Adrian Hunter
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190710085810.1650-17-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Remove redundant semi-colons added inadvertently.

    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190710085810.1650-16-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Now that a thread's current comm is exported, it shows up in the call graph
    and call tree even if it has no calls. That can happen because the calls
    are recorded against the main thread's initial comm.

    Add a table column to make it easy for the exported-sql-viewer.py script to
    select only comms with calls.

    Committer testing:

    $ rm -f simple-retpoline.db
    $ sudo ~acme/bin/perf script -i simple-retpoline.perf.data --itrace=be -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py simple-retpoline.db branches calls
    2019-07-10 12:25:33.200529 Creating database ...
    2019-07-10 12:25:33.211548 Writing records...
    2019-07-10 12:25:33.549630 Adding indexes
    2019-07-10 12:25:33.560715 Dropping unused tables
    2019-07-10 12:25:33.580201 Done
    $ sha256sum tools/perf/scripts/python/export-to-sqlite.py ~/libexec/perf-core/scripts/python/export-to-sqlite.py
    2922b642c392004dffa1d8789296478c85904623f5895bcb9b6cbf33e3ca999f tools/perf/scripts/python/export-to-sqlite.py
    2922b642c392004dffa1d8789296478c85904623f5895bcb9b6cbf33e3ca999f /home/acme/libexec/perf-core/scripts/python/export-to-sqlite.py
    $
    $ sqlite3 simple-retpoline.db
    SQLite version 3.26.0 2018-12-01 12:34:55
    Enter ".help" for usage hints.
    sqlite> .schema comms
    CREATE TABLE comms (id integer NOT NULL PRIMARY KEY,comm varchar(16),c_thread_id bigint,c_time bigint,exec_flag boolean, has_calls boolean);
    sqlite> select id,has_calls from comms;
    0|1
    1|1
    sqlite> select distinct comm_id from calls;
    0
    1
    sqlite>

    Signed-off-by: Adrian Hunter
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190710085810.1650-15-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Now that a thread's current comm is exported, it shows up in the call
    graph and call tree even if it has no calls. That can happen because the
    calls are recorded against the main thread's initial comm.

    Add a table column to make it easy for the exported-sql-viewer.py script
    to select only comms with calls.

    Committer notes:

    Running the export-to-sqlite.py worked without warnings and using the
    exported-sql-viewer.py worked as before.

    Signed-off-by: Adrian Hunter
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190710085810.1650-14-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Add table columns for thread id, comm start time and exec flag.

    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190710085810.1650-11-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Add table columns for thread id, comm start time and exec flag.

    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190710085810.1650-10-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

09 Jul, 2019

2 commits

  • Drop power_events_view before its dependent tables.

    SQLite does not seem to mind but the fix was needed for PostgreSQL
    (export-to-postgresql.py script), so do the same fix for the SQLite. It is
    more logical and keeps the 2 scripts following the same approach.

    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Fixes: 5130c6e55531 ("perf scripts python: export-to-sqlite.py: Export Intel PT power and ptwrite events")
    Link: http://lkml.kernel.org/r/20190708055232.5032-3-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • PostgreSQL can error if power_events_view is not dropped before its
    dependent tables e.g.

    Exception: Query failed: ERROR: cannot drop table mwait because other
    objects depend on it
    DETAIL: view power_events_view depends on table mwait

    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Fixes: aba44287a224 ("perf scripts python: export-to-postgresql.py: Export Intel PT power and ptwrite events")
    Link: http://lkml.kernel.org/r/20190708055232.5032-2-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

25 Jun, 2019

2 commits

  • 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
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190622093248.581-8-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • 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
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190622093248.581-7-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

05 Jun, 2019

7 commits

  • The user probably wants to replace the find text, so select the find
    text when the find bar is activated.

    That is fairly standard behaviour for search text entry.

    Entering text will replace the current text, but using edit keys
    (arrows, home, end etc) cancels the selection and enables editing.

    Signed-off-by: Adrian Hunter
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190520113728.14389-23-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Enhance the call tree to display IPC information if it is available.

    Committer testing:

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

    Reports -> Call Tree, then expand a few trees, then select with the
    mouse and press control+C (copy):

    Call Path Object Call Time Time Time(%) Insn Insn Cyc Cyc IPC Branch Branch
    ▼ simple-retpolin (ns) Cnt Cnt(%) Cnt Cnt(%) Count Count(%)
    ▼ 23003:23003
    ▼ _start ld-2.28.so 112195670 218295 100.0 127746 100.0 207320 100.0 0.62 13046 100.0
    ▶ unknown unknown 112195987 3202 1.5 0 0.0 0 0.0 0 1 0.0
    ▶ _dl_start ld-2.28.so 112199189 188471 86.3 123394 96.6 180007 86.8 0.69 12529 96.0
    ▼ _dl_init ld-2.28.so 112387660 13406 6.1 3207 2.5 14868 7.2 0.22 327 2.5
    ▶ call_init.part.0 ld-2.28.so 112387773 117 0.9 70 2.2 639 4.3 0.11 3 0.9
    ▶ call_init.part.0 ld-2.28.so 112387890 13129 97.9 3103 96.8 14100 94.8 0.22 315 96.3
    ▶ call_init.part.0 ld-2.28.so 112401020 0 0.0 0 0.0 0 0.0 0 2 0.6
    ▼ _start simple-retpol 112401066 12899 5.9 1142 0.9 11561 5.6 0.10 184 1.4
    ▶ unknown unknown 112401388 846 6.6 0 0.0 0 0.0 0 1 0.5
    ▼ __libc_start_main libc-2.28.so 112402344 11621 90.1 1129 98.9 10350 89.5 0.11 181 98.4
    ▶ __cxa_atexit libc-2.28.so 112402360 2302 19.8 101 8.9 1817 17.6 0.06 13 7.2
    ▶ __libc_csu_init simple-retpol 112404673 121 1.0 43 3.8 340 3.3 0.13 8 4.4
    ▶ _setjmp libc-2.28.so 112404794 74 0.6 46 4.1 206 2.0 0.22 4 2.2
    ▼ main simple-retpol 112404892 44 0.4 23 2.0 126 1.2 0.18 12 6.6
    ▼ foo simple-retpol 112404892 19 43.2 12 52.2 55 43.7 0.22 5 41.7
    bar simple-retpol 112404896 12 63.2 3 25.0 34 61.8 0.09 1 20.0
    ▼ foo simple-retpol 112404911 25 56.8 11 47.8 71 56.3 0.15 5 41.7
    ▶ bar simple-retpol 112404924 10 40.0 3 27.3 27 38.0 0.11 1 20.0
    ▶ exit libc-2.28.so 112404936 9029 77.7 878 77.8 7765 75.0 0.11 139 76.8

    Signed-off-by: Adrian Hunter
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190520113728.14389-22-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Enhance the call graph to display IPC information if it is available.

    Committer testing:

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

    Reports -> Context Sensitive Callgraph, then expand a few trees, then
    select with the mouse and press control+C:

    Call Path Object Count Time(ns) Time(%) Insn Insn Cyc Cyc IPC Branch Branch
    ▼ simple-retpolin Cnt Cnt(%) Cnt Cnt(%) Cnt Cnt(%)
    ▼ 23003:23003
    ▼ _start ld-2.28.so 1 218295 100.0 127746 100.0 207320 100.0 0.62 13046 100.0
    ▶ unknown unknown 1 3202 1.5 0 0.0 0 0.0 0 1 0.0
    ▶ _dl_start ld-2.28.so 1 188471 86.3 123394 96.6 180007 86.8 0.69 12529 96.0
    ▶ _dl_init ld-2.28.so 1 13406 6.1 3207 2.5 14868 7.2 0.22 327 2.5
    ▼ _start simple-retpoline 1 12899 5.9 1142 0.9 11561 5.6 0.10 184 1.4
    ▶ unknown unknown 1 846 6.6 0 0.0 0 0.0 0 1 0.5
    ▼ __libc_start_main libc-2.28.so 1 11621 90.1 1129 98.9 10350 89.5 0.11 181 98.4
    ▶ __cxa_atexit libc-2.28.so 1 2302 19.8 101 8.9 1817 17.6 0.06 13 7.2
    ▶ __libc_csu_init simple-retpoline 1 121 1.0 43 3.8 340 3.3 0.13 8 4.4
    ▼ _setjmp libc-2.28.so 1 74 0.6 46 4.1 206 2.0 0.22 4 2.2
    ▼ __sigsetjmp libc-2.28.so 1 74 100.0 46 100.0 206 100.0 0.22 3 75.0
    ▶ __sigjmp_save libc-2.28.so 1 0 0.0 0 0.0 0 0.0 0 1 33.3
    ▼ main simple-retpoline 1 44 0.4 23 2.0 126 1.2 0.18 12 6.6
    ▼ foo simple-retpoline 2 44 100.0 23 100.0 126 100.0 0.18 10 83.3
    bar simple-retpoline 2 22 50.0 6 26.1 61 48.4 0.10 2 20.0
    ▶ exit libc-2.28.so 1 9029 77.7 878 77.8 7765 75.0 0.11 139 76.8

    Signed-off-by: Adrian Hunter
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190520113728.14389-21-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Add a parameter to call graph and call tree, to determine whether IPC
    information is available.

    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190520113728.14389-20-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Enhance the "All branches" and "Selected branches" reports to display IPC
    information if it is available.

    Committer testing:

    So, testing this I noticed that it all starts with the left arrow in every
    line, that should mean there is some tree there, i.e. look at all those ▶
    symbols:

    Reports -> All Branches:

    Time CPU Command PID TID Branch Type In Tx Insn Cnt Cyc Cnt IPC Branch
    ▶ 187836112195670 7 simple-retpolin 23003 23003 trace begin No 0 0 0 0 unknown (unknown) -> 7f6f33d4f110
    +_start (ld-2.28.so)
    ▶ 187836112195987 7 simple-retpolin 23003 23003 trace end No 0 883 0 7f6f33d4f110 _start (ld-2.28.so) -> 0 unknown
    +(unknown)
    ▶ 187836112199189 7 simple-retpolin 23003 23003 trace begin No 0 0 0 0 unknown (unknown) -> 7f6f33d4f110
    +_start (ld-2.28.so)
    ▶ 187836112199189 7 simple-retpolin 23003 23003 call No 0 0 0 7f6f33d4f113 _start+0x3 (ld-2.28.so) -> 7f6f33d4ff50
    +_dl_start (ld-2.28.so)
    ▶ 187836112199544 7 simple-retpolin 23003 23003 trace end No 17 996 0.02 7f6f33d4ff73 _dl_start+0x23 (ld-2.28.so) -> 0
    +unknown (unknown)
    ▶ 187836112200939 7 simple-retpolin 23003 23003 trace begin No 0 0 0 0 unknown (unknown) -> 7f6f33d4ff73
    +_dl_start+0x23 (ld-2.28.so)
    ▶ 187836112201229 7 simple-retpolin 23003 23003 trace end No 1 816 0.00 7f6f33d4ff7a _dl_start+0x2a (ld-2.28.so) -> 0
    +unknown (unknown)
    ▶ 187836112203500 7 simple-retpolin 23003 23003 trace begin No 0 0 0 0 unknown (unknown) -> 7f6f33d4ff7a
    +_dl_start+0x2a (ld-2.28.so)

    But if you click on it, that ▶ disappears and a new click doesn't make
    it reappear, looks buggy, minor oddity, reported to Adrian.

    Reports -> Selected Branches, then ask for branches in the ld-2.28.so
    DSO:

    Time CPU Command PID TID Branch Type In Tx Insn Cnt Cyc Cnt IPC Branch
    ▶ 187836112195987 7 simple-retpolin 23003 23003 trace end No 0 883 0 7f6f33d4f110 _start (ld-2.28.so) -> 0 unknown (unknown)
    ▶ 187836112199189 7 simple-retpolin 23003 23003 trace begin No 0 0 0 0 unknown (unknown) -> 7f6f33d4f110 _start (ld-2.28.so)
    ▶ 187836112199189 7 simple-retpolin 23003 23003 call No 0 0 0 7f6f33d4f113 _start+0x3 (ld-2.28.so) -> 7f6f33d4ff50 _dl_start (ld-2.28.so)
    ▶ 187836112199544 7 simple-retpolin 23003 23003 trace end No 17 996 0.02 7f6f33d4ff73 _dl_start+0x23 (ld-2.28.so) -> 0 unknown (unknown)
    ▶ 187836112200939 7 simple-retpolin 23003 23003 trace begin No 0 0 0 0 unknown (unknown) -> 7f6f33d4ff73 _dl_start+0x23 (ld-2.28.so)
    ▶ 187836112201229 7 simple-retpolin 23003 23003 trace end No 1 816 0.00 7f6f33d4ff7a _dl_start+0x2a (ld-2.28.so) -> 0 unknown (unknown)
    ▶ 187836112203500 7 simple-retpolin 23003 23003 trace begin No 0 0 0 0 unknown (unknown) -> 7f6f33d4ff7a _dl_start+0x2a (ld-2.28.so)
    ▶ 187836112203528 7 simple-retpolin 23003 23003 unconditional jump No 0 0 0 7f6f33d4ffe7 _dl_start+0x97 (ld-2.28.so) -> 7f6f33d5000b _dl_start+0xbb (ld-2.28.so)
    ▶ 187836112203528 7 simple-retpolin 23003 23003 conditional jump No 0 0 0 7f6f33d5000f _dl_start+0xbf (ld-2.28.so) -> 7f6f33d4fffb _dl_start+0xab (ld-2.28.so)
    ▶ 187836112203528 7 simple-retpolin 23003 23003 conditional jump No 0 0 0 7f6f33d5000f _dl_start+0xbf (ld-2.28.so) -> 7f6f33d4fffb _dl_start+0xab (ld-2.28.so)
    ▶ 187836112203539 7 simple-retpolin 23003 23003 conditional jump No 0 0 0 7f6f33d50025 _dl_start+0xd5 (ld-2.28.so) -> 7f6f33d50210 _dl_start+0x2c0 (ld-2.28.so)
    ▶ 187836112203539 7 simple-retpolin 23003 23003 conditional jump No 0 0 0 7f6f33d5021a _dl_start+0x2ca (ld-2.28.so) -> 7f6f33d50360 _dl_start+0x410 (ld-2.28.so)
    ▶ 187836112203539 7 simple-retpolin 23003 23003 unconditional jump No 0 0 0 7f6f33d50377 _dl_start+0x427 (ld-2.28.so) -> 7f6f33d4ffff _dl_start+0xaf (ld-2.28.so)
    ▶ 187836112203539 7 simple-retpolin 23003 23003 conditional jump No 0 0 0 7f6f33d5000f _dl_start+0xbf (ld-2.28.so) -> 7f6f33d4fffb _dl_start+0xab (ld-2.28.so)
    ▶ 187836112203562 7 simple-retpolin 23003 23003 conditional jump No 0 0 0 7f6f33d5000f _dl_start+0xbf (ld-2.28.so) -> 7f6f33d4fffb _dl_start+0xab (ld-2.28.so)

    Signed-off-by: Adrian Hunter
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190520113728.14389-19-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Export cycle and instruction counts on samples and calls tables.

    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190520113728.14389-18-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Export cycle and instruction counts on samples and calls tables.

    Committer testing:

    First runs some workload collecting intel_pt with the 'cyc' ter just for
    userspace:

    [root@quaco adrian.hunter]# perf record -o simple-retpoline.perf.data -e intel_pt/cyc/u ./simple-retpoline
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.035 MB simple-retpoline.perf.data ]
    [root@quaco adrian.hunter]#

    Then use the export-to-sqlite.py script to see if the changes in this
    cset don't make it to break and if the changes in the db schema are the
    ones expected:

    [root@quaco adrian.hunter]# perf script -i simple-retpoline.perf.data --itrace=be -s ~acme/libexec/perf-core/scripts/python/export-to-sqlite.py simple-retpoline.db branches calls
    2019-05-31 11:50:46.942710 Creating database ...
    2019-05-31 11:50:46.949663 Writing records...
    2019-05-31 11:50:47.224033 Adding indexes
    2019-05-31 11:50:47.231599 Done
    [root@quaco adrian.hunter]#

    Now lets use the db:

    [root@quaco adrian.hunter]# sqlite3 simple-retpoline.db
    SQLite version 3.26.0 2018-12-01 12:34:55
    Enter ".help" for usage hints.
    sqlite> .schema samples
    CREATE TABLE samples (id integer NOT NULL PRIMARY KEY,evsel_id bigint,machine_id bigint,thread_id bigint,comm_id bigint,dso_id bigint,symbol_id bigint,sym_offset bigint,ip bigint,time bigint,cpuinteger,to_dso_id bigint,to_symbol_id bigint,to_sym_offset bigint,to_ip bigint,branch_type integer,in_tx boolean,call_path_id bigint,insn_count bigint,cyc_count bigint);
    sqlite>

    Cool, the 'insn_count' and 'cyc_count' are there, now lets see if we can
    use them in a query:

    sqlite> select insn_count,cyc_count from samples where cyc_count > 1500 and insn_count < 10;
    6|1507
    sqlite> select insn_count,cyc_count from samples where cyc_count > 1500;
    118|2210
    140|1516
    3783|1861
    132|1521
    6|1507
    sqlite>

    Seems to work :-)

    Signed-off-by: Adrian Hunter
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20190520113728.14389-17-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

03 Jun, 2019

1 commit


31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    licensed under the terms of the gnu gpl license version 2

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 62 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Kate Stewart
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.929121379@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner