06 Dec, 2015

9 commits

  • For debugging low level code interacting with the CPU it is often
    useful to trace the MSR read/writes. This gives a concise summary of
    PMU and other operations.

    perf has an ad-hoc way to do this using trace_printk, but it's
    somewhat limited (and also now spews ugly boot messages when enabled)

    Instead define real trace points for all MSR accesses.

    This adds three new trace points: read_msr and write_msr and rdpmc.

    They also report if the access faulted (if *_safe is used)

    This allows filtering and triggering on specific MSR values, which
    allows various more advanced debugging techniques.

    All the values are well defined in the CPU documentation.

    The trace can be post processed with
    Documentation/trace/postprocess/decode_msr.py to add symbolic MSR
    names to the trace.

    I only added it to native MSR accesses in C, not paravirtualized or in
    entry*.S (which is not too interesting)

    Originally the patch kit moved the MSRs out of line. This uses an
    alternative approach recommended by Steven Rostedt of only moving the
    trace calls out of line, but open coding the access to the jump label.

    Signed-off-by: Andi Kleen
    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Steven Rostedt
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Link: http://lkml.kernel.org/r/1449018060-1742-3-git-send-email-andi@firstfloor.org
    Signed-off-by: Ingo Molnar

    Andi Kleen
     
  • Steven recommended open coding access to tracepoint->key to add
    trace points to headers. Unfortunately this is difficult for some
    headers (such as x86 asm/msr.h) because including tracepoint.h
    includes so many other headers that it causes include loops.
    The main problem is the include of linux/rcupdate.h, which
    pulls in a lot of other headers. The rcu header is only needed
    when actually defining trace points.

    Move the struct tracepoint into a separate tracepoint-defs.h
    header that can be included without pulling in all of RCU.

    Signed-off-by: Andi Kleen
    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Steven Rostedt
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Link: http://lkml.kernel.org/r/1449018060-1742-2-git-send-email-andi@firstfloor.org
    Signed-off-by: Ingo Molnar

    Andi Kleen
     
  • asm/atomic.h doesn't really need asm/processor.h anymore. Everything
    it uses has moved to other header files. So remove that include.

    processor.h is a nasty header that includes lots of
    other headers and makes it prone to include loops. Removing the
    include here makes asm/atomic.h a "leaf" header that can
    be safely included in most other headers.

    The only fallout is in the lib/atomic tester which relied on
    this implicit include. Give it an explicit include.
    (the include is in ifdef because the user is also in ifdef)

    Signed-off-by: Andi Kleen
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Cc: rostedt@goodmis.org
    Link: http://lkml.kernel.org/r/1449018060-1742-1-git-send-email-andi@firstfloor.org
    Signed-off-by: Ingo Molnar

    Andi Kleen
     
  • Fix a definition in the perf rapl driver. __initconst must
    be applied to a const object, but to declare a const pointer
    you need to use * const ..., not const ... *

    This fixes a section attribute conflict with LTO builds.

    Signed-off-by: Andi Kleen
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Link: http://lkml.kernel.org/r/1448905722-2767-1-git-send-email-andi@firstfloor.org
    Signed-off-by: Ingo Molnar

    Andi Kleen
     
  • Various functions implement the same pattern to send IPIs to an
    event's CPU. Collapse the easy ones in a common helper function to
    reduce duplication.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • In case we monitor events system wide, we get EXIT event
    (when configured) twice for each task that exited.

    Note doubled lines with same pid/tid in following example:

    $ sudo ./perf record -a
    ^C[ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.480 MB perf.data (2518 samples) ]
    $ sudo ./perf report -D | grep EXIT

    0 60290687567581 0x59910 [0x38]: PERF_RECORD_EXIT(1250:1250):(1250:1250)
    0 60290687568354 0x59948 [0x38]: PERF_RECORD_EXIT(1250:1250):(1250:1250)
    0 60290687988744 0x59ad8 [0x38]: PERF_RECORD_EXIT(1250:1250):(1250:1250)
    0 60290687989198 0x59b10 [0x38]: PERF_RECORD_EXIT(1250:1250):(1250:1250)
    1 60290692567895 0x62af0 [0x38]: PERF_RECORD_EXIT(1253:1253):(1253:1253)
    1 60290692568322 0x62b28 [0x38]: PERF_RECORD_EXIT(1253:1253):(1253:1253)
    2 60290692739276 0x69a18 [0x38]: PERF_RECORD_EXIT(1252:1252):(1252:1252)
    2 60290692739910 0x69a50 [0x38]: PERF_RECORD_EXIT(1252:1252):(1252:1252)

    The reason is that the cpu contexts are processes each time
    we call perf_event_task. I'm changing the perf_event_aux logic
    to serve task_ctx and cpu contexts separately, which ensure we
    don't get EXIT event generated twice on same cpu context.

    This does not affect other auxiliary events, as they don't
    use task_ctx at all.

    Signed-off-by: Jiri Olsa
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Link: http://lkml.kernel.org/r/1446649205-5822-1-git-send-email-jolsa@kernel.org
    Signed-off-by: Ingo Molnar

    Jiri Olsa
     
  • We need to add rest of the flags to the constraint mask
    instead of another INTEL_ARCH_EVENT_MASK, fixing a typo.

    Signed-off-by: Jiri Olsa
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Link: http://lkml.kernel.org/r/1447061071-28085-1-git-send-email-jolsa@kernel.org
    Signed-off-by: Ingo Molnar

    Jiri Olsa
     
  • There was a mistake in the Haswell constraints table.

    Signed-off-by: Yuanfang Chen
    Signed-off-by: Peter Zijlstra (Intel)
    Reviewed-by: Andi Kleen
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Link: http://lkml.kernel.org/r/1448384701-9110-1-git-send-email-cheny@udel.edu
    Signed-off-by: Ingo Molnar

    Yuanfang Chen
     

04 Dec, 2015

1 commit

  • Dmitry reported a fairly silly recursive lock deadlock for
    PERF_EVENT_IOC_PERIOD, fix this by explicitly doing the inactive part of
    __perf_event_period() instead of calling that function.

    Reported-by: Dmitry Vyukov
    Signed-off-by: Peter Zijlstra (Intel)
    Cc:
    Cc: Alexander Potapenko
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Eric Dumazet
    Cc: Jiri Olsa
    Cc: Kostya Serebryany
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Sasha Levin
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Fixes: c7999c6f3fed ("perf: Fix PERF_EVENT_IOC_PERIOD migration race")
    Link: http://lkml.kernel.org/r/20151130115615.GJ17308@twins.programming.kicks-ass.net
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

28 Nov, 2015

10 commits

  • …/acme/linux into perf/core

    Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

    User visible changes:

    - Fix 'perf list' segfault due to lack of support for PERF_CONF_SW_BPF_OUTPUT
    in an array used just for printing available events, robustify the code
    involved (Arnaldo Carvalho de Melo)

    - 'perf test unwind' should create kernel maps, now that entry works and the
    test passes (Jiri Olsa)

    - Fix showing the running kernel build id in 'perf buildid-list' (Michael Petlan)

    - Fix command line symbol filtering in 'perf report' (Namhyung Kim)

    Infrastructure changes:

    - Extract and collect map info from BPF object files in libbpf (Wang Nan)

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

    Ingo Molnar
     
  • Following patches are going to introduce BPF object level configuration
    to enable setting values into BPF maps. To avoid confusion, this patch
    renames existing 'config' in bpf-loader.c to 'program config'. Following
    patches would introduce 'object config'.

    Signed-off-by: Wang Nan
    Cc: Alexei Starovoitov
    Cc: Masami Hiramatsu
    Cc: Namhyung Kim
    Cc: Zefan Li
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1448614067-197576-4-git-send-email-wangnan0@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     
  • This patch collects name of maps in BPF object files and saves them into
    'maps' field in 'struct bpf_object'. 'bpf_object__get_map_by_name' is
    introduced to retrive fd and definitions of a map through its name.

    Signed-off-by: He Kuang
    Cc: Alexei Starovoitov
    Cc: He Kuang
    Cc: Masami Hiramatsu
    Cc: Namhyung Kim
    Cc: Zefan Li
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1448614067-197576-3-git-send-email-wangnan0@huawei.com
    Signed-off-by: Wang Nan
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     
  • This patch collects more information from maps sections in BPF object
    files into 'struct bpf_object', enables later patches access those
    information (such as the type and size of the map).

    In this patch, a new handler 'struct bpf_map' is extracted in parallel
    with bpf_object and bpf_program. Its iterator and accessor is also
    created.

    Signed-off-by: Wang Nan
    Cc: Alexei Starovoitov
    Cc: Masami Hiramatsu
    Cc: Namhyung Kim
    Cc: Zefan Li
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1448614067-197576-2-git-send-email-wangnan0@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     
  • When perf report on TUI was called with -S symbol filter, it should
    update nr entries even if min_pcnt is 0. IIRC the reason was to update
    nr entries after applying minimum percent threshold. But if symbol
    filter was given on command line (with -S option), it should use
    hists->nr_non_filtered_entries instead of hists->nr_entries.

    So this patch fixes a bug of navigating hists browser that the cursor
    goes beyond the number of entries when -S (or similar) option is used.

    Signed-off-by: Namhyung Kim
    Tested-by: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1448645559-31167-3-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • If user gives a filter, perf marks the corresponding column elided and
    omits the output. But it should process and aggregates samples using
    the field, otherwise samples will be aggregated as if the column was not
    there resulted in incorrect output.

    For example, I'd like to set a filter on native_write_msr_safe. The
    original overhead of the function is negligible.

    $ perf report | grep native_write_msr_safe
    0.00% swapper [kernel.vmlinux] native_write_msr_safe
    0.00% perf [kernel.vmlinux] native_write_msr_safe

    However adding -S option gives different output.

    $ perf report -S native_write_msr_safe --percentage absolute | \
    > grep -e swapper -e perf
    51.47% swapper [kernel.vmlinux]
    4.14% perf [kernel.vmlinux]

    Since it aggregated samples using comm and dso only. In fact, the above
    values are same when it sorts with -s comm,dso.

    $ perf report -s comm,dso | grep -e swapper -e perf
    51.47% swapper [kernel.vmlinux]
    4.14% perf [kernel.vmlinux]

    This resulted in TUI failure with -ERANGE since it tries to increase
    sample hit count for annotation with wrong symbols due to incorrect
    aggregation.

    This patch fixes it not to skip elided fields when comparing samples in
    order to insert them to the hists.

    Commiter note:

    After the patch, with a different workloads:

    # perf report --show-total-period -S native_write_msr_safe --stdio
    #
    # symbol: native_write_msr_safe
    #
    # Samples: 455 of event 'cycles:pp'
    # Event count (approx.): 134787489
    #
    # Overhead Period Command Shared Object
    # ........ ...... ............... ................
    #
    0.22% 293081 qemu-system-x86 [vmlinux]
    0.19% 255914 swapper [vmlinux]
    0.00% 2054 Timer [vmlinux]
    0.00% 1021 firefox [vmlinux]
    0.00% 2 perf [vmlinux]

    # perf report --show-total-period | grep native_write_msr_safe
    Failed to open /tmp/perf-14838.map, continuing without symbols
    0.22% 293081 qemu-system-x86 [vmlinux] [k] native_write_msr_safe
    0.19% 255914 swapper [vmlinux] [k] native_write_msr_safe
    0.00% 2054 Timer [vmlinux] [k] native_write_msr_safe
    0.00% 1021 firefox [vmlinux] [k] native_write_msr_safe
    0.00% 2 perf [vmlinux] [k] native_write_msr_safe
    #

    Reported-by: Ingo Molnar
    Signed-off-by: Namhyung Kim
    Tested-by: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1448645559-31167-2-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • Currently when perf fails to process samples for some reason, it doesn't
    show any message about the failure. This is very inconvenient for users
    especially on TUI as screen is reset after the failure.

    Reported-by: Ingo Molnar
    Signed-off-by: Namhyung Kim
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1448645559-31167-1-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • When a43eec304259 ("bpf: introduce bpf_perf_event_output() helper") added
    PERF_COUNT_SW_BPF_OUTPUT we ended up with a new entry in the event_symbols_sw
    array that wasn't initialized, thus set to NULL, fix print_symbol_events()
    to check for that case so that we don't crash if this happens again.

    (gdb) bt
    #0 __match_glob (ignore_space=false, pat=, str=) at util/string.c:198
    #1 strglobmatch (str=, pat=pat@entry=0x7fffffffe61d "stall") at util/string.c:252
    #2 0x00000000004993a5 in print_symbol_events (type=1, syms=0x872880 , max=11, name_only=false, event_glob=0x7fffffffe61d "stall")
    at util/parse-events.c:1615
    #3 print_events (event_glob=event_glob@entry=0x7fffffffe61d "stall", name_only=false) at util/parse-events.c:1675
    #4 0x000000000042c79e in cmd_list (argc=1, argv=0x7fffffffe390, prefix=) at builtin-list.c:68
    #5 0x00000000004788a5 in run_builtin (p=p@entry=0x871758 , argc=argc@entry=2, argv=argv@entry=0x7fffffffe390) at perf.c:370
    #6 0x0000000000420ab0 in handle_internal_command (argv=0x7fffffffe390, argc=2) at perf.c:429
    #7 run_argv (argv=0x7fffffffe110, argcp=0x7fffffffe11c) at perf.c:473
    #8 main (argc=2, argv=0x7fffffffe390) at perf.c:588
    (gdb) p event_symbols_sw[PERF_COUNT_SW_BPF_OUTPUT]
    $4 = {symbol = 0x0, alias = 0x0}
    (gdb)

    A patch to robustify perf to not segfault when the next counter gets added in
    the kernel will follow this one.

    Reported-by: Ingo Molnar
    Cc: Adrian Hunter
    Cc: Alexei Starovoitov
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-57wysblcjfrseb0zg5u7ek10@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • When PERF_COUNT_SW_BPF_OUTPUT was added to the kernel we should've
    added it to tools/perf, where it is used just to list events.

    This ended up causing a segfault in commands like "perf list stall".

    Fix it by adding that new software counter.

    A patch to robustify perf to not segfault when the next counter gets
    added in the kernel will follow this one.

    Reported-by: Ingo Molnar
    Cc: Adrian Hunter
    Cc: Alexei Starovoitov
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-uya354upi3eprsey6mi5962d@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • The 'perf test unwind' is failing because it forgot to create the kernel
    maps, fix it.

    After the patch:

    # perf test unwind
    40: Test dwarf unwind : Ok

    Reported-and-Tested-by: Arnaldo Carvalho de Melo
    Signed-off-by: Jiri Olsa
    Cc: David Ahern
    Cc: Masami Hiramatsu
    Cc: Namhyung Kim
    Link: http://lkml.kernel.org/r/20151127082121.GA24503@krava.brq.redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     

27 Nov, 2015

15 commits

  • The --kernel option of perf buildid-list tool should show the running
    kernel buildid. The functionality has been lost during other changes of
    the related code.

    The build_id__sprintf() function should return length of the build-id
    string, but it was the length of the build-id raw data instead. Due to
    that, some return value checking caused that the final string was not
    printed out.

    With this patch the build_id__sprintf() returns the correct value, so
    the --kernel option works again.

    Before:

    # perf buildid-list --kernel
    #

    After:

    # perf buildid-list --kernel
    972c1edab5bdc06cc224af45d510af662a3c6972
    #

    Signed-off-by: Michael Petlan
    Cc: Jiri Olsa
    Cc: Masami Hiramatsu
    LPU-Reference: 1448632089.24573.114.camel@redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Michael Petlan
     
  • …/acme/linux into perf/core

    Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

    User visible changes:

    - Add 'vmlinux.debug' to the vmlinux search path (Ekaterina Tumanova)

    - Do not show sample_(type|period) in the perf_event_attr dump when using
    -v with 'perf stat' (Jiri Olsa)

    - Display the WEIGHT sample bit, when set, in 'perf evlist -v' (Jiri Olsa)

    - Honour --hide-unresolved in 'report', will honour it as well in 'top'
    when --hide-unresolved gets supported in that tool (Namhyung Kim)

    - Fix freeze wit h--call-graph 'flat/folded' due to not properly
    reinitializing the callchain rb_tree (Namhyumg Kim)

    - Set dso->long_name when a module name is passed as a parameter
    to tools like 'perf probe' but the 'struct dso' associated to that module
    still doesn't have the full path for the module, just the '[name]' one
    obtained from /proc/modules (Wang Nan)

    - Fix anon_hugepage mmaps detection using scanf on /proc/PID/smaps (Yannick Brosseau)

    Infrastructure changes:

    - Add helper function for updating bpf maps elements (He Kuang)

    - Fix traceevents plugins build race (Jiri Olsa)

    - Add the $OUTPUT path prefix with 'fixdep' (Jiri Olsa)

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

    Ingo Molnar
     
  • Add bpf_map_update_elem() helper function which calls the sys_bpf
    syscall to update elements in bpf maps. Upcoming patches will use it to
    adjust data in map through the perf command line.

    Signed-off-by: He Kuang
    Cc: Alexei Starovoitov
    Cc: Masami Hiramatsu
    Cc: Namhyung Kim
    Cc: Wang Nan
    Cc: Zefan Li
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1448372181-151723-4-git-send-email-wangnan0@huawei.com
    Signed-off-by: Wang Nan
    Signed-off-by: Arnaldo Carvalho de Melo

    He Kuang
     
  • Adding WIEGHT bit_name call to display sample_type properly.

    $ perf evlist -v
    cpu/mem-loads/pp: ...SNIP... sample_type: IP|TID|TIME|ADDR|ID|CPU|DATA_SRC|WEIGHT ...

    Signed-off-by: Jiri Olsa
    Tested-by: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1448465815-27404-2-git-send-email-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • Clear sample_(type|period) for counting, as it only confuses debug
    output with unwanted sampling details:

    Before:

    $ sudo perf stat -e 'raw_syscalls:sys_enter' -vv ls
    ------------------------------------------------------------
    perf_event_attr:
    type 2
    size 112
    config 0x11
    { sample_period, sample_freq } 1
    sample_type TIME|CPU|PERIOD|RAW
    read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
    disabled 1
    inherit 1
    enable_on_exec 1
    exclude_guest 1
    ...

    After:
    $ sudo perf stat -e 'raw_syscalls:sys_enter' -vv ls
    ------------------------------------------------------------
    perf_event_attr:
    type 2
    size 112
    config 0x11
    read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
    disabled 1
    inherit 1
    enable_on_exec 1
    exclude_guest 1
    ...

    Signed-off-by: Jiri Olsa
    Tested-by: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1448465815-27404-1-git-send-email-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • Currently when debuginfo is separated to vmlinux.debug, it's contents
    get ignored. Let's change that and add it to the vmlinux_path list.

    Signed-off-by: Ekaterina Tumanova
    Acked-by: Alexander Yarygin
    Acked-by: Jiri Olsa
    Cc: Adrian Hunter
    Cc: Christian Borntraeger
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Naveen N. Rao
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1448469166-61363-3-git-send-email-tumanova@linux.vnet.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Ekaterina Tumanova
     
  • Refactor vmlinux_path__init() to ease subsequent additions of new
    vmlinux locations.

    Signed-off-by: Ekaterina Tumanova
    Acked-by: Alexander Yarygin
    Acked-by: Jiri Olsa
    Cc: Adrian Hunter
    Cc: Christian Borntraeger
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Naveen N. Rao
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1448469166-61363-2-git-send-email-tumanova@linux.vnet.ibm.com
    [ Rename vmlinux_path__update() to vmlinux_path__add() ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Ekaterina Tumanova
     
  • Adding OUTPUT path prefix for fixdep target so we use it properly in out
    of tree builds.

    If the fixdep already existed in the tree, the out of tree build would
    see it already exist and did not build the out of tree version, as
    reported by Arnaldo:

    [acme@zoo linux]$ make O=/tmp/build/perf -C tools/perf
    make: Entering directory '/home/git/linux/tools/perf'
    BUILD: Doing 'make -j4' parallel build
    make[2]: Nothing to be done for 'fixdep'.
    make: Leaving directory '/home/git/linux/tools/perf'

    Reported-and-Tested-by: Arnaldo Carvalho de Melo
    Signed-off-by: Jiri Olsa
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/20151126185055.GC19410@krava.brq.redhat.com
    [ Fixed conflict with 5725dd8fa888 ("tools build: Clean CFLAGS and LDFLAGS for fixdep") ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • Passing perf_script struct into process_event function, so we could
    process configuration data for event printing.

    It will be used in following patch to get event name string width.

    Signed-off-by: Jiri Olsa
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20151126175521.GA18979@krava.brq.redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • When parsing /proc/xxx/maps, the sscanf in perf_event__synthesize_mmap_events
    truncate the map name at the space in "/anon_hugepage (deleted)".

    is_anon_memory() then only receives the string "/anon_hugepage" and does
    not detect it. We change is_anon_memory() to only compare the first
    part of the string, effectively ignoring if " (deleted)" is there.

    Signed-off-by: Yannick Brosseau
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Andi Kleen
    Cc: Joshua Zhu
    Cc: kernel-team@fb.com
    Link: http://lkml.kernel.org/r/1448538152-2898-1-git-send-email-scientist@fb.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Yannick Brosseau
     
  • Something unexpected may happen if copy statically linked perf to a
    production environment:

    # ./perf probe -m ./mymodule.ko my_func
    [mymodule] with build id 326ab42550ef3d24944f53c817533728367effeb not found, continuing without symbols
    Failed to find symbol my_func in /home/wangnan/kmodule/mymodule.ko
    Error: Failed to add events.
    # ./perf buildid-cache -a ./mymodule.ko
    # ./perf probe -m ./mymodule.ko my_func
    Added new event:
    probe:my_func (on my_func in /home/wangnan/kmodule/mymodule.ko)

    You can now use it in all perf tools, such as:

    perf record -e probe:my_func -aR sleep 1

    Where:

    # ldd ./perf
    not a dynamic executable
    # strace -e open ./perf probe -m ./mymodule.ko my_func
    ...
    open("/home/wangnan/kmodule/mymodule.ko", O_RDONLY) = 3
    open("/home/wangnan/kmodule/../lib64/elfutils/libebl_x86_64.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    ...
    open("/lib64/tls/libebl_x86_64.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    open("/lib64/libebl_x86_64.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    open("/usr/lib64/tls/libebl_x86_64.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    open("/usr/lib64/libebl_x86_64.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    open("[mymodule]", O_RDONLY) = -1 ENOENT (No such file or directory)
    open("/home/wangnan/.debug/.build-id/32/6ab42550ef3d24944f53c817533728367effeb", O_RDONLY) = -1 ENOENT (No such file or directory)
    open("[mymodule]", O_RDONLY) = -1 ENOENT (No such file or directory)

    In the above example, probe fails before we put the module into
    buildid-cache. However, user would expect it success in both case
    because perf is able to find probe points actually.

    The reason is because perf won't utilize module's full path if it failed
    to open debuginfo. In:

    convert_to_probe_trace_events ->
    find_probe_trace_events_from_map ->
    get_target_map ->
    kernel_get_module_map ->
    machine__findnew_module_map ->
    map_groups__find_by_name

    map_groups__find_by_name() is able to find the map of that module, but
    this information is found from /proc/module before it knows the real
    path of the offline module. Therefore, the map->dso->long_name is set to
    something like '[mymodule]', which prevent dso__load() find the real
    path of the module file.

    In another aspect, if dso__load() can get the offline module through
    buildid cache, it can read symble table from that ko. Even if debuginfo
    is not available, 'perf probe' can success if the '.symtab' can be
    found.

    This patch improves machine__findnew_module_map(): when dso->long_name
    is leading with '[' (doesn't find path of module when parsing
    /proc/modules), fixes it by dso__set_long_name(), so following
    dso__load() is possible to find the symbol table.

    This patch won't interfere with buildid matching. Here is the test
    result:

    # ./perf probe -m ./mymodule.ko my_func
    Added new event:
    probe:my_func (on my_func in /home/wangnan/kmodule/mymodule.ko)

    You can now use it in all perf tools, such as:

    perf record -e probe:my_func -aR sleep 1

    # ./perf probe -d '*'
    Removed event: probe:my_func
    # mv ./mymodule.{ko,.bak}
    # mv ./moduleb.ko mymodule.ko
    # ./perf probe -m ./mymodule.ko my_func
    /home/wangnan/kmodule/mymodule.ko with build id 326ab42550ef3d24944f53c817533728367effeb not found, continuing without symbols
    Failed to find symbol my_func in /home/wangnan/kmodule/mymodule.ko
    Error: Failed to add events.

    # ./perf probe -v -m ./mymodule.ko my_func
    probe-definition(0): my_func
    symbol:my_func file:(null) line:0 offset:0 return:0 lazy:(null)
    0 arguments
    Could not open debuginfo. Try to use symbols.
    symsrc__init: build id mismatch for /home/wangnan/kmodule/mymodule.ko.
    /home/wangnan/kmodule/mymodule.ko with build id 326ab42550ef3d24944f53c817533728367effeb not found, continuing without symbols
    Failed to find symbol my_func in /home/wangnan/kmodule/mymodule.ko
    Error: Failed to add events. Reason: No such file or directory (Code: -2)

    Signed-off-by: Wang Nan
    Cc: Masami Hiramatsu
    Cc: Namhyung Kim
    Cc: Zefan Li
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1448510397-187965-1-git-send-email-wangnan0@huawei.com
    [ Renamed adjust_dso_long_name() do dso__adjust_kmod_long_name() ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     
  • Ingo reported following build failure:

    $ make clean install
    ...
    CC plugin_kmem.o
    fixdep: error opening depfile: ./.plugin_hrtimer.o.d: No such file or directory
    /home/mingo/tip/tools/build/Makefile.build:77: recipe for target
    'plugin_hrtimer.o' failed
    make[3]: *** [plugin_hrtimer.o] Error 2
    Makefile:189: recipe for target 'plugin_hrtimer-in.o' failed
    make[2]: *** [plugin_hrtimer-in.o] Error 2
    Makefile.perf:414: recipe for target 'libtraceevent_plugins' failed
    make[1]: *** [libtraceevent_plugins] Error 2
    make[1]: *** Waiting for unfinished jobs....

    Currently we have the install-traceevent-plugins target being dependent
    on $(LIBTRACEEVENT), which will actualy not build any plugin. So the
    install-traceevent-plugins target itself will try to build plugins,
    but..

    Plugins built is also triggered by perf build itself via
    libtraceevent_plugins target.

    This might cause a race having one make thread removing temp files from
    another and result in above error. Fixing this by having proper plugins
    build dependency before installing plugins.

    Reported-and-Tested-by:: Ingo Molnar
    Signed-off-by: Jiri Olsa
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1448546044-28973-3-git-send-email-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • The default script handler (the one that displays samples on screen) is
    implemented scripting_ops instance with process_event callback.

    This way we can't pass any script config into display function, because
    we don't want perl or python handlers to be depended on perf script
    internals.

    Removing the default_scripting_ops and calling process event function
    directly. This way it's possible to pass perf_script struct and process
    configuration data in following commit.

    Signed-off-by: Jiri Olsa
    Acked-by: David Ahern
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1448546125-29245-1-git-send-email-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • The callchain rbtree is rebuilt periodically, so it needs to
    reinitialize the root everytime. Otherwise it can be stuck in the
    rbtree insertion with stale pointers.

    Signed-off-by: Namhyung Kim
    Cc: Andi Kleen
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Kan Liang
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1448521700-32062-1-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • If user requested to hide unresolved entries, skip unresolved callchains
    as well as hist entries.

    Signed-off-by: Namhyung Kim
    Acked-by: Jiri Olsa
    Cc: Andi Kleen
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Kan Liang
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1448521700-32062-3-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     

26 Nov, 2015

4 commits

  • …it/acme/linux into perf/core

    Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

    User visible changes:

    - Fix to free temporal Dwarf_Frame correctly in 'perf probe', fixing a
    regression introduced in perf/core that prevented, at least, adding
    an uprobe collecting function parameter values (Masami Hiramatsu)

    - Fix output of %llu for 64 bit values read on 32 bit machines in
    libtraceevent (Steven Rostedt)

    Developer visible:

    - Clean CFLAGS and LDFLAGS for fixdep in tools/build (Wang Nan)

    - Don't do a feature check when cleaning tools/lib/bpf (Wang Nan)

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

    Ingo Molnar
     
  • Before this patch libbpf always do feature check even when cleaning.

    For example:

    $ cd kernel/tools/lib/bpf
    $ make

    Auto-detecting system features:
    ... libelf: [ on ]
    ... bpf: [ on ]

    CC libbpf.o
    CC bpf.o
    LD libbpf-in.o
    LINK libbpf.a
    LINK libbpf.so
    $ make clean
    CLEAN libbpf
    CLEAN core-gen
    $ make clean

    Auto-detecting system features:
    ... libelf: [ on ]
    ... bpf: [ on ]

    CLEAN libbpf
    CLEAN core-gen
    $

    Although the first 'make clean' doesn't show feature check result, it
    still does the check. No output because check result is similar to
    FEATURE-DUMP.libbpf.

    This patch uses same method as perf to turn off feature checking when
    'make clean'.

    Reported-and-Tested-by: Arnaldo Carvalho de Melo
    Signed-off-by: Wang Nan
    Cc: Alexei Starovoitov
    Cc: Jiri Olsa
    Cc: Masami Hiramatsu
    Cc: Zefan Li
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1448372181-151723-3-git-send-email-wangnan0@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     
  • Sometimes passing variables to tools/build is dangerous. For example, on
    my platform there is a gcc problem (gcc 4.8.1):

    It passes the stackprotector-all feature check:

    $ gcc -fstack-protector-all -c ./test.c
    $ echo $?
    0

    But requires LDFLAGS support if separate compiling and linking:
    $ gcc -fstack-protector-all -c ./test.c
    $ gcc ./test.o
    ./test.o: In function `main':
    test.c:(.text+0xb): undefined reference to `__stack_chk_guard'
    test.c:(.text+0x21): undefined reference to `__stack_chk_guard'
    collect2: error: ld returned 1 exit status
    $ gcc -fstack-protector-all ./test.o
    $ echo $?
    0
    $ gcc ./test.o -lssp
    $ echo $?
    0
    $

    In this environment building perf throws an error:

    $ make
    BUILD: Doing 'make -j24' parallel build
    config/Makefile:344: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR
    config/Makefile:403: No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev
    config/Makefile:418: slang not found, disables TUI support. Please install slang-devel or libslang-dev
    config/Makefile:432: GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev
    config/Makefile:564: No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling
    config/Makefile:606: No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev
    CC fixdep.o
    LD fixdep-in.o
    LINK fixdep
    fixdep-in.o: In function `parse_dep_file':
    /kernel/tools/build/fixdep.c:47: undefined reference to `__stack_chk_guard'
    /kernel/tools/build/fixdep.c:117: undefined reference to `__stack_chk_guard'
    fixdep-in.o: In function `main':
    /kernel-hydrogen/tools/build/fixdep.c:156: undefined reference to `__stack_chk_guard'
    /kernel/tools/build/fixdep.c:168: undefined reference to `__stack_chk_guard'
    collect2: error: ld returned 1 exit status
    make[2]: *** [fixdep] Error 1
    make[1]: *** [fixdep] Error 2
    make: *** [all] Error 2

    This is because the CFLAGS used in building perf pollutes the CFLAGS
    used for fixdep, passing -fstack-protector-all to buiold fixdep which is
    obviously not required. Since fixdep is a small host side tool, we
    should keep its CFLAGS/LDFLAGS simple and clean.

    This patch clears the CFLAGS and LDFLAGS passed when building fixdep, so
    such gcc problem won't block the perf build process.

    Signed-off-by: Wang Nan
    Acked-by: Jiri Olsa
    Cc: Alexei Starovoitov
    Cc: Masami Hiramatsu
    Cc: Zefan Li
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1448372181-151723-2-git-send-email-wangnan0@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     
  • The commit 05c8d802fa52 ("perf probe: Fix to free temporal Dwarf_Frame")
    tried to fix the memory leak of Dwarf_Frame, but it released the frame
    at wrong point. Since the dwarf_frame_cfa(frame, &pf->fb_ops, &nops) can
    return an address inside the frame data structure to pf->fb_ops, we can
    not release the frame before using pf->fb_ops.

    This reverts the commit and releases the frame afterwards (right before
    returning from call_probe_finder) correctly.

    Reported-and-Tested-by: Arnaldo Carvalho de Melo
    Reported-by: Michael Petlan
    Signed-off-by: Masami Hiramatsu
    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Fixes: 05c8d802fa52 ("perf probe: Fix to free temporal Dwarf_Frame")
    LPU-Reference: 20151125103432.1473.31009.stgit@localhost.localdomain
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

24 Nov, 2015

1 commit

  • …/acme/linux into perf/core

    Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

    User visible changes:

    - Allow callchain order (caller, callee) to the libdw and libunwind based DWARF
    unwinders (Jiri Olsa)

    - Add missing parent_val initialization in the callchain code, fixing a
    SEGFAULT when using callchains with 'perf top' (Jiri Olsa)

    - Add initial 'perf config' command, for now just with a --list command to the
    contents of the configuration file in use and a basic man page describing
    its format, commands for doing edits and detailed documentation are being
    reviewed and proof-read. (Taeung Song)

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

    Ingo Molnar