04 Oct, 2011

1 commit

  • Each event adds some points to its counters. By default it adds 1,
    and a number of points may be transmited in event's parameters.

    E.g. sched:sched_stat_runtime adds how long process has been running.

    But this functionality was broken by v2.6.31-rc5-392-gf413cdb
    and now the event's parameters doesn't affect on a number of points.

    TP_perf_assign isn't defined, so __perf_count(c) isn't executed and
    __count is always equal to 1.

    Signed-off-by: Andrew Vagin
    Signed-off-by: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1317052535-1765247-2-git-send-email-avagin@openvz.org
    Signed-off-by: Ingo Molnar

    Andrew Vagin
     

26 May, 2011

1 commit


03 Feb, 2011

1 commit

  • Currently the trace_event structures are placed in the _ftrace_events
    section, and at link time, the linker makes one large array of all
    the trace_event structures. On boot up, this array is read (much like
    the initcall sections) and the events are processed.

    The problem is that there is no guarantee that gcc will place complex
    structures nicely together in an array format. Two structures in the
    same file may be placed awkwardly, because gcc has no clue that they
    are suppose to be in an array.

    A hack was used previous to force the alignment to 4, to pack the
    structures together. But this caused alignment issues with other
    architectures (sparc).

    Instead of packing the structures into an array, the structures' addresses
    are now put into the _ftrace_event section. As pointers are always the
    natural alignment, gcc should always pack them tightly together
    (otherwise initcall, extable, etc would also fail).

    By having the pointers to the structures in the section, we can still
    iterate the trace_events without causing unnecessary alignment problems
    with other architectures, or depending on the current behaviour of
    gcc that will likely change in the future just to tick us kernel developers
    off a little more.

    The _ftrace_event section is also moved into the .init.data section
    as it is now only needed at boot up.

    Suggested-by: David Miller
    Cc: Mathieu Desnoyers
    Acked-by: David S. Miller
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

19 Nov, 2010

1 commit

  • Currently we have in something like the sched_switch event:

    field:char prev_comm[TASK_COMM_LEN]; offset:12; size:16; signed:1;

    When a userspace tool such as perf tries to parse this, the
    TASK_COMM_LEN is meaningless. This is done because the TRACE_EVENT() macro
    simply uses a #len to show the string of the length. When the length is
    an enum, we get a string that means nothing for tools.

    By adding a static buffer and a mutex to protect it, we can store the
    string into that buffer with snprintf and show the actual number.
    Now we get:

    field:char prev_comm[16]; offset:12; size:16; signed:1;

    Something much more useful.

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

18 Nov, 2010

2 commits

  • As for the raw syscalls events, individual syscall events won't
    leak system wide information on task bound tracing. Allow non
    privileged users to use them in such workflow.

    Signed-off-by: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Thomas Gleixner
    Cc: Steven Rostedt
    Cc: Li Zefan
    Cc: Jason Baron

    Frederic Weisbecker
     
  • This introduces the new TRACE_EVENT_FLAGS() macro in order
    to set up initial event flags value.

    This macro must simply follow the definition of a trace event
    and take the event name and the flag value as parameters:

    TRACE_EVENT(my_event, .....
    ....
    );

    TRACE_EVENT_FLAGS(my_event, 1)

    This will set up 1 as the initial my_event->flags value.

    Signed-off-by: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Thomas Gleixner
    Cc: Steven Rostedt
    Cc: Li Zefan
    Cc: Jason Baron

    Frederic Weisbecker
     

02 Aug, 2010

1 commit


21 Jul, 2010

1 commit

  • __print_flags() and __print_symbolic() use percpu trace_seq:

    1) Its memory is allocated at compile time, it wastes memory if we don't use tracing.
    2) It is percpu data and it wastes more memory for multi-cpus system.
    3) It disables preemption when it executes its core routine
    "trace_seq_printf(s, "%s: ", #call);" and introduces latency.

    So we move this trace_seq to struct trace_iterator.

    Signed-off-by: Lai Jiangshan
    LKML-Reference:
    Signed-off-by: Steven Rostedt

    Lai Jiangshan
     

29 Jun, 2010

1 commit

  • Because kprobes and syscalls need special processing to register
    events, the class->reg() method was created to handle the differences.

    But instead of creating a default ->reg for perf and ftrace events,
    the code was scattered with:

    if (class->reg)
    class->reg();
    else
    default_reg();

    This is messy and can also lead to bugs.

    This patch cleans up this code and creates a default reg() entry for
    the events allowing for the code to directly call the class->reg()
    without the condition.

    Reported-by: Peter Zijlstra
    Acked-by: Peter Zijlstra
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

10 Jun, 2010

1 commit


09 Jun, 2010

1 commit

  • Drop this argument now that we always want to rewind only to the
    state of the first caller.
    It means frame pointers are not necessary anymore to reliably get
    the source of an event. But this also means we need this helper
    to be a macro now, as an inline function is not an option since
    we need to know when to provide a default implentation.

    Signed-off-by: Frederic Weisbecker
    Signed-off-by: Paul Mackerras
    Cc: David Miller
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo

    Frederic Weisbecker
     

31 May, 2010

1 commit

  • tracepoint_probe_unregister() does not synchronize against the probe
    callbacks, so do that explicitly. This properly serializes the callbacks
    and the free of the data used therein.

    Also, use this_cpu_ptr() where possible.

    Acked-by: Frederic Weisbecker
    Signed-off-by: Peter Zijlstra
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

28 May, 2010

1 commit

  • …git/tip/linux-2.6-tip

    * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (61 commits)
    tracing: Add __used annotation to event variable
    perf, trace: Fix !x86 build bug
    perf report: Support multiple events on the TUI
    perf annotate: Fix up usage of the build id cache
    x86/mmiotrace: Remove redundant instruction prefix checks
    perf annotate: Add TUI interface
    perf tui: Remove annotate from popup menu after failure
    perf report: Don't start the TUI if -D is used
    perf: Fix getline undeclared
    perf: Optimize perf_tp_event_match()
    perf: Remove more code from the fastpath
    perf: Optimize the !vmalloc backed buffer
    perf: Optimize perf_output_copy()
    perf: Fix wakeup storm for RO mmap()s
    perf-record: Share per-cpu buffers
    perf-record: Remove -M
    perf: Ensure that IOC_OUTPUT isn't used to create multi-writer buffers
    perf, trace: Optimize tracepoints by using per-tracepoint-per-cpu hlist to track events
    perf, trace: Optimize tracepoints by removing IRQ-disable from perf/tracepoint interaction
    perf tui: Allow disabling the TUI on a per command basis in ~/.perfconfig
    ...

    Linus Torvalds
     

25 May, 2010

1 commit

  • The TRACE_EVENT() macros automate creation of trace events. To automate
    initialization, the set up variables are loaded in a special section
    that is read on boot up. GCC is not aware that these static variables
    are used and will complain about them if we do not inform GCC that
    they are indeed used.

    One of the declarations of the event element was missing a __used
    annotation. This patch adds it.

    Reported-by: Ingo Molnar
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

21 May, 2010

4 commits

  • …nux-2.6-tip into trace/tip/tracing/core-7

    Conflicts:
    include/linux/ftrace_event.h
    include/trace/ftrace.h
    kernel/trace/trace_event_perf.c
    kernel/trace/trace_kprobe.c
    kernel/trace/trace_syscalls.c

    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

    Steven Rostedt
     
  • * git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (182 commits)
    [SCSI] aacraid: add an ifdef'd device delete case instead of taking the device offline
    [SCSI] aacraid: prohibit access to array container space
    [SCSI] aacraid: add support for handling ATA pass-through commands.
    [SCSI] aacraid: expose physical devices for models with newer firmware
    [SCSI] aacraid: respond automatically to volumes added by config tool
    [SCSI] fcoe: fix fcoe module ref counting
    [SCSI] libfcoe: FIP Keep-Alive messages for VPorts are sent with incorrect port_id and wwn
    [SCSI] libfcoe: Fix incorrect MAC address clearing
    [SCSI] fcoe: fix a circular locking issue with rtnl and sysfs mutex
    [SCSI] libfc: Move the port_id into lport
    [SCSI] fcoe: move link speed checking into its own routine
    [SCSI] libfc: Remove extra pointer check
    [SCSI] libfc: Remove unused fc_get_host_port_type
    [SCSI] fcoe: fixes wrong error exit in fcoe_create
    [SCSI] libfc: set seq_id for incoming sequence
    [SCSI] qla2xxx: Updates to ISP82xx support.
    [SCSI] qla2xxx: Optionally disable target reset.
    [SCSI] qla2xxx: ensure flash operation and host reset via sg_reset are mutually exclusive
    [SCSI] qla2xxx: Silence bogus warning by gcc for wrap and did.
    [SCSI] qla2xxx: T10 DIF support added.
    ...

    Linus Torvalds
     
  • Avoid the swevent hash-table by using per-tracepoint
    hlists.

    Also, avoid conditionals on the fast path by ordering
    with probe unregister so that we should never get on
    the callback path without the data being there.

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

    Peter Zijlstra
     
  • Improves performance.

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

    Peter Zijlstra
     

20 May, 2010

1 commit


19 May, 2010

1 commit


18 May, 2010

2 commits

  • …git/tip/linux-2.6-tip

    * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (311 commits)
    perf tools: Add mode to build without newt support
    perf symbols: symbol inconsistency message should be done only at verbose=1
    perf tui: Add explicit -lslang option
    perf options: Type check all the remaining OPT_ variants
    perf options: Type check OPT_BOOLEAN and fix the offenders
    perf options: Check v type in OPT_U?INTEGER
    perf options: Introduce OPT_UINTEGER
    perf tui: Add workaround for slang < 2.1.4
    perf record: Fix bug mismatch with -c option definition
    perf options: Introduce OPT_U64
    perf tui: Add help window to show key associations
    perf tui: Make <- exit menus too
    perf newt: Add single key shortcuts for zoom into DSO and threads
    perf newt: Exit browser unconditionally when CTRL+C, q or Q is pressed
    perf newt: Fix the 'A'/'a' shortcut for annotate
    perf newt: Make <- exit the ui_browser
    x86, perf: P4 PMU - fix counters management logic
    perf newt: Make <- zoom out filters
    perf report: Report number of events, not samples
    perf hist: Clarify events_stats fields usage
    ...

    Fix up trivial conflicts in kernel/fork.c and tools/perf/builtin-record.c

    Linus Torvalds
     
  • …nux-2.6-tip into trace/tip/tracing/core-6

    Conflicts:
    include/trace/ftrace.h
    kernel/trace/trace_kprobe.c

    Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
    Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

    Steven Rostedt
     

15 May, 2010

6 commits

  • Now that the trace_event structure is embedded in the ftrace_event_call
    structure, there is no need for the ftrace_event_call id field.
    The id field is the same as the trace_event type field.

    Removing the id and re-arranging the structure brings down the tracepoint
    footprint by another 5K.

    text data bss dec hex filename
    4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
    4895024 1023812 861512 6780348 6775bc vmlinux.print
    4894944 1018052 861512 6774508 675eec vmlinux.id

    Acked-by: Mathieu Desnoyers
    Acked-by: Masami Hiramatsu
    Acked-by: Frederic Weisbecker
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     
  • Currently, every event has its own trace_event structure. This is
    fine since the structure is needed anyway. But the print function
    structure (trace_event_functions) is now separate. Since the output
    of the trace event is done by the class (with the exception of events
    defined by DEFINE_EVENT_PRINT), it makes sense to have the class
    define the print functions that all events in the class can use.

    This makes a bigger deal with the syscall events since all syscall events
    use the same class. The savings here is another 30K.

    text data bss dec hex filename
    4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
    4900382 1048964 861512 6810858 67ecea vmlinux.init
    4900446 1049028 861512 6810986 67ed6a vmlinux.preprint
    4895024 1023812 861512 6780348 6775bc vmlinux.print

    To accomplish this, and to let the class know what event is being
    printed, the event structure is embedded in the ftrace_event_call
    structure. This should not be an issues since the event structure
    was created for each event anyway.

    Acked-by: Mathieu Desnoyers
    Acked-by: Masami Hiramatsu
    Acked-by: Frederic Weisbecker
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     
  • Multiple events may use the same method to print their data.
    Instead of having all events have a pointer to their print funtions,
    the trace_event structure now points to a trace_event_functions structure
    that will hold the way to print ouf the event.

    The event itself is now passed to the print function to let the print
    function know what kind of event it should print.

    This opens the door to consolidating the way several events print
    their output.

    text data bss dec hex filename
    4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
    4900382 1048964 861512 6810858 67ecea vmlinux.init
    4900446 1049028 861512 6810986 67ed6a vmlinux.preprint

    This change slightly increases the size but is needed for the next change.

    v3: Fix the branch tracer events to handle this change.

    v2: Fix the new function graph tracer event calls to handle this change.

    Acked-by: Mathieu Desnoyers
    Acked-by: Masami Hiramatsu
    Acked-by: Frederic Weisbecker
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     
  • The raw_init function pointer in the event is used to initialize
    various kinds of events. The type of initialization needed is usually
    classed to the kind of event it is.

    Two events with the same class will always have the same initialization
    function, so it makes sense to move this to the class structure.

    Perhaps even making a special system structure would work since
    the initialization is the same for all events within a system.
    But since there's no system structure (yet), this will just move it
    to the class.

    text data bss dec hex filename
    4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
    4900375 1053380 861512 6815267 67fe23 vmlinux.fields
    4900382 1048964 861512 6810858 67ecea vmlinux.init

    The text grew very slightly, but this is a constant growth that happened
    with the changing of the C files that call the init code.
    The bigger savings is the data which will be saved the more events share
    a class.

    Acked-by: Mathieu Desnoyers
    Acked-by: Masami Hiramatsu
    Acked-by: Frederic Weisbecker
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     
  • Move the defined fields from the event to the class structure.
    Since the fields of the event are defined by the class they belong
    to, it makes sense to have the class hold the information instead
    of the individual events. The events of the same class would just
    hold duplicate information.

    After this change the size of the kernel dropped another 3K:

    text data bss dec hex filename
    4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
    4900252 1057412 861512 6819176 680d68 vmlinux.regs
    4900375 1053380 861512 6815267 67fe23 vmlinux.fields

    Although the text increased, this was mainly due to the C files
    having to adapt to the change. This is a constant increase, where
    new tracepoints will not increase the Text. But the big drop is
    in the data size (as well as needed allocations to hold the fields).
    This will give even more savings as more tracepoints are created.

    Note, if just TRACE_EVENT()s are used and not DECLARE_EVENT_CLASS()
    with several DEFINE_EVENT()s, then the savings will be lost. But
    we are pushing developers to consolidate events with DEFINE_EVENT()
    so this should not be an issue.

    The kprobes define a unique class to every new event, but are dynamic
    so it should not be a issue.

    The syscalls however have a single class but the fields for the individual
    events are different. The syscalls use a metadata to define the
    fields. I moved the fields list from the event to the metadata and
    added a "get_fields()" function to the class. This function is used
    to find the fields. For normal events and kprobes, get_fields() just
    returns a pointer to the fields list_head in the class. For syscall
    events, it returns the fields list_head in the metadata for the event.

    v2: Fixed the syscall fields. The syscall metadata needs a list
    of fields for both enter and exit.

    Acked-by: Frederic Weisbecker
    Acked-by: Mathieu Desnoyers
    Acked-by: Masami Hiramatsu
    Cc: Tom Zanussi
    Cc: Peter Zijlstra
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     
  • This patch removes the register functions of TRACE_EVENT() to enable
    and disable tracepoints. The registering of a event is now down
    directly in the trace_events.c file. The tracepoint_probe_register()
    is now called directly.

    The prototypes are no longer type checked, but this should not be
    an issue since the tracepoints are created automatically by the
    macros. If a prototype is incorrect in the TRACE_EVENT() macro, then
    other macros will catch it.

    The trace_event_class structure now holds the probes to be called
    by the callbacks. This removes needing to have each event have
    a separate pointer for the probe.

    To handle kprobes and syscalls, since they register probes in a
    different manner, a "reg" field is added to the ftrace_event_class
    structure. If the "reg" field is assigned, then it will be called for
    enabling and disabling of the probe for either ftrace or perf. To let
    the reg function know what is happening, a new enum (trace_reg) is
    created that has the type of control that is needed.

    With this new rework, the 82 kernel events and 618 syscall events
    has their footprint dramatically lowered:

    text data bss dec hex filename
    4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
    4914025 1088868 861512 6864405 68be15 vmlinux.class
    4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint
    4900252 1057412 861512 6819176 680d68 vmlinux.regs

    The size went from 6863829 to 6819176, that's a total of 44K
    in savings. With tracepoints being continuously added, this is
    critical that the footprint becomes minimal.

    v5: Added #ifdef CONFIG_PERF_EVENTS around a reference to perf
    specific structure in trace_events.c.

    v4: Fixed trace self tests to check probe because regfunc no longer
    exists.

    v3: Updated to handle void *data in beginning of probe parameters.
    Also added the tracepoint: check_trace_callback_type_##call().

    v2: Changed the callback probes to pass void * and typecast the
    value within the function.

    Acked-by: Mathieu Desnoyers
    Acked-by: Masami Hiramatsu
    Acked-by: Frederic Weisbecker
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

14 May, 2010

2 commits

  • This patch adds data to be passed to tracepoint callbacks.

    The created functions from DECLARE_TRACE() now need a mandatory data
    parameter. For example:

    DECLARE_TRACE(mytracepoint, int value, value)

    Will create the register function:

    int register_trace_mytracepoint((void(*)(void *data, int value))probe,
    void *data);

    As the first argument, all callbacks (probes) must take a (void *data)
    parameter. So a callback for the above tracepoint will look like:

    void myprobe(void *data, int value)
    {
    }

    The callback may choose to ignore the data parameter.

    This change allows callbacks to register a private data pointer along
    with the function probe.

    void mycallback(void *data, int value);

    register_trace_mytracepoint(mycallback, mydata);

    Then the mycallback() will receive the "mydata" as the first parameter
    before the args.

    A more detailed example:

    DECLARE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));

    /* In the C file */

    DEFINE_TRACE(mytracepoint, TP_PROTO(int status), TP_ARGS(status));

    [...]

    trace_mytracepoint(status);

    /* In a file registering this tracepoint */

    int my_callback(void *data, int status)
    {
    struct my_struct my_data = data;
    [...]
    }

    [...]
    my_data = kmalloc(sizeof(*my_data), GFP_KERNEL);
    init_my_data(my_data);
    register_trace_mytracepoint(my_callback, my_data);

    The same callback can also be registered to the same tracepoint as long
    as the data registered is different. Note, the data must also be used
    to unregister the callback:

    unregister_trace_mytracepoint(my_callback, my_data);

    Because of the data parameter, tracepoints declared this way can not have
    no args. That is:

    DECLARE_TRACE(mytracepoint, TP_PROTO(void), TP_ARGS());

    will cause an error.

    If no arguments are needed, a new macro can be used instead:

    DECLARE_TRACE_NOARGS(mytracepoint);

    Since there are no arguments, the proto and args fields are left out.

    This is part of a series to make the tracepoint footprint smaller:

    text data bss dec hex filename
    4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
    4914025 1088868 861512 6864405 68be15 vmlinux.class
    4918492 1084612 861512 6864616 68bee8 vmlinux.tracepoint

    Again, this patch also increases the size of the kernel, but
    lays the ground work for decreasing it.

    v5: Fixed net/core/drop_monitor.c to handle these updates.

    v4: Moved the DECLARE_TRACE() DECLARE_TRACE_NOARGS out of the
    #ifdef CONFIG_TRACE_POINTS, since the two are the same in both
    cases. The __DECLARE_TRACE() is what changes.
    Thanks to Frederic Weisbecker for pointing this out.

    v3: Made all register_* functions require data to be passed and
    all callbacks to take a void * parameter as its first argument.
    This makes the calling functions comply with C standards.

    Also added more comments to the modifications of DECLARE_TRACE().

    v2: Made the DECLARE_TRACE() have the ability to pass arguments
    and added a new DECLARE_TRACE_NOARGS() for tracepoints that
    do not need any arguments.

    Acked-by: Mathieu Desnoyers
    Acked-by: Masami Hiramatsu
    Acked-by: Frederic Weisbecker
    Cc: Neil Horman
    Cc: David S. Miller
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     
  • This patch creates a ftrace_event_class struct that event structs point to.
    This class struct will be made to hold information to modify the
    events. Currently the class struct only holds the events system name.

    This patch slightly increases the size, but this change lays the ground work
    of other changes to make the footprint of tracepoints smaller.

    With 82 standard tracepoints, and 618 system call tracepoints
    (two tracepoints per syscall: enter and exit):

    text data bss dec hex filename
    4913961 1088356 861512 6863829 68bbd5 vmlinux.orig
    4914025 1088868 861512 6864405 68be15 vmlinux.class

    This patch also cleans up some stale comments in ftrace.h.

    v2: Fixed missing semi-colon in macro.

    Acked-by: Frederic Weisbecker
    Acked-by: Mathieu Desnoyers
    Acked-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

01 May, 2010

1 commit

  • __print_hex() prints values in an array in hex (w/o '0x') (space separated)
    EX) 92 33 32 f3 ee 4d

    Signed-off-by: Li Zefan
    Signed-off-by: Tomohiro Kusumi
    Signed-off-by: Kei Tokunaga
    Acked-by: Steven Rostedt
    Signed-off-by: James Bottomley

    Kei Tokunaga
     

04 Apr, 2010

1 commit

  • Trace events can be defined from a template using
    DECLARE_EVENT_CLASS/DEFINE_EVENT or directly with TRACE_EVENT.

    In both cases we have a template tracepoint handler, used to
    record the trace, to which we pass our ftrace event instance.

    In the function level, if the class is named "foo" and the event
    is named "blah", we have the following chain of calls:

    perf_trace_blah() -> perf_trace_templ_foo()

    In the case we have several events sharing the class "blah",
    we'll have multiple users of perf_trace_templ_foo(), and it
    won't be inlined by the compiler. This is usually what happens
    with the DECLARE_EVENT_CLASS/DEFINE_EVENT based definition.

    But if perf_trace_blah() is the only caller of perf_trace_templ_foo()
    there are fair chances that it will be inlined.

    The problem is that we fetch the regs from perf_trace_templ_foo()
    after we rewinded the frame pointer to the second caller, we want
    to reach the caller of perf_trace_blah() to get the right source
    of the event. And we do this by always assuming that
    perf_trace_templ_foo() is not inlined. But as shown above this
    is not always true. And if it is inlined we miss the first caller,
    losing the most important level of precision.

    We get:
    61.31% ls [kernel.kallsyms] [k] do_softirq
    |
    --- do_softirq
    irq_exit
    do_IRQ
    common_interrupt
    |
    |--25.00%-- tty_buffer_request_room

    Instead of:
    61.31% ls [kernel.kallsyms] [k] __do_softirq
    |
    --- __do_softirq
    do_softirq
    irq_exit
    do_IRQ
    common_interrupt
    |
    |--25.00%-- tty_buffer_request_room

    To fix this, we fetch the regs from perf_trace_blah() rather than
    perf_trace_templ_foo() so that we don't have to deal with inlining
    surprises.

    That also bring us the advantage of having the true source of the
    event even if we don't have frame pointers.

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

    Frederic Weisbecker
     

01 Apr, 2010

1 commit


19 Mar, 2010

1 commit

  • …/git/tip/linux-2.6-tip

    * 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (35 commits)
    perf: Fix unexported generic perf_arch_fetch_caller_regs
    perf record: Don't try to find buildids in a zero sized file
    perf: export perf_trace_regs and perf_arch_fetch_caller_regs
    perf, x86: Fix hw_perf_enable() event assignment
    perf, ppc: Fix compile error due to new cpu notifiers
    perf: Make the install relative to DESTDIR if specified
    kprobes: Calculate the index correctly when freeing the out-of-line execution slot
    perf tools: Fix sparse CPU numbering related bugs
    perf_event: Fix oops triggered by cpu offline/online
    perf: Drop the obsolete profile naming for trace events
    perf: Take a hot regs snapshot for trace events
    perf: Introduce new perf_fetch_caller_regs() for hot regs snapshot
    perf/x86-64: Use frame pointer to walk on irq and process stacks
    lockdep: Move lock events under lockdep recursion protection
    perf report: Print the map table just after samples for which no map was found
    perf report: Add multiple event support
    perf session: Change perf_session post processing functions to take histogram tree
    perf session: Add storage for seperating event types in report
    perf session: Change add_hist_entry to take the tree root instead of session
    perf record: Add ID and to recorded event data when recording multiple events
    ...

    Linus Torvalds
     

10 Mar, 2010

2 commits

  • Drop the obsolete "profile" naming used by perf for trace events.
    Perf can now do more than simple events counting, so generalize
    the API naming.

    Signed-off-by: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Steven Rostedt
    Cc: Masami Hiramatsu
    Cc: Jason Baron

    Frederic Weisbecker
     
  • We are taking a wrong regs snapshot when a trace event triggers.
    Either we use get_irq_regs(), which gives us the interrupted
    registers if we are in an interrupt, or we use task_pt_regs()
    which gives us the state before we entered the kernel, assuming
    we are lucky enough to be no kernel thread, in which case
    task_pt_regs() returns the initial set of regs when the kernel
    thread was started.

    What we want is different. We need a hot snapshot of the regs,
    so that we can get the instruction pointer to record in the
    sample, the frame pointer for the callchain, and some other
    things.

    Let's use the new perf_fetch_caller_regs() for that.

    Comparison with perf record -e lock: -R -a -f -g
    Before:

    perf [kernel] [k] __do_softirq
    |
    --- __do_softirq
    |
    |--55.16%-- __open
    |
    --44.84%-- __write_nocancel

    After:

    perf [kernel] [k] perf_tp_event
    |
    --- perf_tp_event
    |
    |--41.07%-- lock_acquire
    | |
    | |--39.36%-- _raw_spin_lock
    | | |
    | | |--7.81%-- hrtimer_interrupt
    | | | smp_apic_timer_interrupt
    | | | apic_timer_interrupt

    The old case was producing unreliable callchains. Now having
    right frame and instruction pointers, we have the trace we
    want.

    Also syscalls and kprobe events already have the right regs,
    let's use them instead of wasting a retrieval.

    v2: Follow the rename perf_save_regs() -> perf_fetch_caller_regs()

    Signed-off-by: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: H. Peter Anvin
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Steven Rostedt
    Cc: Arnaldo Carvalho de Melo
    Cc: Masami Hiramatsu
    Cc: Jason Baron
    Cc: Archs

    Frederic Weisbecker
     

04 Mar, 2010

1 commit

  • Change the pair of rcu_dereference() calls in
    ftrace_perf_buf_prepare() to rcu_dereference_sched().

    Signed-off-by: Paul E. McKenney
    Acked-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: laijs@cn.fujitsu.com
    Cc: dipankar@in.ibm.com
    Cc: mathieu.desnoyers@polymtl.ca
    Cc: josh@joshtriplett.org
    Cc: dvhltc@us.ibm.com
    Cc: niv@us.ibm.com
    Cc: peterz@infradead.org
    Cc: Valdis.Kletnieks@vt.edu
    Cc: dhowells@redhat.com
    Cc: Frederic Weisbecker
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Paul E. McKenney
     

01 Mar, 2010

1 commit

  • …git/tip/linux-2.6-tip

    * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (172 commits)
    perf_event, amd: Fix spinlock initialization
    perf_event: Fix preempt warning in perf_clock()
    perf tools: Flush maps on COMM events
    perf_events, x86: Split PMU definitions into separate files
    perf annotate: Handle samples not at objdump output addr boundaries
    perf_events, x86: Remove superflous MSR writes
    perf_events: Simplify code by removing cpu argument to hw_perf_group_sched_in()
    perf_events, x86: AMD event scheduling
    perf_events: Add new start/stop PMU callbacks
    perf_events: Report the MMAP pgoff value in bytes
    perf annotate: Defer allocating sym_priv->hist array
    perf symbols: Improve debugging information about symtab origins
    perf top: Use a macro instead of a constant variable
    perf symbols: Check the right return variable
    perf/scripts: Tag syscall_name helper as not yet available
    perf/scripts: Add perf-trace-python Documentation
    perf/scripts: Remove unnecessary PyTuple resizes
    perf/scripts: Add syscall tracing scripts
    perf/scripts: Add Python scripting engine
    perf/scripts: Remove check-perf-trace from listed scripts
    ...

    Fix trivial conflict in tools/perf/util/probe-event.c

    Linus Torvalds
     

25 Feb, 2010

1 commit

  • GCC 4.5 introduces behavior that forces the alignment of structures to
    use the largest possible value. The default value is 32 bytes, so if
    some structures are defined with a 4-byte alignment and others aren't
    declared with an alignment constraint at all - it will align at 32-bytes.

    For things like the ftrace events, this results in a non-standard array.
    When initializing the ftrace subsystem, we traverse the _ftrace_events
    section and call the initialization callback for each event. When the
    structures are misaligned, we could be treating another part of the
    structure (or the zeroed out space between them) as a function pointer.

    This patch forces the alignment for all the ftrace_event_call structures
    to 4 bytes.

    Without this patch, the kernel fails to boot very early when built with
    gcc 4.5.

    It's trivial to check the alignment of the members of the array, so it
    might be worthwhile to add something to the build system to do that
    automatically. Unfortunately, that only covers this case. I've asked one
    of the gcc developers about adding a warning when this condition is seen.

    Cc: stable@kernel.org
    Signed-off-by: Jeff Mahoney
    LKML-Reference:
    Signed-off-by: Steven Rostedt

    Jeff Mahoney
     

16 Feb, 2010

1 commit

  • The functions used to implement the TRACE_EVENT macro show up in
    function tracing. This is considered a distraction, and these should
    not be displayed. For example:

    -0 [000] 57.202149: task_of -0 [000] 57.202149: ftrace_raw_event_sched_stat_wait -0 [000] 57.202150: ftrace_raw_event_id_sched_stat_template -0 [000] 57.202150: sched_stat_wait: comm=sshd pid=2735 delay=19207 [ns]

    The "ftrace_raw_event_*" traces are just the utility functions used
    by TRACE_EVENT tracepoints.

    Cc: Thomas Gleixner
    Requested-by: Peter Zijlstra
    Signed-off-by: Steven Rostedt

    Steven Rostedt