Skip to content

Extend support for linux tools perf for jitted code#6925

Closed
sathvikl wants to merge 1 commit into
facebook:masterfrom
sathvikl:master
Closed

Extend support for linux tools perf for jitted code#6925
sathvikl wants to merge 1 commit into
facebook:masterfrom
sathvikl:master

Conversation

@sathvikl

Copy link
Copy Markdown
Contributor

Summary: This patch provides better support for two of the perf tools infra

(a) perf record/report/annotate supported limited profiling of
jitted code. Function/ DSO view worked however assembly profile view
of jitted code was not supported.
With this patch and the latest version of perf tools from
https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/
jitted code profile can be viewed at the assembly level.

It works by generating /tmp/perf-<pid>.dump for perf to read jitted code.

There's two choices for clock source to be used for profiling
(.1) use arch_timestamp; perf tooling requires the env variable
JITDUMP_USE_ARCH_TIMESTAMP=1 to be set.
run perf record
(.2) use MONOTONIC_CLOCK;
run perf record -k 1/mono

 perf inject --jit -i perf.data -o perf.jitted.data
 will inject jit records into perf.data. This will generate an ELF
 file for every trace recorded in perf-<pid>.dump. "PERF_RECORD_MMAP2"
 entry in inserted into perf.data for each one of these ELF files
 created in /tmp.
 By default they will be in /tmp unless specified via
 env variable JITDUMPDIR.

perf report -i perf.jitted.data will generate the results.

The patch defaults to using arch_timestamp unless
env variable is set to JITDUMP_USE_ARCH_TIMESTAMP=0

(b) It extends support for jitted code for
perf event "intel_pt//" ;PT processor trace recording.
perf record -e intel_pt//u -p
perf inject --jit -i perf.data -o perf.jitted.data
perf script --itrace=i0ns -F.. -i perf.jitted.data
will produce a trace of the workload.

This requires 4.1+ version of kernel and the latest version of perf.
--itrace option of 0ns is supported only in the latest version.

The env var JITDUMP_USE_ARCH_TIMESTAMP=1 must be set and is used by the
linux perf tools infra.

Summary: This patch provides better support for two of the perf tools infra

(a) perf record/report/annotate supported limited profiling of
    jitted code. Function/ DSO view worked however assembly profile view
    of jitted code was not supported.
    With this patch and the latest version of perf tools from
    https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/
    jitted code profile can be viewed at the assembly level.

    It works by generating /tmp/perf-<pid>.dump for perf to read jitted code.
There's two choices for clock source to be used for profiling
(.1) use arch_timestamp; perf tooling requires the env variable
     JITDUMP_USE_ARCH_TIMESTAMP=1 to be set.
     run perf record
(.2) use MONOTONIC_CLOCK;
     run perf record -k 1/mono

     perf inject --jit -i perf.data -o perf.jitted.data
     will inject jit records into perf.data. This will generate an ELF
     file for every trace recorded in perf-<pid>.dump. "PERF_RECORD_MMAP2"
     entry in inserted into perf.data for each one of these ELF files
     created in /tmp.
     By default they will be in /tmp unless specified via
     env variable JITDUMPDIR.

perf report -i perf.jitted.data will generate the results.

The patch defaults to using arch_timestamp unless
env variable is set to JITDUMP_USE_ARCH_TIMESTAMP=0

(b) It extends support for jitted code for
    perf event "intel_pt//" ;PT processor trace recording.
    perf record -e intel_pt//u -p <pid>
    perf inject --jit -i perf.data -o perf.jitted.data
    perf script --itrace=i0ns -F.. -i perf.jitted.data
    will produce a trace of the workload.

This requires 4.1+ version of kernel and the latest version of perf.
 --itrace option of 0ns is supported only in the latest version.

The env var JITDUMP_USE_ARCH_TIMESTAMP=1 must be set and is used by the
linux perf tools infra.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants