04 Mar, 2010

2 commits


25 Feb, 2010

1 commit

  • Add base support for Python scripting to perf trace.

    Signed-off-by: Tom Zanussi
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Keiichi KII
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Tom Zanussi
     

24 Feb, 2010

1 commit

  • 'perf trace -s list' prints a list of the supported scripting
    languages. One problem with it is that it falls through and prints
    the trace as well. The use of 'list' for this also makes it easy to
    confuse with 'perf trace -l', used for listing available scripts. So
    change 'perf trace -s list' to 'perf trace -s lang' and fixes the
    fall-through problem.

    Signed-off-by: Tom Zanussi
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Keiichi KII
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Tom Zanussi
     

27 Jan, 2010

1 commit


16 Jan, 2010

1 commit

  • Since they can come from another architecture with bigger
    pointers, i.e. processing a 64-bit perf.data on a 32-bit arch.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

28 Dec, 2009

3 commits


19 Dec, 2009

1 commit

  • Fixing this:

    [acme@doppio linux-2.6-tip]$ perf diff --hell
    Error: unknown option `hell'

    usage: perf diff [] [old_file] [new_file]
    Segmentation fault
    [acme@doppio linux-2.6-tip]$

    Also go over the other such arrays to check if they all were OK,
    they are, but there were some minor changes to do like making
    one static and renaming another to match the command it refers
    to.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frederic Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

16 Dec, 2009

2 commits


15 Dec, 2009

5 commits

  • Allow scripts to be recorded/executed by simply specifying the
    script root name (the script name minus extension) along with
    'record' or 'report' to 'perf trace'.

    The script names shown by 'perf trace -l' can be directly used
    to run the command-line contained within the corresponding
    '-record' and '-report' versions of scripts in the scripts/*/bin
    directories.

    For example, to record the trace data needed to run the
    wakeup-latency.pl script, the user can easily find the name of
    the corresponding script from the script list and invoke it
    using 'perf trace record', without having to remember the
    details of how to do the same thing using the lower-level perf
    trace command-line options:

    root@tropicana:~# perf trace -l
    List of available trace scripts:
    workqueue-stats workqueue stats (ins/exe/create/destroy)
    wakeup-latency system-wide min/max/avg wakeup latency
    rw-by-file r/w activity for a program, by file
    check-perf-trace useless but exhaustive test script
    rw-by-pid system-wide r/w activity

    root@tropicana:~# perf trace record wakeup-latency
    ^C[ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.296 MB perf.data (~12931
    samples) ]

    To run the wakeup-latency.pl script using the captured data,
    change 'record' to 'report' in the command-line:

    root@tropicana:~# perf trace report wakeup-latency

    wakeup_latency stats:

    total_wakeups: 65
    avg_wakeup_latency (ns): 22417
    min_wakeup_latency (ns): 3470
    max_wakeup_latency (ns): 223311

    perf trace Perl script stopped

    If the script takes options, thay can be simply added to the end
    of the 'report' invocation:

    root@tropicana:~# perf trace record rw-by-file
    ^C[ perf record: Woken up 2 times to write data ]
    [ perf record: Captured and wrote 0.782 MB perf.data (~34171
    samples) ]

    root@tropicana:~# perf trace report rw-by-file perf

    file read counts for perf:

    fd # reads bytes_requested
    ------ ---------- -----------
    122 1934 1980416
    120 1 32

    file write counts for perf:

    fd # writes bytes_written
    ------ ---------- -----------
    3 4006 280568

    perf trace Perl script stopped

    Signed-off-by: Tom Zanussi
    Cc: fweisbec@gmail.com
    Cc: rostedt@goodmis.org
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Tom Zanussi
     
  • Lists the available perf trace scripts, one per line e.g.:

    root@tropicana:~# perf trace -l
    List of available trace scripts:
    workqueue-stats workqueue stats (ins/exe/create/destroy)
    wakeup-latency system-wide min/max/avg wakeup latency
    rw-by-file r/w activity for a program, by file
    check-perf-trace useless but exhaustive test script
    rw-by-pid system-wide r/w activity

    To be consistent with the other listing options in perf, the
    current latency trace option was changed to '-L', and '-l' is
    now used to access the script listing as:

    To create the list, it searches each scripts/*/bin directory for
    files ending with "-report" and reads information found in
    certain comment lines contained in those shell scripts:

    - if the comment line starts with "description:", the rest of the
    line is used as a 'half-line' description. To keep each line in
    the list to a single line, the description should be limited to 40
    characters (the rest of the line contains the script name and
    args)

    - if the comment line starts with "args:", the rest of the line
    names the args the script supports. Required args should be
    surrounded by <> brackets, optional args by [] brackets.

    The current scripts in scripts/perl/bin have also been updated
    with description: and args: comments.

    Signed-off-by: Tom Zanussi
    Cc: fweisbec@gmail.com
    Cc: rostedt@goodmis.org
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Tom Zanussi
     
  • One oversight of the original scripting_ops patch was a lack of
    support for passing args to handler scripts. This adds
    argc/argv to the start_script() scripting_op, and changes the
    rw-by-file script to take 'comm' arg rather than the 'perf'
    value currently hard-coded. It also takes the opportunity to do
    some related minor cleanup.

    Signed-off-by: Tom Zanussi
    Cc: fweisbec@gmail.com
    Cc: rostedt@goodmis.org
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Tom Zanussi
     
  • Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • All tools had copies, and perf diff would have to specify a
    sample_type_check method just for copying it.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

14 Dec, 2009

7 commits


12 Dec, 2009

1 commit

  • That does all the initialization boilerplate, opening the file,
    reading the header, checking if it is valid, etc.

    And that will as well have the threads list, kmap (now) global
    variable, etc, so that we can handle two (or more) perf.data files
    describing sessions to compare.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

07 Dec, 2009

1 commit

  • Currently, sample event data is parsed for each commands, and it
    is assuming that the data is not including other data. (E.g.
    timechart, trace, etc. can't parse the event if it has
    PERF_SAMPLE_CALLCHAIN)

    So, even if we record the superset data for multiple commands at
    a time, commands can't parse. etc.

    To fix it, this makes common sample event parser, and use it to
    parse sample event correctly. (PERF_SAMPLE_READ is unsupported
    for now though, it seems to be not using.)

    Signed-off-by: OGAWA Hirofumi
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    Cc: Frederic Weisbecker
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    OGAWA Hirofumi
     

28 Nov, 2009

4 commits

  • Cc: Peter Zijlstra
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    Cc: Frederic Weisbecker
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Implement trace_scripting_ops to make Perl a supported perf
    trace scripting language.

    Additionally adds code that allows Perl trace scripts to access
    the 'flag' and 'symbolic' (__print_flags(), __print_symbolic())
    field information parsed from the trace format files.

    Also adds the Perl implementation of the generate_script()
    trace_scripting_op, which creates a ready-to-run perf trace Perl
    script based on existing trace data. Scripts generated by this
    implementation print out all the fields for each event mentioned
    in perf.data (and will detect and generate the proper scripting
    code for 'flag' and 'symbolic' fields), and will additionally
    generate handlers for the special 'trace_unhandled',
    'trace_begin' and 'trace_end' handlers. Script authors can
    simply remove the printing code to implement their own custom
    event handling.

    Signed-off-by: Tom Zanussi
    Cc: fweisbec@gmail.com
    Cc: rostedt@goodmis.org
    Cc: anton@samba.org
    Cc: hch@infradead.org
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Tom Zanussi
     
  • Adds an interface, scripting_ops, that when implemented for a
    particular scripting language enables built-in support for trace
    stream processing using that language.

    The interface is designed to enable full-fledged language
    interpreters to be embedded inside the perf executable and
    thereby make the full capabilities of the supported languages
    available for trace processing.

    See below for details on the interface.

    This patch also adds a couple command-line options to 'perf
    trace':

    The -s option option is used to specify the script to be run.
    Script names that can be used with -s take the form:

    [language spec:]scriptname[.ext]

    Scripting languages register a set of 'language specs' that can
    be used to specify scripts for the registered languages. The
    specs can be used either as prefixes or extensions.

    If [language spec:] is used, the script is taken as a script of
    the matching language regardless of any extension it might have.
    If [language spec:] is not used, [.ext] is used to look up the
    language it corresponds to. Language specs are case
    insensitive.

    e.g. Perl scripts can be specified in the following ways:

    Perl:scriptname
    pl:scriptname.py # extension ignored
    PL:scriptname
    scriptname.pl
    scriptname.perl

    The -g [language spec] option gives users an easy starting point
    for writing scripts in the specified language. Scripting
    support for a particular language can implement a
    generate_script() scripting op that outputs an empty (or
    near-empty) set of handlers for all the events contained in a
    given perf.data trace file - this option gives users a direct
    way to access that.

    Adding support for a scripting language
    ---------------------------------------

    The main thing that needs to be done do add support for a new
    language is to implement the scripting_ops interface:

    It consists of the following four functions:

    start_script()
    stop_script()
    process_event()
    generate_script()

    start_script() is called before any events are processed, and is
    meant to give the scripting language support an opportunity to
    set things up to receive events e.g. create and initialize an
    instance of a language interpreter.

    stop_script() is called after all events are processed, and is
    meant to give the scripting language support an opportunity to
    clean up e.g. destroy the interpreter instance, etc.

    process_event() is called once for each event and takes as its
    main parameter a pointer to the binary trace event record to be
    processed. The implementation is responsible for picking out the
    binary fields from the event record and sending them to the
    script handler function associated with that event e.g. a
    function derived from the event name it's meant to handle e.g.
    'sched::sched_switch()'. The 'format' information for trace
    events can be used to parse the binary data and map it into a
    form usable by a given scripting language; see the Perl
    implemention in subsequent patches for one possible way to
    leverage the existing trace format parsing code in perf and map
    that info into specific scripting language types.

    generate_script() should generate a ready-to-run script for the
    current set of events in the trace, preferably with bodies that
    print out every field for each event. Again, look at the Perl
    implementation for clues as to how that can be done. This is an
    optional, but very useful op.

    Support for a given language should also add a language-specific
    setup function and call it from setup_scripting(). The
    language-specific setup function associates the the scripting
    ops for that language with one or more 'language specifiers'
    (see below) using script_spec_register(). When a script name is
    specified on the command line, the scripting ops associated with
    the specified language are used to instantiate and use the
    appropriate interpreter to process the trace stream.

    In general, it should be relatively easy to add support for a
    new language, especially if the language implementation supports
    an interface allowing an interpreter to be 'embedded' inside
    another program (in this case the containing program will be
    'perf trace'). If so, it should be relatively straightforward to
    translate trace events into invocations of user-defined script
    functions where e.g. the function name corresponds to the event
    type and the function parameters correspond to the event fields.
    The event and field type information exported by the event
    tracing infrastructure (via the event 'format' files) should be
    enough to parse and send any piece of trace data to the user
    script. The easiest way to see how this can be done would be to
    look at the Perl implementation contained in
    perf/util/trace-event-perl.c/.h.

    There are a couple of other things that aren't covered by the
    scripting_ops or setup interface and are technically optional,
    but should be implemented if possible. One of these is support
    for 'flag' and 'symbolic' fields e.g. being able to use more
    human-readable values such as 'GFP_KERNEL' or
    HI/BLOCK_IOPOLL/TASKLET in place of raw flag values. See the
    Perl implementation to see how this can be done. The other thing
    is support for 'calling back' into the perf executable to access
    e.g. uncommon fields not passed by default into handler
    functions, or any metadata the implementation might want to make
    available to users via the language interface. Again, see the
    Perl implementation for examples.

    Signed-off-by: Tom Zanussi
    Cc: fweisbec@gmail.com
    Cc: rostedt@goodmis.org
    Cc: anton@samba.org
    Cc: hch@infradead.org
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Tom Zanussi
     
  • While implementing event__preprocess_sample, that will do all of
    the symbol lookup in one convenient function, I noticed that
    util/process_event.[ch] were not being used at all, then started
    looking if there were other functions that could be shared
    and...

    All those functions really don't need to receive offset + head,
    the only thing they did was common to all of them, so do it at
    one place instead.

    Stats about number of each type of event processed now is done
    in a central place.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: John Kacur
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

24 Nov, 2009

2 commits

  • And also express its configuration toggles via a struct.

    Now all one has to do is to call symbol__init(NULL) if the
    defaults are OK, or pass a struct symbol_conf pointer with the
    desired configuration.

    If a tool uses kernel_maps__find_symbol() to look at the kernel
    and modules mappings for a symbol but didn't call symbol__init()
    first, that will generate a one time warning too, alerting the
    subcommand developer that symbol__init() must be called.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • Now that we can check the buildid to see if it really matches,
    this can be done safely:

    vmlinux
    /boot/vmlinux
    /boot/vmlinux-
    /lib/modules//build/vmlinux
    /usr/lib/debug/lib/modules/%s/vmlinux

    More can be added - if you know about distros that put the
    vmlinux somewhere else please let us know.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

02 Nov, 2009

1 commit

  • Before we were storing this in the DSO, but in fact this is a
    property of the 'symbol' class, not something that will vary
    among DSOs, so move it to a global variable and initialize it
    using the existing symbol__init routine.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Mike Galbraith
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

23 Oct, 2009

1 commit

  • We were using eprintf in some places, that looks at a global
    'verbose' level, and at other places passing a 'v' parameter to
    specify the verbosity level, unify it by introducing
    pr_{err,warning,debug,etc}, just like in the kernel.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Mike Galbraith
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

17 Oct, 2009

1 commit

  • In each case, if the NULL test on thread is needed, then the
    dereference should be after the NULL test.

    A simplified version of the semantic match that detects this
    problem is as follows (http://coccinelle.lip6.fr/):

    //
    @match exists@
    expression x, E;
    identifier fld;
    @@

    * x->fld
    ... when != \(x = E\|&x\)
    * x == NULL
    //

    Signed-off-by: Julia Lawall
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Julia Lawall
     

15 Oct, 2009

1 commit

  • Add the irqs disabled, preemption count, need resched, and other
    info that is shown in the latency format of ftrace.

    # perf trace -l
    perf-16457 2..s2. 53636.260344: kmem_cache_free: call_site=ffffffff811198f
    perf-16457 2..s2. 53636.264330: kmem_cache_free: call_site=ffffffff811198f
    perf-16457 2d.s4. 53636.300006: kmem_cache_free: call_site=ffffffff810d889

    Signed-off-by: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Frederic Weisbecker
    Cc: Arnaldo Carvalho de Melo
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Steven Rostedt
     

13 Oct, 2009

1 commit


08 Oct, 2009

1 commit

  • This librarizes the perf.data file mapping and handling in various
    perf tools, roughly reducing the amount of code and fixing the
    places that mmap from beginning of the file whereas we want to mmap
    from the beginning of the data, leading to page fault because the
    mmap window is too small since the trace info are written in the
    file too.

    TODO:

    - convert perf timechart too

    Signed-off-by: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Arjan van de Ven
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     

07 Oct, 2009

2 commits

  • This drops the trace.info file and move its contents into the
    common perf.data file.

    This is done by creating a new trace_info section into this file. A
    user of perf headers needs to call perf_header__set_trace_info() to
    save the trace meta informations into the perf.data file.

    A file created by perf after his patch is unsupported by previous
    version because the size of the headers have increased.

    That said, it's two new fields that have been added in the end of
    the headers, and those could be ignored by previous versions if
    they just handled the dynamic header size and then ignore the
    unknow part. The offsets guarantee the compatibility. We'll do a
    -stable fix for that.

    But current previous versions handle the header size using its
    static size, not dynamic, then it's not backward compatible with
    trace records.

    Signed-off-by: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Paul Mackerras
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     
  • Currently, we are mapping perf.data in the beginning of the file
    and use the data offset as a buffer offset.

    This may exceed the mapping area if the data offset is upper than
    page_size * mmap_window and result in a page fault (thing that
    happen if we merge trace.info in perf.data).

    Instead, let's start the mapping in the page that matches our data
    offset.

    v2: Drop a junk from another patch (trace_report() removal)

    Signed-off-by: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Tom Zanussi
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker