Merge tag 'perf-core-for-mingo-3' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull new perf tool feature from Arnaldo Carvalho de Melo:

" User visible changes:

  - Generate perf.data files from 'perf stat', to tap into the scripting
    capabilities perf has instead of defining a 'perf stat' specific scripting
    support to calculate event ratios, etc. Simple example:

    $ perf stat record -e cycles usleep 1

     Performance counter stats for 'usleep 1':

           1,134,996      cycles

         0.000670644 seconds time elapsed

    $ perf stat report

     Performance counter stats for '/home/acme/bin/perf stat record -e cycles usleep 1':

           1,134,996      cycles

         0.000670644 seconds time elapsed

    $

    It generates PERF_RECORD_ userspace records to store the details:

    $ perf report -D | grep PERF_RECORD
    0xf0 [0x28]: PERF_RECORD_THREAD_MAP nr: 1 thread: 27637
    0x118 [0x12]: PERF_RECORD_CPU_MAP nr: 1 cpu: 65535
    0x12a [0x40]: PERF_RECORD_STAT_CONFIG
    0x16a [0x30]: PERF_RECORD_STAT
    -1 -1 0x19a [0x40]: PERF_RECORD_MMAP -1/0: [0xffffffff81000000(0x1f000000) @ 0xffffffff81000000]: x [kernel.kallsyms]_text
    0x1da [0x18]: PERF_RECORD_STAT_ROUND
    [acme@ssdandy linux]$

    An effort was made to make perf.data files generated like this to not
    generate cryptic messages when processed by older tools.

    The 'perf script' bits need rebasing, will go up later.

  Jiri's cover letter for this series:

  The initial attempt defined its own formula lang and allowed triggering user's
  script on the end of the stat command:

    http://marc.info/?l=linux-kernel&m=136742146322273&w=2

  This patchset abandons the idea of new formula language and rather adds support
  to:

    - store stat data into perf.data file
    - add python support to process stat events

  Basically it allows to store stat data into perf.data and post process it with
  python scripts in a similar way we do for sampling data.

  The stat data are stored in new stat, stat-round, stat-config user events.
    stat        - stored for each read syscall of the counter
    stat round  - stored for each interval or end of the command invocation
    stat config - stores all the config information needed to process data
                  so report tool could restore the same output as record

  The python script can now define 'stat__<eventname>_<modifier>' functions
  to get stat events data and 'stat__interval' to get stat-round data.

  See CPI script example in scripts/python/stat-cpi.py."

Also a few other changes:

User visible changes:

  - Make command line options always available, even when they
    depend on some feature being enabled, warning the user about
    use of such options (Wang Nan)

  - Support --vmlinux in perf record, useful, so far, for eBPF,
    where we will set up events that will be used in the record
    session (He Kuang)

  - Automatically disable collecting branch flags and cycles with
    --call-graph lbr. This allows avoiding a bunch of extra MSR
    reads in the PMI on Skylake.  (Andi Kleen)

Infrastructure changes:

  - Dump the stack when a 'perf test -v ' entry segfaults, so far we
    would have to run it under gdb with 'set follow-fork-mode child'
    set to get a proper backtrace (Arnaldo Carvalho de Melo)

  - Initialize the refcnt in 'struct thread' to 1 and fixup its
    users accordingly, so that we try to have the same refcount
    model accross the perf codebase (Arnaldo Carvalho de Melo)

  - More prep work for moving the subcmd infrastructure out of
    tools/perf/ and into tools/lib/subcmd/ to be used by other
    tools/ living utilities (Josh Poimboeuf)

  - Fix 'perf test' hist testcases when kptr_restrict is on (Namhyung Kim)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>