12 Aug, 2011

1 commit

  • A file in /tmp/ might be a symlink, so lstat() should be used instead of
    stat().

    Acked-by: Pekka Enberg
    Cc: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Paul Mackerras
    Cc: Pekka Enberg
    Cc: Peter Zijlstra
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20110811205537.GA22864@albatros
    Signed-off-by: Vasiliy Kulikov
    Signed-off-by: Arnaldo Carvalho de Melo

    Vasiliy Kulikov
     

11 Aug, 2011

1 commit

  • If we bring the recorded perf data together with kernel binary from another
    machine using:

    on server A:
    perf archive

    on server B:
    tar xjvf perf.data.tar.bz2 -C ~/.debug

    the build_id kernel dso is not properly recognized during the "perf report"
    command on server B.

    The reason is, that build_id dsos are added during the session initialization,
    while the kernel maps are created during the sample event processing.

    The machine__create_kernel_maps functions ends up creating new dso object for
    kernel, but it does not check if we already have one added by build_id
    processing.

    Also the build_id reading ABI quirk added in commit:

    - commit b25114817a73bbd2b84ce9dba02ee1ef8989a947
    perf build-id: Add quirk to deal with perf.data file format breakage

    populates the "struct build_id_event::pid" with 0, which
    is later interpreted as DEFAULT_GUEST_KERNEL_ID.

    This is not always correct, so it's better to guess the pid
    value based on the "struct build_id_event::header::misc" value.

    - Tested with data generated on x86 kernel version v2.6.34
    and reported back on x86_64 current kernel.
    - Not tested for guest kernel case.

    Note the problem stays for PERF_RECORD_MMAP events recorded by perf that
    does not use proper pid (HOST_KERNEL_ID/DEFAULT_GUEST_KERNEL_ID). They are
    misinterpreted within the current perf code. Probably there's not much we
    can do about that.

    Cc: Avi Kivity
    Cc: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Yanmin Zhang
    Link: http://lkml.kernel.org/r/20110601194346.GB1934@jolsa.brq.redhat.com
    Signed-off-by: Jiri Olsa
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     

10 Aug, 2011

4 commits

  • It will be immediately replaced in perf_top_browser__run.

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

    Arnaldo Carvalho de Melo
     
  • The external symbol files are generated by JIT compilers, for example, but we
    need to make sure they're ours before injecting them to 'perf report'.

    Requested-by: Ingo Molnar
    Cc: Frederic Weisbecker
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1312919658-17158-1-git-send-email-penberg@kernel.org
    Signed-off-by: Pekka Enberg
    Signed-off-by: Arnaldo Carvalho de Melo

    Pekka Enberg
     
  • The 'perf sched' command usage still showing 'trace' command instead of
    the 'script' command.

    Cc: Ingo Molnar
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20110809124651.GD2056@jolsa.brq.redhat.com
    Signed-off-by: Jiri Olsa
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • The session object is released prematurely when processing events for
    latency command. The session's thread objects are used within the
    output_lat_thread function.

    Runnning following commands:

    # perf sched record
    # perf sched latency

    the latter displays incorrect data and might cause access violation.

    Cc: Ingo Molnar
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1312837414-3819-1-git-send-email-jolsa@redhat.com
    Signed-off-by: Jiri Olsa
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     

09 Aug, 2011

1 commit

  • Just like we do already for perf.data files.

    Requested-by: Ingo Molnar
    Cc: Ben Hutchings
    Cc: Christian Ohm
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Jonathan Nieder
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/n/tip-qgokmxsmvppwpc5404qhyk7e@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

08 Aug, 2011

5 commits

  • Adding install-python_ext target to install python extension related
    files. Installation directory is governed by python distutils package
    and follows the DESTDIR variable settings.

    Also moving python extension build output into '$(O)python_ext_build'
    directory and making it configurable via PYTHON_EXTBUILD variable.

    Keeping the '$(O)python/perf.so' file, so it could be used for testing
    as of until now.

    Cc: Ingo Molnar
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20110722113307.GA1931@jolsa.brq.redhat.com
    Signed-off-by: Jiri Olsa
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • In addition to /etc/perfconfig and $HOME/.perfconfig, perf looks for
    configuration in the file ./config, imitating git which looks at
    $GIT_DIR/config. If ./config is not a perf configuration file, it
    fails, or worse, treats it as a configuration file and changes behavior
    in some unexpected way.

    "config" is not an unusual name for a file to be lying around and perf
    does not have a private directory dedicated for its own use, so let's
    just stop looking for configuration in the cwd. Callers needing
    context-sensitive configuration can use the PERF_CONFIG environment
    variable.

    Requested-by: Christian Ohm
    Cc: 632923@bugs.debian.org
    Cc: Ben Hutchings
    Cc: Christian Ohm
    Cc: Ingo Molnar
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20110805165838.GA7237@elie.gateway.2wire.net
    Signed-off-by: Jonathan Nieder
    Signed-off-by: Arnaldo Carvalho de Melo

    Jonathan Nieder
     
  • Use LIB_OBJS and BUILTIN_OBJS for .o files.

    LIB_FILE is already prefixed with OUTPUT.

    Cc: Ingo Molnar
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20110807083932.9C0E514C03B@msa103.auone-net.jp
    Signed-off-by: Kusanagi Kouichi
    Signed-off-by: Arnaldo Carvalho de Melo

    Kusanagi Kouichi
     
  • Looks to me like the :r modifier is not supported anymore, so remove it
    from the list of events. Without this fix 'perf lock record' doesn't
    work.

    Cc: Ingo Molnar
    Cc: Paul Mackerras
    Cc: Zhu Yanhai
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1312035232-9534-1-git-send-email-gaoyang.zyh@taobao.com
    Signed-off-by: Zhu Yanhai
    Signed-off-by: Arnaldo Carvalho de Melo

    Zhu Yanhai
     
  • perf will coredump if the user doesn't give the "-m" option in probe
    command, this patch fixes it.

    [root@localhost perf]# ./perf probe --add='PROBE'
    Segmentation fault (core dumped)

    Cc: Ingo Molnar
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1311602888-2389-1-git-send-email-bookjovi@gmail.com
    Signed-off-by: Jovi Zhang
    Signed-off-by: Arnaldo Carvalho de Melo

    Jovi Zhang
     

03 Aug, 2011

1 commit

  • So that we get a proper warning in the TUI in cases like:

    $ perf report --stdio -g fractal,0.5,caller --sort pid
    Selected -g but no callchain data. Did you call 'perf record' without -g?
    $

    The --stdio case is ok because it uses fprintf, ui__warning is needed to
    figure out if --stdio or --tui is being used.

    Cc: Arun Sharma
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Sam Liao
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/n/tip-ag9fz2wd17mbbfjsbznq1wms@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

26 Jul, 2011

1 commit

  • So those friggin "spurious" PERF_RECORD_MMAP events were actually a
    brain fart copy'n'paste error in the python binding, doh. I.e. they
    weren't MMAPs, just SAMPLEs.

    Fix it by providing routines for these events instead of using the MMAP
    ones.

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

    Arnaldo Carvalho de Melo
     

25 Jul, 2011

1 commit

  • To remove the last case of access to the FD() macro outside the library.

    Inspired by a patch by Borislav that moved the FD() macro to util.h, for
    namespace concerns I rather preferred to constrain it to ev{sel,list}.c.

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

    Arnaldo Carvalho de Melo
     

22 Jul, 2011

5 commits

  • The readlink() function doesn't append a null byte to buf. So we should
    zero out buf with zalloc(). Or we'll see sometimes error like this:

    [root@intel-s3e36-01]~# /usr/bin/perf buildid-cache -a /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko -v
    Adding f64ba8efd5f53c7ad332fc17db1d21de309038e1 /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko: Ok
    [root@intel-s3e36-01]~# /usr/bin/perf buildid-cache -r /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko -v
    Removing f64ba8efd5f53c7ad332fc17db1d21de309038e1 /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko: FAIL
    /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko wasn't in the cache

    The change in build_id_cache__add_s() is a defense.

    Tested-by: Jiri Olsa
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/20110718031314.GA5802@hpt.nay.redhat.com
    Signed-off-by: Han Pingtian
    Signed-off-by: Arnaldo Carvalho de Melo

    Han Pingtian
     
  • In commit a8b0ca17b80e ("perf: Remove the nmi parameter from the
    swevent and overflow interface") one site was overlooked.

    Signed-off-by: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20110708173442.GB31972@e102144-lin.cambridge.arm.com
    Signed-off-by: Ingo Molnar

    Will Deacon
     
  • copy_from_user_nmi() is used in oprofile and perf. Moving it to other
    library functions like copy_from_user(). As this is x86 code for 32
    and 64 bits, create a new file usercopy.c for unified code.

    Signed-off-by: Robert Richter
    Signed-off-by: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20110607172413.GJ20052@erda.amd.com
    Signed-off-by: Ingo Molnar

    Robert Richter
     
  • PMU type id can be allocated dynamically, so perf_event_attr::type check
    when copying attribute from userspace to kernel is not valid.

    Signed-off-by: Lin Ming
    Cc: Robert Richter
    Signed-off-by: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1309421396-17438-4-git-send-email-ming.m.lin@intel.com
    Signed-off-by: Ingo Molnar

    Lin Ming
     
  • This patch:

    - fixes typos in comments and clarifies the text
    - renames obscure p4_event_alias::original and ::alter members to
    ::original and ::alternative as appropriate
    - drops parenthesis from the return of p4_get_alias_event()

    No functional changes.

    Reported-by: Ingo Molnar
    Signed-off-by: Cyrill Gorcunov
    Link: http://lkml.kernel.org/r/20110721160625.GX7492@sun
    Signed-off-by: Ingo Molnar

    Cyrill Gorcunov
     

21 Jul, 2011

8 commits

  • Use preset debugfs path instead of hardcoded one.

    Signed-off-by: Jiri Olsa
    Cc: acme@redhat.com
    Cc: a.p.zijlstra@chello.nl
    Cc: paulus@samba.org
    Link: http://lkml.kernel.org/r/1310635534-4013-4-git-send-email-jolsa@redhat.com
    Signed-off-by: Ingo Molnar

    Jiri Olsa
     
  • Adding builtin test for parse_events function, which is
    responsible for parsing/processing "-e" option for
    stat/top/record commands.

    This new test will run within the builtin test command suite
    (perf test).

    One or several tests were added for each type of event.
    More tests could be added easily if needed.

    Signed-off-by: Jiri Olsa
    Cc: acme@redhat.com
    Cc: a.p.zijlstra@chello.nl
    Cc: paulus@samba.org
    Link: http://lkml.kernel.org/r/1310635534-4013-3-git-send-email-jolsa@redhat.com
    Signed-off-by: Ingo Molnar

    Jiri Olsa
     
  • Moving out the option parameter from parse_events function,
    and adding new parse_events_option function instead.

    The option parameter is used only to carry "struct perf_evlist"
    pointer for chaining new events. Putting it away, enable us
    to call parse_events from other places without using the
    option parameter.

    Signed-off-by: Jiri Olsa
    Cc: acme@redhat.com
    Cc: a.p.zijlstra@chello.nl
    Cc: paulus@samba.org
    Link: http://lkml.kernel.org/r/1310635534-4013-2-git-send-email-jolsa@redhat.com
    Signed-off-by: Ingo Molnar

    Jiri Olsa
     
  • Non-callchain path is using al.addr which prints as:
    openssl 14564 17672.003587: 7862d _x86_64_AES_encrypt_compact

    This should be sample->ip to print as:
    openssl 14564 17672.003587: 3f7867862d _x86_64_AES_encrypt_compact

    Signed-off-by: David Ahern
    Acked-by: Frederic Weisbecker
    Cc: acme@ghostprotocols.net
    Cc: peterz@infradead.org
    Cc: paulus@samba.org
    Link: http://lkml.kernel.org/r/1306768587-15376-1-git-send-email-dsahern@gmail.com
    Signed-off-by: Ingo Molnar

    David Ahern
     
  • The perf_event_attr struct has two __u32's at the top and
    they need to be swapped individually.

    With this change I was able to analyze a perf.data collected in a
    32-bit PPC VM on an x86 system. I tested both 32-bit and 64-bit
    binaries for the Intel analysis side; both read the PPC perf.data
    file correctly.

    -v2:
    - changed the existing perf_event__attr_swap() to swap only elements
    of perf_event_attr and exported it for use in swapping the
    attributes in the file header
    - updated swap_ops used for processing events

    Signed-off-by: David Ahern
    Acked-by: Frederic Weisbecker
    Cc: acme@ghostprotocols.net
    Cc: peterz@infradead.org
    Cc: paulus@samba.org
    Cc:
    Link: http://lkml.kernel.org/r/1310754849-12474-1-git-send-email-dsahern@gmail.com
    Signed-off-by: Ingo Molnar

    David Ahern
     
  • Add "node" as a simple alias for NODE cache events.

    The addition of NODE cache events broke the parse_alias
    function, so any mismatched event caused the segfault, like:

    # ./perf stat -e krava ls

    The hw_cache/hw_cache_op/hw_cache_result arrays needs to follow
    PERF_COUNT_HW_CACHE_*MAX enums. Adding those MAXs to be size
    of those arrays, so possible ommision in future wil not lead to
    segfault.

    Adding read/write/prefetch as allowed operations for node cache
    event.

    Signed-off-by: Jiri Olsa
    Acked-by: Peter Zijlstra
    Cc: acme@redhat.com
    Link: http://lkml.kernel.org/r/20110713205818.GB7827@jolsa.brq.redhat.com
    Signed-off-by: Ingo Molnar

    Jiri Olsa
     
  • …stedt/linux-2.6-trace into perf/core

    Ingo Molnar
     
  • Merge reason: pick up the latest fixes - they won't make v3.0.

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

16 Jul, 2011

11 commits

  • Support adding probes on offline kernel modules. This enables
    perf-probe to trace kernel-module init functions via perf-probe.
    If user gives the path of module with -m option, perf-probe
    expects the module is offline.
    This feature works with --add, --funcs, and --vars.

    E.g)
    # perf probe -m /lib/modules/`uname -r`/kernel/fs/btrfs/btrfs.ko \
    -a "extent_io_init:5 extent_state_cache"
    Add new events:
    probe:extent_io_init (on extent_io_init:5 with extent_state_cache)
    probe:extent_io_init_1 (on extent_io_init:5 with extent_state_cache)

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

    perf record -e probe:extent_io_init_1 -aR sleep 1

    Signed-off-by: Masami Hiramatsu
    Cc: Peter Zijlstra
    Cc: Frederic Weisbecker
    Cc: Paul Mackerras
    Cc: Ingo Molnar
    Cc: Arnaldo Carvalho de Melo
    Link: http://lkml.kernel.org/r/20110627072751.6528.10230.stgit@fedora15
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • Add probed module name and ":" in front of function name
    if -m module option is given. In the result, the symbol
    name passed to kprobe-tracer becomes MODULE:FUNCTION,
    so that kallsyms can solve it as a symbol in the module
    correctly.

    Signed-off-by: Masami Hiramatsu
    Cc: Peter Zijlstra
    Cc: Frederic Weisbecker
    Cc: Paul Mackerras
    Cc: Ingo Molnar
    Cc: Arnaldo Carvalho de Melo
    Link: http://lkml.kernel.org/r/20110627072745.6528.26416.stgit@fedora15
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • Introduce debuginfo to encapsulate dwarf information.
    This new object allows us to reuse and expand debuginfo easily.

    Signed-off-by: Masami Hiramatsu
    Cc: Peter Zijlstra
    Cc: Frederic Weisbecker
    Cc: Paul Mackerras
    Cc: Ingo Molnar
    Cc: Arnaldo Carvalho de Melo
    Link: http://lkml.kernel.org/r/20110627072739.6528.12438.stgit@fedora15
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • Move dwarf library related routines to dwarf-aux.{c,h}.
    This includes several minor changes.
    - Add simple documents for each API.
    - Rename die_find_real_subprogram() to die_find_realfunc()
    - Rename line_walk_handler_t to line_walk_callback_t.
    - Minor cleanups.

    Signed-off-by: Masami Hiramatsu
    Cc: Peter Zijlstra
    Cc: Frederic Weisbecker
    Cc: Paul Mackerras
    Cc: Ingo Molnar
    Cc: Arnaldo Carvalho de Melo
    Link: http://lkml.kernel.org/r/20110627072727.6528.57647.stgit@fedora15
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • Since there are dwarf_bitsize, dwarf_bitoffset and dwarf_bytesize
    defined in libdw, we don't need die_get_bit_size, die_get_bit_offset
    and die_get_byte_size anymore.

    Signed-off-by: Masami Hiramatsu
    Cc: Peter Zijlstra
    Cc: Frederic Weisbecker
    Cc: Paul Mackerras
    Cc: Ingo Molnar
    Cc: Arnaldo Carvalho de Melo
    Link: http://lkml.kernel.org/r/20110627072721.6528.2747.stgit@fedora15
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • Since strtailcmp() is enough generic, it should be defined in string.c.

    Signed-off-by: Masami Hiramatsu
    Cc: Peter Zijlstra
    Cc: Frederic Weisbecker
    Cc: Paul Mackerras
    Cc: Ingo Molnar
    Cc: Arnaldo Carvalho de Melo
    Link: http://lkml.kernel.org/r/20110627072715.6528.10677.stgit@fedora15
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • Since die_find/walk* callbacks use DIE_FIND_CB_FOUND for
    both of failed and found cases, it should be "END"
    instead "FOUND" for avoiding confusion.

    Signed-off-by: Masami Hiramatsu
    Reported-by: Arnaldo Carvalho de Melo
    Cc: Peter Zijlstra
    Cc: Frederic Weisbecker
    Cc: Paul Mackerras
    Cc: Ingo Molnar
    Link: http://lkml.kernel.org/r/20110627072709.6528.45706.stgit@fedora15
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • Since the address of a module-local variable can only be
    solved after the target module is loaded, the symbol
    fetch-argument should be updated when loading target
    module.

    Signed-off-by: Masami Hiramatsu
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: Frederic Weisbecker
    Cc: Arnaldo Carvalho de Melo
    Link: http://lkml.kernel.org/r/20110627072703.6528.75042.stgit@fedora15
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • To support probing module init functions, kprobe-tracer allows
    user to define a probe on non-existed function when it is given
    with a module name. This also enables user to set a probe on
    a function on a specific module, even if a same name (but different)
    function is locally defined in another module.

    The module name must be in the front of function name and separated
    by a ':'. e.g. btrfs:btrfs_init_sysfs

    Signed-off-by: Masami Hiramatsu
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: Frederic Weisbecker
    Cc: Arnaldo Carvalho de Melo
    Link: http://lkml.kernel.org/r/20110627072656.6528.89970.stgit@fedora15
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • Return -ENOENT if probe point doesn't exist, but still returns
    -EINVAL if both of kprobe->addr and kprobe->symbol_name are
    specified or both are not specified.

    Acked-by: Ananth N Mavinakayanahalli
    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Arnaldo Carvalho de Melo
    Cc: Ingo Molnar
    Cc: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: Anil S Keshavamurthy
    Cc: "David S. Miller"
    Link: http://lkml.kernel.org/r/20110627072650.6528.67329.stgit@fedora15
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     
  • Merge redundant enable/disable functions into enable_trace_probe()
    and disable_trace_probe().

    Signed-off-by: Masami Hiramatsu
    Cc: Arnaldo Carvalho de Melo
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: yrl.pp-manager.tt@hitachi.com
    Cc: Frederic Weisbecker
    Cc: Ingo Molnar
    Link: http://lkml.kernel.org/r/20110627072644.6528.26910.stgit@fedora15

    [ converted kprobe selftest to use enable_trace_probe ]

    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     

15 Jul, 2011

1 commit

  • Enabling function tracer to trace all functions, then load a module and
    then disable function tracing will cause ftrace to fail.

    This can also happen by enabling function tracing on the command line:

    ftrace=function

    and during boot up, modules are loaded, then you disable function tracing
    with 'echo nop > current_tracer' you will trigger a bug in ftrace that
    will shut itself down.

    The reason is, the new ftrace code keeps ref counts of all ftrace_ops that
    are registered for tracing. When one or more ftrace_ops are registered,
    all the records that represent the functions that the ftrace_ops will
    trace have a ref count incremented. If this ref count is not zero,
    when the code modification runs, that function will be enabled for tracing.
    If the ref count is zero, that function will be disabled from tracing.

    To make sure the accounting was working, FTRACE_WARN_ON()s were added
    to updating of the ref counts.

    If the ref count hits its max (> 2^30 ftrace_ops added), or if
    the ref count goes below zero, a FTRACE_WARN_ON() is triggered which
    disables all modification of code.

    Since it is common for ftrace_ops to trace all functions in the kernel,
    instead of creating > 20,000 hash items for the ftrace_ops, the hash
    count is just set to zero, and it represents that the ftrace_ops is
    to trace all functions. This is where the issues arrise.

    If you enable function tracing to trace all functions, and then add
    a module, the modules function records do not get the ref count updated.
    When the function tracer is disabled, all function records ref counts
    are subtracted. Since the modules never had their ref counts incremented,
    they go below zero and the FTRACE_WARN_ON() is triggered.

    The solution to this is rather simple. When modules are loaded, and
    their functions are added to the the ftrace pool, look to see if any
    ftrace_ops are registered that trace all functions. And for those,
    update the ref count for the module function records.

    Reported-by: Thomas Gleixner
    Signed-off-by: Steven Rostedt

    Steven Rostedt