10 Jan, 2014

1 commit

  • commit f447ef4a56dee4b68a91460bcdfe06b5011085f2 upstream.

    If a user calls 'cpupower set --perf-bias 15', the process will end with
    a SIGSEGV in libc because cpupower-set passes a NULL optarg to the atoi
    call. This is because the getopt_long structure currently has all of
    the options as having an optional_argument when they really have a
    required argument. We change the structure to use required_argument to
    match the short options and it resolves the issue.

    This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1000439

    Signed-off-by: Josh Boyer
    Cc: Dominik Brodowski
    Cc: Thomas Renninger
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Josh Boyer
     

05 Dec, 2013

2 commits

  • commit 9d4ecc8893832337daf241236841db966fa53489 upstream.

    When introducing the PERF_RECORD_MMAP2 in:

    5c5e854bc760 perf tools: Add attr->mmap2 support

    A check for the number of entries parsed by sscanf was introduced that
    assumed all of the 8 fields needed to be correctly parsed so that
    particular /proc/pid/maps line would be considered synthesizable.

    That broke anon records synthesizing, as it doesn't have the 'execname'
    field.

    Fix it by keeping the sscanf return check, changing it to not require
    that the 'execname' variable be parsed, so that the preexisting logic
    can kick in and set it to '//anon'.

    This should get things like JIT profiling working again.

    Signed-off-by: Don Zickus
    Cc: Bill Gray
    Cc: Jiri Olsa
    Cc: Joe Mario
    Cc: Richard Fowles
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/n/tip-bo4akalno7579shpz29u867j@git.kernel.org
    [ commit log message is mine, dzickus reported the problem with a patch ]
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Don Zickus
     
  • commit 53805eca3d89b095062c11a6798689bb0af09216 upstream.

    The 4fb71074a570 (perf ui/hist: Consolidate hpp helpers) cset introduced
    a cast of percent_color_snprintf to a function pointer type with
    varargs. Change percent_color_snprintf to be variadic and remove the
    cast.

    The symptom of this was all percentages being reported as 0.00% in perf
    report --stdio output on the armhf arch.

    Signed-off-by: Michael Hudson-Doyle
    Acked-by: Namhyung Kim
    Acked-by: Will Deacon
    Cc: Jean Pihet
    Cc: Jiri Olsa
    Cc: Will Deacon
    Link: http://lkml.kernel.org/r/87zjppvw7y.fsf@canonical.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Michael Hudson-Doyle
     

29 Oct, 2013

4 commits

  • The tail position of the event buffer should only be modified after
    actually use that event.

    If not the event buffer could be invalid before use, and segment fault
    occurs when invoking perf top -G.

    Signed-off-by: Zhouyi Zhou
    Cc: David Ahern
    Cc: Zhouyi Zhou
    Link: http://lkml.kernel.org/r/1382600613-32177-1-git-send-email-zhouzhouyi@gmail.com
    [ Simplified the logic using exit gotos and renamed write_tail method to mmap_consume ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Zhouyi Zhou
     
  • Splitting -G and --call-graph for record command, so we could use '-G'
    with no option.

    The '-G' option now takes NO argument and enables the configured unwind
    method, which is currently the frame pointers method.

    It will be possible to configure unwind method via config file in
    upcoming patches.

    All current '-G' arguments is overtaken by --call-graph option.

    NOTE: The documentation for top --call-graph option
    was wrongly copied from report command.

    Signed-off-by: Jiri Olsa
    Tested-by: David Ahern
    Tested-by: Ingo Molnar
    Reviewed-by: David Ahern
    Acked-by: Ingo Molnar
    Cc: Adrian Hunter
    Cc: Andi Kleen
    Cc: Corey Ashford
    Cc: David Ahern
    Cc: Ingo Molnar
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1382797536-32303-3-git-send-email-jolsa@redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • Splitting -g and --call-graph for record command, so we could use '-g'
    with no option.

    The '-g' option now takes NO argument and enables the configured unwind
    method, which is currently the frame pointers method.

    It will be possible to configure unwind method via config file in
    upcoming patches.

    All current '-g' arguments is overtaken by --call-graph option.

    Signed-off-by: Jiri Olsa
    Tested-by: David Ahern
    Tested-by: Ingo Molnar
    Reviewed-by: David Ahern
    Acked-by: Ingo Molnar
    Cc: Adrian Hunter
    Cc: Andi Kleen
    Cc: Corey Ashford
    Cc: David Ahern
    Cc: Ingo Molnar
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1382797536-32303-2-git-send-email-jolsa@redhat.com
    [ reordered -g/--call-graph on --help and expanded the man page
    according to comments by David Ahern and Namhyung Kim ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • Following commit tightened up the buffer size for output to strict width
    of used format columns:

    99cf666 perf hists: Fix formatting of long symbol names

    This works fine until you hit color overhead output which places extra
    bytes into output buffer. We need to account for color overhead in the
    output buffer. Adding maximum color byte size to the output buffer size.

    Signed-off-by: Jiri Olsa
    Cc: Adrian Hunter
    Cc: Corey Ashford
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1382700293-1803-1-git-send-email-jolsa@redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     

28 Oct, 2013

1 commit

  • When introducing support for MMAP2 we considered more parts of each map
    representation in /proc/PID/maps, and when disabling it we forgot to
    reduce the number of expected parsed/assigned entries in the sscanf
    call, fix it to expect the right number of desired fields, 5.

    Reported-by: Markus Trippelsdorf
    Based-on-a-patch-by: Markus Trippelsdorf
    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/n/tip-vrbo1wik997ahjzl1chm3bdm@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

24 Oct, 2013

1 commit

  • We are using the Python scripting interface in perf to extract kernel
    events relevant for performance analysis of HPC codes. We noticed that
    the "perf script" call allocates a significant amount of memory (in the
    order of several 100 MiB) during it's run, e.g. 125 MiB for a 25 MiB
    input file:

    $> perf record -o perf.data -a -R -g fp \
    -e power:cpu_frequency -e sched:sched_switch \
    -e sched:sched_migrate_task -e sched:sched_process_exit \
    -e sched:sched_process_fork -e sched:sched_process_exec \
    -e cycles -m 4096 --freq 4000
    $> /usr/bin/time perf script -i perf.data -s dummy_script.py
    0.84user 0.13system 0:01.92elapsed 51%CPU (0avgtext+0avgdata
    125532maxresident)k
    73072inputs+0outputs (57major+33086minor)pagefaults 0swaps

    Upon further investigation using the valgrind massif tool, we noticed
    that Python objects that are created in trace-event-python.c via
    PyString_FromString*() (and their Integer and Long counterparts) are
    never free'd.

    The reason for this seem to be missing Py_DECREF calls on the objects
    that are returned by these functions and stored in the Python
    dictionaries. The Python dictionaries do not steal references (as
    opposed to Python tuples and lists) but instead add their own reference.

    Hence, the reference that is returned by these object creation functions
    is never released and the memory is leaked. (see [1,2])

    The attached patch fixes this by wrapping all relevant calls to
    PyDict_SetItemString() and decrementing the reference counter
    immediately after the Python function call.

    This reduces the allocated memory to a reasonable amount:

    $> /usr/bin/time perf script -i perf.data -s dummy_script.py
    0.73user 0.05system 0:00.79elapsed 99%CPU (0avgtext+0avgdata
    49132maxresident)k
    0inputs+0outputs (0major+14045minor)pagefaults 0swaps

    For comparison, with a 120 MiB input file the memory consumption
    reported by time drops from almost 600 MiB to 146 MiB.

    The patch has been tested using Linux 3.8.2 with Python 2.7.4 and Linux
    3.11.6 with Python 2.7.5.

    Please let me know if you need any further information.

    [1] http://docs.python.org/2/c-api/tuple.html#PyTuple_SetItem
    [2] http://docs.python.org/2/c-api/dict.html#PyDict_SetItemString

    Signed-off-by: Joseph Schuchart
    Reviewed-by: Tom Zanussi
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Tom Zanussi
    Link: http://lkml.kernel.org/r/1381468543-25334-4-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Joseph Schuchart
     

20 Oct, 2013

1 commit


18 Oct, 2013

2 commits

  • For now, we disable the extended MMAP record support (MMAP2).

    We have identified cases where it would not report the correct mapping
    information, clone(VM_CLONE) but with separate pids. We will revisit
    the support once we find a solution for this case.

    The patch changes the kernel to return EINVAL if attr->mmap2 is set. The
    patch also modifies the perf tool to use regular PERF_RECORD_MMAP for
    synthetic events and it also prevents the tool from requesting
    attr->mmap2 mode because the kernel would reject it.

    The support will be revisited once the kenrel interface is updated.

    In V2, we reduce the patch to the strict minimum.

    In V3, we avoid calling perf_event_open() with mmap2 set because we know
    it will fail and require fallback retry.

    Signed-off-by: Stephane Eranian
    Cc: Andi Kleen
    Cc: David Ahern
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20131017173215.GA8820@quad
    Signed-off-by: Arnaldo Carvalho de Melo

    Stephane Eranian
     
  • Cast __u64 to u64 to silence this warning on older distros, such as
    Fedora 12:

    CC /tmp/build/perf/util/scripting-engines/trace-event-perl.o
    cc1: warnings being treated as errors
    util/scripting-engines/trace-event-perl.c: In function ‘perl_process_tracepoint’:
    util/scripting-engines/trace-event-perl.c:285: error: format ‘%lu’ expects type ‘long unsigned int’, but argument 2 has type ‘__u64’
    make[1]: *** [/tmp/build/perf/util/scripting-engines/trace-event-perl.o] Error 1
    make: *** [install] Error 2
    make: Leaving directory `/home/acme/git/linux/tools/perf'
    [acme@fedora12 linux]$

    Reported-by: Waiman Long
    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Tom Zanussi
    Cc: Waiman Long
    Link: http://lkml.kernel.org/n/tip-nlxofdqcdjfm0w9o6bgq4kqv@git.kernel.org
    Link: http://lkml.kernel.org/r/1381265120-58532-1-git-send-email-Waiman.Long@hp.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

17 Oct, 2013

1 commit


16 Oct, 2013

1 commit

  • Fix perf probe --list to initialize fname local var always before
    use it. This may cause a SEGV if there is a probe which is in
    the function body but not in any inline function.

    Problem introduced in:

    commit e08cfd4bda76
    Author: Masami Hiramatsu
    Date: Mon Sep 30 18:21:44 2013 +0900

    perf probe: Fix to find line information for probe list

    Signed-off-by: Masami Hiramatsu
    Cc: Ingo Molnar
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20131011122317.9662.29736.stgit@kbuild-fedora.novalocal
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

05 Oct, 2013

6 commits

  • perf-record updates the header in the perf.data file at termination.
    Without this update perf-report (and other processing built-ins) it
    caused an infinite loop when perf report (or something like) called.

    This is because the algorithm in __perf_session__process_events()
    depends on the data_size which is read from file header. Use file size
    directly instead in this case to do the best-effort processing.

    Signed-off-by: Namhyung Kim
    Tested-by: David Ahern
    Tested-by: Sonny Rao
    Acked-by: Ingo Molnar
    Cc: David Ahern
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Sonny Rao
    Link: http://lkml.kernel.org/r/1380529188-27193-1-git-send-email-namhyung@kernel.org
    Signed-off-by: David Ahern
    [ Reworded warning as per Ingo Molnar suggestion, replaces 'perf.data'
    with session->filename, to precisely identify the data file involved ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • Doing a fresh install on a user home directory needs to first make sure
    that the ~/libexec/perf-core/ directory is present so that
    'perf-archive' like scripts, 'perf test' attr config files and 'perf
    script' scripts can be installed.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/n/tip-z7ryi3r1b9dn9smbfnab0fdc@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • Fix to find the correct (as much as possible) line information for
    listing probes. Without this fix, perf probe --list action will show
    incorrect line information as below;

    probe:getname_flags (on getname_flags@ksrc/linux-3/fs/namei.c)
    probe:getname_flags_1 (on getname:-89@x86/include/asm/current.h)
    probe:getname_flags_2 (on user_path_at_empty:-2054@x86/include/asm/current.h)

    The minus line number is obviously wrong, and current.h is not related
    to the probe point. Deeper investigation discovered that there were 2
    issues related to this bug, and minor typos too.

    The 1st issue is the rack of considering about nested inlined functions,
    which causes the wrong (relative) line number.

    The 2nd issue is that the dwarf line info is not correct at those
    points. It points 14th line of current.h.

    Since it seems that the line info includes somewhat unreliable
    information, this fixes perf to try to find correct line information
    from both of debuginfo and line info as below.

    1) Probe address is the entry of a function instance

    In this case, the line is set as the function declared line.

    2) Probe address is the entry of an expanded inline function block

    In this case, the line is set as the function call-site line.
    This means that the line number is relative from the entry line
    of caller function (which can be an inlined function if nested)

    3) Probe address is inside a function instance or an expanded
    inline function block

    In this case, perf probe queries the line number from lineinfo
    and verify the function declared file is same as the file name
    queried from lineinfo.

    If the file name is different, it is a failure case. The probe
    address is shown as symbol+offset.

    4) Probe address is not in the any function instance

    This is a failure case, the probe address is shown as
    symbol+offset.

    With this fix, perf probe -l shows correct probe lines as below;

    probe:getname_flags (on getname_flags@ksrc/linux-3/fs/namei.c)
    probe:getname_flags_1 (on getname:2@ksrc/linux-3/fs/namei.c)
    probe:getname_flags_2 (on user_path_at_empty:4@ksrc/linux-3/fs/namei.c)

    Changes at v2:
    - Fix typos in the function comments. (Thanks to Namhyung Kim)
    - Use die_find_top_inlinefunc instead of die_find_inlinefunc_next.

    Signed-off-by: Masami Hiramatsu
    Cc: Ingo Molnar
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20130930092144.1693.11058.stgit@udc4-manage.rcp.hitachi.co.jp
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     
  • In ubuntu systems the libaudit test was always failing due to the
    newline in the printf call not being escaped, which somehow didn't
    prevented the test from working as expected on other systems, such
    as fedora18.

    Fix it by removing the newline, as this is just a test, that program is
    just a compile test.

    The error messages, obtained using 'make V=1':

    CHK libaudit
    : In function ‘main’:
    :5:9: error: missing terminating " character [-Werror]
    :5:2: error: missing terminating " character
    :6:1: error: missing terminating " character [-Werror]
    :6:1: error: missing terminating " character
    :7:2: error: expected expression before ‘return’
    :8:1: error: expected ‘;’ before ‘}’ token
    cc1: all warnings being treated as errors
    config/Makefile:241: No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev

    After this change the test works as expected in all systems tested and the
    'trace' tool is built when the needed devel packages are installed.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/n/tip-0trw8qs9hafeopc0vj1sicay@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • The commit acf2892270dc ("perf stat: Use perf_evlist__prepare/
    start_workload()") converted to use the function but forgot to update
    child_pid. Fix it.

    Signed-off-by: Namhyung Kim
    Cc: David Ahern
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1380531671-28076-1-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • Commands that do not implement an mmap2 handler should at least not die
    with a segfault when processing files with MMAP2 events.

    Signed-off-by: David Ahern
    Link: http://lkml.kernel.org/r/1379900700-5186-5-git-send-email-dsahern@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    David Ahern
     

29 Sep, 2013

1 commit

  • This reverts commit de95ab53645a2f0015e0f68ee723f18dce2b8b51.

    Markus Trippelsdorf reported that this commit broke 'perf top':

    > I just see a gray screen with no text at all. Sometimes the
    > following error messages are printed:
    >
    > *** Error in `perf': invalid fastbin entry (free): 0x00000000029b18c0
    > ***
    > *** Error in `perf': malloc(): memory corruption (fast): 0x0000000000ee0b10 ***

    While this code is fixable, the commit itself fails on several levels:

    - it should have been a separate helper function
    - why the heck does it do strchr() twice
    - it casts a const char * over into char *
    - sloppy style
    - it's not even a regression fix!

    So lets revert it and re-try the patch in v3.13.

    Reported-by: Markus Trippelsdorf
    Cc: Andi Kleen
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Linus Torvalds
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

25 Sep, 2013

6 commits

  • The libbfd C++ demangler doesn't seem to deal with cloned functions,
    like symbol.clone.NUM.

    Just strip the dot part before demangling and add it back later.

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1378998998-10802-1-git-send-email-andi@firstfloor.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Andi Kleen
     
  • In machine__create_modules() the 'path' char array was used in a call to
    symbol__restricted_filename() without always being populated.

    Signed-off-by: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Mike Galbraith
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1379845338-29637-2-git-send-email-adrian.hunter@intel.com
    [ Split patch removing unrelated conversion of sprintf to snprintf to perf/core ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Fixes compile failure on Fedora 12.

    Signed-off-by: David Ahern
    Link: http://lkml.kernel.org/r/1379900700-5186-3-git-send-email-dsahern@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    David Ahern
     
  • Fix perf probe to probe on some symbols which have some optimzation
    suffixes, e.g. ".part", ".isra", and ".constprop".

    To fix this issue, instead of using the DIE name, perf probe uses the
    symbol name found by dwfl_module_addrsym().

    This also involves a perf probe --vars operation update which now shows
    the symbol name instead of the DIE name.

    Without this patch, putting a probe on an inlined function which was
    compiled with a suffixed symbol will fail like this:

    $ perf probe -v getname_flags
    probe-definition(0): getname_flags
    symbol:getname_flags file:(null) line:0 offset:0 return:0 lazy:(null)
    0 arguments
    Looking at the vmlinux_path (6 entries long)
    Using /lib/modules/3.11.0+/build/vmlinux for symbols
    found inline addr: 0xffffffff8119bb70
    Probe point found: getname_flags+0
    found inline addr: 0xffffffff8119bcb6
    Probe point found: getname+6
    found inline addr: 0xffffffff811a06a6
    Probe point found: user_path_at_empty+6
    find 3 probe_trace_events.
    Opening /sys/kernel/debug//tracing/kprobe_events write=1
    Added new events:
    Writing event: p:probe/getname_flags getname_flags+0
    Failed to write event: No such file or directory
    Error: Failed to add events. (-1)

    Because the debuginfo knows only the original (non suffix) symbol name,
    it uses the original symbol for probe address but the kernel (kallsyms)
    knows only suffixed symbol. Then, the kernel rejects that original
    symbol.

    This patch uses dwfl_module_addrsym() to get the correct (suffixed)
    symbol from symtab when a probe point is found.

    Reported-by: Arnaldo Carvalho de Melo
    Signed-off-by: Masami Hiramatsu
    Cc: Ingo Molnar
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20130925131616.31632.46658.stgit@udc4-manage.rcp.hitachi.co.jp
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     
  • 5c5e854b changed perf_event__synthesize_mmap_events to generate MMAP2
    events. Since perf-trace does not have a handler for it it dies with a
    segfault when trying to process files:

    perf trace -i /tmp/perf.data
    Segmentation fault

    Signed-off-by: David Ahern
    Link: http://lkml.kernel.org/r/1379900700-5186-4-git-send-email-dsahern@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    David Ahern
     
  • The commit '2814eb0 perf kmem: Remove die() calls' disabled 'perf kmem'
    command for machines without numa support. It made the command fail if
    '/sys/devices/system/node' dir wasn't found.

    Skipping the numa based initialization in case the directory is not
    found and continue execution.

    Signed-off-by: Jiri Olsa
    Cc: Corey Ashford
    Cc: Frederic Weisbecker
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1379003976-5839-5-git-send-email-jolsa@redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     

20 Sep, 2013

4 commits

  • Solve the problems around the broken definition of perf_event_mmap_page::
    cap_usr_time and cap_usr_rdpmc fields which used to overlap, partially
    fixed by:

    860f085b74e9 ("perf: Fix broken union in 'struct perf_event_mmap_page'")

    The problem with the fix (merged in v3.12-rc1 and not yet released
    officially), noticed by Vince Weaver is that the new behavior is
    not detectable by new user-space, and that due to the reuse of the
    field names it's easy to mis-compile a binary if old headers are used
    on a new kernel or new headers are used on an old kernel.

    To solve all that make this change explicit, detectable and self-contained,
    by iterating the ABI the following way:

    - Always clear bit 0, and rename it to usrpage->cap_bit0, to at least not
    confuse old user-space binaries. RDPMC will be marked as unavailable
    to old binaries but that's within the ABI, this is a capability bit.

    - Rename bit 1 to ->cap_bit0_is_deprecated and always set it to 1, so new
    libraries can reliably detect that bit 0 is deprecated and perma-zero
    without having to check the kernel version.

    - Use bits 2, 3, 4 for the newly defined, correct functionality:

    cap_user_rdpmc : 1, /* The RDPMC instruction can be used to read counts */
    cap_user_time : 1, /* The time_* fields are used */
    cap_user_time_zero : 1, /* The time_zero field is used */

    - Rename all the bitfield names in perf_event.h to be different from the
    old names, to make sure it's not possible to mis-compile it
    accidentally with old assumptions.

    The 'size' field can then be used in the future to add new fields and it
    will act as a natural ABI version indicator as well.

    Also adjust tools/perf/ userspace for the new definitions, noticed by
    Adrian Hunter.

    Reported-by: Vince Weaver
    Signed-off-by: Peter Zijlstra
    Also-Fixed-by: Adrian Hunter
    Link: http://lkml.kernel.org/n/tip-zr03yxjrpXesOzzupszqglbv@git.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • …it/acme/linux into perf/urgent

    Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

    * Check for SIGINT in more loops, allowing tools such as 'perf report' to
    react faster to Ctrl+C, from Arnaldo Carvalho de Melo.

    * Fix objdump line parsing offset validation in the annotate code,
    from Adrian Hunter.

    * Fix buildid cache handling of kallsyms with kcore, from Adrian Hunter.

    * Fix compile with libelf without get_phdrnum, from Adrian Hunter.

    * Sharpen the libaudit dependencies test, refusing to build with older
    libraries that doesn't have all the functions used by 'perf trace", fix
    from Ingo Molnar.

    * Fill in new definitions for madvise()/mmap() flags to fix the build in
    older systems, from Ingo Molnar.

    * Fix old GCC build error in older systems in the kallsyms parsing code in
    trace-event-parse.c, from Ingo Molnar.

    * Ignore DWARF declaration tags, allowing, for instance, that the

    $ perf probe -L getname

    command succeeds in showing the source code for the 'getname' kernel
    function, telling in which lines probes can be inserted, fix from
    Masami Hiramatsu.

    * Fix linux/magic.h related build breakage in some systems, fix from
    Vinson Lee.

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

    Ingo Molnar
     
  • The compilation only looks for linux/magic.h from the default include
    paths, which does not include the source tree. This results in a build
    error if linux/magic.h is not available or not installed.

    For example, this build error occurs on CentOS 5.

    $ make -C tools/lib/lk V=1
    [...]
    gcc -o debugfs.o -c -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6
    -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement
    -Wformat-security -Wformat-y2k -Winit-self -Wmissing-declarations
    -Wmissing-prototypes -Wnested-externs -Wno-system-headers
    -Wold-style-definition -Wpacked -Wredundant-decls -Wshadow
    -Wstrict-aliasing=3 -Wstrict-prototypes -Wswitch-default -Wswitch-enum
    -Wundef -Wwrite-strings -Wformat -fPIC -D_LARGEFILE64_SOURCE
    -D_FILE_OFFSET_BITS=64 debugfs.c
    debugfs.c:8:25: error: linux/magic.h: No such file or directory

    The only symbol from linux/magic.h needed by debugfs.c is DEBUGFS_MAGIC,
    and that is already defined in debugfs.h. linux/magic.h isn't providing
    any extra symbols and can unincluded. This is similar to the approach by
    perf, which has its own magic.h wrapper at
    tools/perf/util/include/linux/magic.h

    Signed-off-by: Vinson Lee
    Acked-by: Borislav Petkov
    Cc: Borislav Petkov
    Cc: Vinson Lee
    Cc: stable@vger.kernel.org
    Link: http://lkml.kernel.org/r/1379546200-17028-1-git-send-email-vlee@freedesktop.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Vinson Lee
     
  • Old GCC (4.1) does not see through the code flow of parse_proc_kallsyms()
    and gets confused about the status of 'fmt':

    util/trace-event-parse.c: In function ‘parse_proc_kallsyms’:
    util/trace-event-parse.c:189: warning: ‘fmt’ may be used uninitialized in this function
    make: *** [util/trace-event-parse.o] Error 1

    Help out GCC by initializing 'fmt' to NULL.

    Signed-off-by: Ingo Molnar
    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: H. Peter Anvin
    Cc: Jiri Olsa
    Cc: Mike Galbraith
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20130912131649.GC23826@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Ingo Molnar
     

19 Sep, 2013

7 commits

  • The commit ba28c59bc9ed8fb7b9a753cd88ee54a2c4f6265b fixed a declaration
    entry bug in probe_point_search_cb(). There are same bugs in line
    finder and call_probe_finder(). This introduces a new dwarf utility
    function to determine given DIE is a function definition, not
    declaration.

    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Prashanth Nageshappa
    Cc: Srikar Dronamraju
    Cc: Steven Rostedt
    Cc: yrl.pp-manager.tt@hitachi.com
    Link: http://lkml.kernel.org/r/20120423032435.8737.80064.stgit@localhost.localdomain
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     
  • When processing big files we were not checking if session_done was set
    by the SIGINT signal handler, for instance in 'perf report'. Fix it.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/n/tip-pyad42lgrtq7xhg2dpsoauq7@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • Add a feature check for get_phdrnum() and implement a replacement if it
    is not present.

    Signed-off-by: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Mike Galbraith
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1379080170-6608-1-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • When kallsyms is used with kcore the dso long_name becomes the kcore
    file name. That prevents the buildid cache from caching kallsyms.
    (There is no support at present for caching kcore). Fix by changing it
    so that the kallsyms name is used in that case instead.

    Signed-off-by: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Mike Galbraith
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1379009959-28046-1-git-send-email-adrian.hunter@intel.com
    [ Kept 'struct foo' pointer as first parameter of foo__ prefixed functions ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • When parsing lines from objdump a line containing source code starting
    with a numeric label is mistaken for a line of disassembly starting with
    a memory address.

    Current validation fails to recognise that the "memory address" is out
    of range and calculates an invalid offset which later causes this
    segfault:

    Program received signal SIGSEGV, Segmentation fault.
    0x0000000000457315 in disasm__calc_percent (notes=0xc98970, evidx=0, offset=143705, end=2127526177, path=0x7fffffffbf50)
    at util/annotate.c:631
    631 hits += h->addr[offset++];
    (gdb) bt
    #0 0x0000000000457315 in disasm__calc_percent (notes=0xc98970, evidx=0, offset=143705, end=2127526177, path=0x7fffffffbf50)
    at util/annotate.c:631
    #1 0x00000000004d65e3 in annotate_browser__calc_percent (browser=0x7fffffffd130, evsel=0xa01da0) at ui/browsers/annotate.c:364
    #2 0x00000000004d7433 in annotate_browser__run (browser=0x7fffffffd130, evsel=0xa01da0, hbt=0x0) at ui/browsers/annotate.c:672
    #3 0x00000000004d80c9 in symbol__tui_annotate (sym=0xc989a0, map=0xa02660, evsel=0xa01da0, hbt=0x0) at ui/browsers/annotate.c:962
    #4 0x00000000004d7aa0 in hist_entry__tui_annotate (he=0xdf73f0, evsel=0xa01da0, hbt=0x0) at ui/browsers/annotate.c:823
    #5 0x00000000004dd648 in perf_evsel__hists_browse (evsel=0xa01da0, nr_events=1, helpline=
    0x58b768 "For a higher level overview, try: perf report --sort comm,dso", ev_name=0xa02cd0 "cycles", left_exits=false, hbt=
    0x0, min_pcnt=0, env=0xa011e0) at ui/browsers/hists.c:1659
    #6 0x00000000004de372 in perf_evlist__tui_browse_hists (evlist=0xa01520, help=
    0x58b768 "For a higher level overview, try: perf report --sort comm,dso", hbt=0x0, min_pcnt=0, env=0xa011e0)
    at ui/browsers/hists.c:1950
    #7 0x000000000042cf6b in __cmd_report (rep=0x7fffffffd6c0) at builtin-report.c:581
    #8 0x000000000042e25d in cmd_report (argc=0, argv=0x7fffffffe4b0, prefix=0x0) at builtin-report.c:965
    #9 0x000000000041a0e1 in run_builtin (p=0x801548, argc=1, argv=0x7fffffffe4b0) at perf.c:319
    #10 0x000000000041a319 in handle_internal_command (argc=1, argv=0x7fffffffe4b0) at perf.c:376
    #11 0x000000000041a465 in run_argv (argcp=0x7fffffffe38c, argv=0x7fffffffe380) at perf.c:420
    #12 0x000000000041a707 in main (argc=1, argv=0x7fffffffe4b0) at perf.c:521

    After the fix is applied the symbol can be annotated showing the
    problematic line "1: rep"

    copy_user_generic_string /usr/lib/debug/lib/modules/3.9.10-100.fc17.x86_64/vmlinux
    */
    ENTRY(copy_user_generic_string)
    CFI_STARTPROC
    ASM_STAC
    andl %edx,%edx
    and %edx,%edx
    jz 4f
    je 37
    cmpl $8,%edx
    cmp $0x8,%edx
    jb 2f /* less than 8 bytes, go to byte copy loop */
    jb 33
    ALIGN_DESTINATION
    mov %edi,%ecx
    and $0x7,%ecx
    je 28
    sub $0x8,%ecx
    neg %ecx
    sub %ecx,%edx
    1a: mov (%rsi),%al
    mov %al,(%rdi)
    inc %rsi
    inc %rdi
    dec %ecx
    jne 1a
    movl %edx,%ecx
    28: mov %edx,%ecx
    shrl $3,%ecx
    shr $0x3,%ecx
    andl $7,%edx
    and $0x7,%edx
    1: rep
    100.00 rep movsq %ds:(%rsi),%es:(%rdi)
    movsq
    2: movl %edx,%ecx
    33: mov %edx,%ecx
    3: rep
    rep movsb %ds:(%rsi),%es:(%rdi)
    movsb
    4: xorl %eax,%eax
    37: xor %eax,%eax
    data32 xchg %ax,%ax
    ASM_CLAC
    ret
    retq

    Signed-off-by: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Mike Galbraith
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1379009721-27667-1-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • builtin-trace.c started using various new syscall features not defined
    in the header files of older distros - resulting in build failures.

    Fill in the (ABI) constants if they are not defined.

    (There might be a better place to put this than builtin-trace.c, into a
    compat header or so.)

    Signed-off-by: Ingo Molnar
    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: H. Peter Anvin
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: linux-tip-commits@vger.kernel.org
    Link: http://lkml.kernel.org/r/20130912132900.GE23826@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Ingo Molnar
     
  • There are older libaudit versions that don't have an
    audit_errno_to_name() method, resulting in a builtin-trace.c build
    error:

    builtin-trace.c: In function ‘trace__sys_exit’:
    builtin-trace.c:794: warning: implicit declaration of function ‘audit_errno_to_name’

    Expand the libaudit test to detect this.

    Signed-off-by: Ingo Molnar
    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: H. Peter Anvin
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20130912132706.GD23826@gmail.com
    [ Fix the test by escaping the double quotes ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Ingo Molnar
     

13 Sep, 2013

1 commit

  • Pull perf fixes from Ingo Molnar:
    "Various fixes.

    The -g perf report lockup you reported is only partially addressed,
    patches that fix the excessive runtime are still being worked on"

    * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    perf/x86: Fix uncore PCI fixed counter handling
    uprobes: Fix utask->depth accounting in handle_trampoline()
    perf/x86: Add constraint for IVB CYCLE_ACTIVITY:CYCLES_LDM_PENDING
    perf: Fix up MMAP2 buffer space reservation
    perf tools: Add attr->mmap2 support
    perf kvm: Fix sample_type manipulation
    perf evlist: Fix id pos in perf_evlist__open()
    perf trace: Handle perf.data files with no tracepoints
    perf session: Separate progress bar update when processing events
    perf trace: Check if MAP_32BIT is defined
    perf hists: Fix formatting of long symbol names
    perf evlist: Fix parsing with no sample_id_all bit set
    perf tools: Add test for parsing with no sample_id_all bit
    perf trace: Check control+C more often

    Linus Torvalds
     

11 Sep, 2013

1 commit

  • This patch adds support for the new PERF_RECORD_MMAP2 record type
    exposed by the kernel. This is an extended PERF_RECORD_MMAP record.

    It adds for each file-backed mapping the device major, minor number and
    the inode number and generation.

    This triplet uniquely identifies the source of a file-backed mapping. It
    can be used to detect identical virtual mappings between processes, for
    instance.

    The patch will prefer MMAP2 over MMAP.

    Signed-off-by: Stephane Eranian
    Cc: Andi Kleen
    Cc: David Ahern
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1377079825-19057-3-git-send-email-eranian@google.com
    [ Cope with 314add6 "Change machine__findnew_thread() to set thread pid",
    fix 'perf test' regression test entry affected,
    use perf_missing_features.mmap2 to fallback to not using .mmap2 in older kernels,
    so that new tools can work with kernels where this feature is not present ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Stephane Eranian