30 May, 2016

1 commit

  • Move the get_main_thread function from db-export.c to thread.c so that
    it can be used elsewhere.

    Signed-off-by: Andi Kleen
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/1464051145-19968-2-git-send-email-andi@firstfloor.org
    [ Removed leftover bits from db-export.h ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Andi Kleen
     

20 May, 2016

1 commit

  • We cannot limit processing stacks from the current value of the sysctl,
    as we may be processing perf.data files, possibly from other machines.

    Instead use the old PERF_MAX_STACK_DEPTH, the sysctl default, that can
    be overriden using --max-stack or equivalent.

    Cc: Adrian Hunter
    Cc: Alexander Shishkin
    Cc: Alexei Starovoitov
    Cc: Brendan Gregg
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: He Kuang
    Cc: Jiri Olsa
    Cc: Masami Hiramatsu
    Cc: Milian Wolff
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Cc: Wang Nan
    Cc: Zefan Li
    Fixes: 4cb93446c587 ("perf tools: Set the maximum allowed stack from /proc/sys/kernel/perf_event_max_stack")
    Link: http://lkml.kernel.org/n/tip-eqeutsr7n7wy0c36z24ytvii@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

11 May, 2016

3 commits

  • When an IP with an unresolved symbol occurs in the callchain more than
    once (ie. recursion), then duplicate symbols can be created because
    the callchain nodes are never updated after they are first created.

    To fix this issue we call dso__find_symbol whenever we encounter a NULL
    symbol, in case we already added a symbol at that IP since we started
    traversing the callchain.

    This change prevents duplicate symbols from being exported when duplicate
    IPs are present in the callchain.

    Signed-off-by: Chris Phlipot
    Cc: Adrian Hunter
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1462937209-6032-5-git-send-email-cphlipot0@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Chris Phlipot
     
  • Remove the call to map_ip() to adjust al.addr, because it has already
    been called when assembling the callchain, in:

    thread__resolve_callchain_sample(perf_sample)
    add_callchain_ip(ip = perf_sample->callchain->ips[j])
    thread__find_addr_location(addr = ip)
    thread__find_addr_map(addr) {
    al->addr = addr
    if (al->map)
    al->addr = al->map->map_ip(al->map, al->addr);
    }

    Calling it a second time can result in incorrect addresses being used.
    This can have effects such as duplicate symbols being created and
    exported.

    Signed-off-by: Chris Phlipot
    Cc: Adrian Hunter
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1462937209-6032-4-git-send-email-cphlipot0@gmail.com
    [ Show the callchain where it is done, to help reviewing this change down the line ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Chris Phlipot
     
  • Use the dso__insert_symbol function instead of symbols__insert() in
    order to properly update the dso symbol cache.

    If the cache is not updated, then duplicate symbols can be
    unintentionally created, inserted, and exported.

    This change prevents duplicate symbols from being exported due to
    dso__find_symbol() using a stale symbol cache.

    Signed-off-by: Chris Phlipot
    Cc: Adrian Hunter
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1462937209-6032-3-git-send-email-cphlipot0@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Chris Phlipot
     

07 May, 2016

3 commits

  • The exported sample now contains a reference to the call_path_id that
    represents its callchain.

    While callchains themselves are nice to have, being able to associate
    them with samples makes them much more useful, and can allow for such
    things as determining how much cumulative time is spent in a particular
    function. This information is normally possible to get from the call
    return processor. However, when doing normal sampling, call/return
    information is not available, thus necessitating the need for
    associating samples directly with call paths.

    This commit include changes to db-export layer to make this information
    available for subsequent patches in this change set, but by itself, does
    not make any changes visible to the user.

    Signed-off-by: Chris Phlipot
    Acked-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1461831551-12213-5-git-send-email-cphlipot0@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Chris Phlipot
     
  • This change enables the db export api to export callchains. This is
    accomplished by adding callchains obtained from samples to the
    call_path_root structure and exporting them via the current call path
    export API.

    While the current API does support exporting call paths, this is not
    supported when sampling. This commit addresses that missing feature by
    allowing the export of call paths when callchains are present in
    samples.

    Summary:

    - This feature is activated by initializing the call_path_root member
    inside the db_export structure to a non-null value.

    - Callchains are resolved with thread__resolve_callchain() and then stored
    and exported by adding a call path under call path root.
    - Symbol and DSO for each callchain node are exported via db_ids_from_al()

    This commit puts in place infrastructure to be used by subsequent commits,
    and by itself, does not introduce any user-visible changes.

    Signed-off-by: Chris Phlipot
    Acked-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1461831551-12213-4-git-send-email-cphlipot0@gmail.com
    [ Made adjustments suggested by Adrian Hunter, see thread via this cset's Link: tag ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Chris Phlipot
     
  • Move the call path handling code out of thread-stack.c and
    thread-stack.h to allow other components that are not part of
    thread-stack to create call paths.

    Summary:

    - Create call-path.c and call-path.h and add them to the build.

    - Move all call path related code out of thread-stack.c and thread-stack.h
    and into call-path.c and call-path.h.

    - A small subset of structures and functions are now visible through
    call-path.h, which is required for thread-stack.c to continue to
    compile.

    This change is a prerequisite for subsequent patches in this change set
    and by itself contains no user-visible changes.

    Signed-off-by: Chris Phlipot
    Acked-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1461831551-12213-3-git-send-email-cphlipot0@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Chris Phlipot
     

23 Mar, 2016

1 commit

  • Since none of the perf_event fields are used anymore, just the
    perf_sample ones, and since this resolves to (map, symbol) from data
    structures within struct thread, rename it to thread__resolve and make
    the argument ordering similar to the one in machine__resolve().

    Cc: Adrian Hunter
    Cc: Hemant Kumar
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Naveen N. Rao
    Cc: Ravi Bangoria
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-2b33hs9bp550tezzlhl4kejh@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

29 May, 2015

1 commit

  • Thread ref-counting was not done for get_main_thread() meaning that
    there was a thread__get() from machine__find_thread() that was not being
    paired with thread__put(). Fix that.

    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Link: http://lkml.kernel.org/r/1432906425-9911-2-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

09 May, 2015

1 commit

  • In addition to using refcounts for the struct thread lifetime
    management, we need to protect access to machine->threads from
    concurrent access.

    That happens in 'perf top', where a thread processes events, inserting
    and deleting entries from that rb_tree while another thread decays
    hist_entries, that end up dropping references and ultimately deleting
    threads from the rb_tree and releasing its resources when no further
    hist_entry (or other data structures, like in 'perf sched') references
    it.

    So the rule is the same for refcounts + protected trees in the kernel,
    get the tree lock, find object, bump the refcount, drop the tree lock,
    return, use object, drop the refcount if no more use of it is needed,
    keep it if storing it in some other data structure, drop when releasing
    that data structure.

    I.e. pair "t = machine__find(new)_thread()" with a "thread__put(t)", and
    "perf_event__preprocess_sample(&al)" with "addr_location__put(&al)".

    The addr_location__put() one is because as we return references to
    several data structures, we may end up adding more reference counting
    for the other data structures and then we'll drop it at
    addr_location__put() time.

    Acked-by: David Ahern
    Cc: Adrian Hunter
    Cc: Borislav Petkov
    Cc: Don Zickus
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/n/tip-bs9rt4n0jw3hi9f3zxyy3xln@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

03 Apr, 2015

2 commits

  • As it comes from address_location->thread, that is already stored as
    export_sample->al, where the thread can be obtained.

    Cc: Adrian Hunter
    Cc: Borislav Petkov
    Cc: David Ahern
    Cc: Don Zickus
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/20150402141542.GA9630@kernel.org
    Link: http://lkml.kernel.org/n/tip-bzotbl4epoztw0jd6sm2stpf@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • As it is available via another parameter, address_location->thread.

    Acked-by: Adrian Hunter
    Cc: Borislav Petkov
    Cc: David Ahern
    Cc: Don Zickus
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Stephane Eranian
    Link: lkml.kernel.org/r/551D08F8.3040706@intel.com
    Link: http://lkml.kernel.org/n/tip-6dbn0tcm9hyv92g7h3zj2dbt@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

04 Nov, 2014

3 commits

  • Tracing for a workload begins before the comm event is seen, which
    results in the initial comm having a string of the form ":" (e.g.
    ":12345").

    In order to export the correct string, defer the export until the new
    script 'flush' callback.

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

    Adrian Hunter
     
  • Make it possible for the database export API to use the enhanced thread
    stack and export detailed information about paired calls and returns.

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

    Adrian Hunter
     
  • Add the ability to export branch types through the database export
    facility.

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

    Adrian Hunter
     

29 Oct, 2014

1 commit

  • This patch introduces an abstraction for exporting sample data in a
    database-friendly way. The abstraction does not implement the actual
    output. A subsequent patch takes this facility into use for extending
    the script interface.

    The abstraction is needed because static data like symbols, dsos, comms
    etc need to be exported only once. That means allocating them a unique
    identifier and recording it on each structure. The member 'db_id' is
    used for that. 'db_id' is just a 64-bit sequence number.

    Exporting centres around the db_export__sample() function which exports
    the associated data structures if they have not yet been allocated a
    db_id.

    Signed-off-by: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1414061124-26830-6-git-send-email-adrian.hunter@intel.com
    [ committer note: Stash db_id using symbol_conf.priv_size + symbol__priv() and foo->priv areas ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter