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
     

29 Jun, 2010

1 commit


15 May, 2010

3 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
     
  • 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
     

14 May, 2010

1 commit

  • 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
     

07 Jan, 2010

3 commits

  • The previous patches added the use of print_fmt string and changes
    the trace_define_field() function to also create the fields and
    format output for the event format files.

    text data bss dec hex filename
    5857201 1355780 9336808 16549789 fc879d vmlinux
    5884589 1351684 9337896 16574169 fce6d9 vmlinux-orig

    The above shows the size of the vmlinux after this patch set
    compared to the vmlinux-orig which is before the patch set.

    This saves us 27k on text, 1k on bss and adds just 4k of data.

    The total savings of 24k in size.

    Signed-off-by: Lai Jiangshan
    LKML-Reference:
    Acked-by: Masami Hiramatsu
    Signed-off-by: Steven Rostedt

    Lai Jiangshan
     
  • This is part of a patch set that removes the show_format method
    in the ftrace event macros.

    The print_fmt field is added to hold the string that shows
    the print_fmt in the event format files. This patch only adds
    the field but it is currently not used. Later patches will use
    this field to enable us to remove the show_format field
    and function.

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

    Lai Jiangshan
     
  • This is part of a patch set that removes the show_format method
    in the ftrace event macros.

    This patch set requires that all fields are added to the
    ftrace_event_call->fields. This patch changes __dynamic_array()
    to call trace_define_field() to include fields that use __dynamic_array().

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

    Lai Jiangshan
     

30 Dec, 2009

1 commit


14 Dec, 2009

1 commit

  • Call trace_define_common_fields() in event_create_dir() only.
    This avoids trace events to handle it from their define_fields
    callbacks and shrinks the kernel code size:

    text data bss dec hex filename
    5346802 1961864 7103260 14411926 dbe896 vmlinux.o.old
    5345151 1961864 7103260 14410275 dbe223 vmlinux.o

    Signed-off-by: Li Zefan
    Acked-by: Steven Rostedt
    Cc: Ingo Molnar
    Cc: Jason Baron
    Cc: Masami Hiramatsu
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Li Zefan
     

06 Dec, 2009

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: (470 commits)
    x86: Fix comments of register/stack access functions
    perf tools: Replace %m with %a in sscanf
    hw-breakpoints: Keep track of user disabled breakpoints
    tracing/syscalls: Make syscall events print callbacks static
    tracing: Add DEFINE_EVENT(), DEFINE_SINGLE_EVENT() support to docbook
    perf: Don't free perf_mmap_data until work has been done
    perf_event: Fix compile error
    perf tools: Fix _GNU_SOURCE macro related strndup() build error
    trace_syscalls: Remove unused syscall_name_to_nr()
    trace_syscalls: Simplify syscall profile
    trace_syscalls: Remove duplicate init_enter_##sname()
    trace_syscalls: Add syscall_nr field to struct syscall_metadata
    trace_syscalls: Remove enter_id exit_id
    trace_syscalls: Set event_enter_##sname->data to its metadata
    trace_syscalls: Remove unused event_syscall_enter and event_syscall_exit
    perf_event: Initialize data.period in perf_swevent_hrtimer()
    perf probe: Simplify event naming
    perf probe: Add --list option for listing current probe events
    perf probe: Add argv_split() from lib/argv_split.c
    perf probe: Move probe event utility functions to probe-event.c
    ...

    Linus Torvalds
     

02 Nov, 2009

1 commit

  • ____ftrace_check_##name() is used for compile-time check on
    F_printk() only, so it should be marked as __unused instead
    of __used.

    Signed-off-by: Li Zefan
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    Cc: Linus Torvalds
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Li Zefan
     

23 Oct, 2009

1 commit


06 Oct, 2009

1 commit

  • The sign info used for filters in the kernel is also useful to
    applications that process the trace stream. Add it to the format
    files and make it available to userspace.

    Signed-off-by: Tom Zanussi
    Acked-by: Frederic Weisbecker
    Cc: rostedt@goodmis.org
    Cc: lizf@cn.fujitsu.com
    Cc: hch@infradead.org
    Cc: Peter Zijlstra
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Tom Zanussi
     

24 Sep, 2009

1 commit


14 Sep, 2009

2 commits


13 Sep, 2009

1 commit

  • This patch changes the way the format files in

    debugfs/tracing/events/ftrace/*/format

    are created. It uses the new trace_entries.h file to automate the
    creation of the format files to ensure that they are always in sync
    with the actual structures. This is the same methodology used to
    create the format files for the TRACE_EVENT macro.

    This also updates the filter creation that was built on the creation
    of the format files.

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

11 Sep, 2009

1 commit

  • Conflicts:
    kernel/trace/trace_export.c
    kernel/trace/trace_kprobe.c

    Merge reason: This topic branch lacks an important
    build fix in tracing/core:

    0dd7b74787eaf7858c6c573353a83c3e2766e674:
    tracing: Fix double CPP substitution in TRACE_EVENT_FN

    that prevents from multiple tracepoint headers inclusion crashes.

    Signed-off-by: Frederic Weisbecker

    Frederic Weisbecker
     

31 Aug, 2009

1 commit

  • init_preds() allocates about 5392 bytes of memory (on x86_32) for
    a TRACE_EVENT. With my config, at system boot total memory occupied
    is:

    5392 * (642 + 15) == 3459KB

    642 == cat available_events | wc -l
    15 == number of dirs in events/ftrace

    That's quite a lot, so we'd better defer memory allocation util
    it's needed, that's when filter is used.

    Signed-off-by: Li Zefan
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    Cc: Tom Zanussi
    Cc: Masami Hiramatsu
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Li Zefan
     

27 Aug, 2009

2 commits

  • Use TRACE_FIELD_ZERO(type, item) instead of TRACE_FIELD_ZERO_CHAR(item).
    This also includes a typo fix of TRACE_ZERO_CHAR() macro.

    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Avi Kivity
    Cc: Andi Kleen
    Cc: Christoph Hellwig
    Cc: Frank Ch. Eigler
    Cc: H. Peter Anvin
    Cc: Ingo Molnar
    Cc: Jason Baron
    Cc: Jim Keniston
    Cc: K.Prasad
    Cc: Lai Jiangshan
    Cc: Li Zefan
    Cc: Przemysław Pawełczyk
    Cc: Roland McGrath
    Cc: Sam Ravnborg
    Cc: Srikar Dronamraju
    Cc: Steven Rostedt
    Cc: Tom Zanussi
    Cc: Vegard Nossum
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Masami Hiramatsu
     
  • Add dynamic ftrace_event_call support to ftrace. Trace engines can add
    new ftrace_event_call to ftrace on the fly. Each operator function of
    the call takes an ftrace_event_call data structure as an argument,
    because these functions may be shared among several ftrace_event_calls.

    Changes from v13:
    - Define remove_subsystem_dir() always (revirt a2ca5e03), because
    trace_remove_event_call() uses it.
    - Modify syscall tracer because of ftrace_event_call change.

    [fweisbec@gmail.com: Fixed conflict against latest tracing/core]

    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Avi Kivity
    Cc: Andi Kleen
    Cc: Christoph Hellwig
    Cc: Frank Ch. Eigler
    Cc: H. Peter Anvin
    Cc: Ingo Molnar
    Cc: Jason Baron
    Cc: Jim Keniston
    Cc: K.Prasad
    Cc: Lai Jiangshan
    Cc: Li Zefan
    Cc: Przemysław Pawełczyk
    Cc: Roland McGrath
    Cc: Sam Ravnborg
    Cc: Srikar Dronamraju
    Cc: Steven Rostedt
    Cc: Tom Zanussi
    Cc: Vegard Nossum
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Masami Hiramatsu
     

26 Aug, 2009

1 commit

  • Add __field_ext(), so a field can be assigned to a specific
    filter_type, which matches a corresponding filter function.

    For example, a later patch will allow this:
    __field_ext(const char *, str, FILTER_PTR_STR);

    Signed-off-by: Li Zefan
    LKML-Reference:

    [
    Fixed a -1 to FILTER_OTHER
    Forward ported to latest kernel.
    ]

    Signed-off-by: Steven Rostedt

    Li Zefan
     

19 Aug, 2009

2 commits


12 Aug, 2009

1 commit

  • Add the struct ftrace_event_call as a parameter of its show_format()
    callback. This way we can use it from the syscall trace events to
    retrieve the syscall name from the ftrace event call parameter and
    describe its fields using the syscalls metadata.

    Signed-off-by: Frederic Weisbecker
    Cc: Lai Jiangshan
    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Mathieu Desnoyers
    Cc: Jiaying Zhang
    Cc: Martin Bligh
    Cc: Li Zefan
    Cc: Masami Hiramatsu
    Cc: Jason Baron

    Frederic Weisbecker
     

29 Apr, 2009

1 commit

  • The new filter comparison ops need to be able to distinguish between
    signed and unsigned field types, so add an is_signed flag/param to the
    event field struct/trace_define_fields(). Also define a simple macro,
    is_signed_type() to determine the signedness at compile time, used in the
    trace macros. If the is_signed_type() macro won't work with a specific
    type, a new slightly modified version of TRACE_FIELD() called
    TRACE_FIELD_SIGN(), allows the signedness to be set explicitly.

    [ Impact: extend trace-filter code for new feature ]

    Signed-off-by: Tom Zanussi
    Acked-by: Steven Rostedt
    Cc: fweisbec@gmail.com
    Cc: Li Zefan
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Tom Zanussi
     

24 Apr, 2009

1 commit

  • The events exported by TRACE_EVENT are automated and are guaranteed
    to be correct when used.

    The internal ftrace structures on the other hand are more manually
    exported. These require the ftrace maintainer to make sure they
    are up to date.

    This patch adds a size check to help flag when a type changes in
    an internal ftrace data structure, and the update needs to be reflected
    in the export.

    If a export is incorrect, then the only harm is that the user space
    tools will not know how to correctly read the internal structures of
    ftrace.

    [ Impact: help prevent inconsistent ftrace format print outs ]

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

14 Apr, 2009

3 commits

  • This patch allows event filters to be safely removed or switched
    on-the-fly while avoiding the use of rcu or the suspension of tracing of
    previous versions.

    It does it by adding a new filter_pred_none() predicate function which
    does nothing and by never deallocating either the predicates or any of
    the filter_pred members used in matching; the predicate lists are
    allocated and initialized during ftrace_event_calls initialization.

    Whenever a filter is removed or replaced, the filter_pred_* functions
    currently in use by the affected ftrace_event_call are immediately
    switched over to to the filter_pred_none() function, while the rest of
    the filter_pred members are left intact, allowing any currently
    executing filter_pred_* functions to finish up, using the values they're
    currently using.

    In the case of filter replacement, the new predicate values are copied
    into the old predicates after the above step, and the filter_pred_none()
    functions are replaced by the filter_pred_* functions for the new
    filter. In this case, it is possible though very unlikely that a
    previous filter_pred_* is still running even after the
    filter_pred_none() switch and the switch to the new filter_pred_*. In
    that case, however, because nothing has been deallocated in the
    filter_pred, the worst that can happen is that the old filter_pred_*
    function sees the new values and as a result produces either a false
    positive or a false negative, depending on the values it finds.

    So one downside to this method is that rarely, it can produce a bad
    match during the filter switch, but it should be possible to live with
    that, IMHO.

    The other downside is that at least in this patch the predicate lists
    are always pre-allocated, taking up memory from the start. They could
    probably be allocated on first-use, and de-allocated when tracing is
    completely stopped - if this patch makes sense, I could create another
    one to do that later on.

    Oh, and it also places a restriction on the size of __arrays in events,
    currently set to 128, since they can't be larger than the now embedded
    str_val arrays in the filter_pred struct.

    Signed-off-by: Tom Zanussi
    Acked-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: paulmck@linux.vnet.ibm.com
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Tom Zanussi
     
  • Frederic Weisbecker suggested that the trace_special event shouldn't be
    filterable; this patch adds a TRACE_EVENT_FORMAT_NOFILTER event macro
    that allows an event format to be exported without having a filter
    attached, and removes filtering from the trace_special event.

    Signed-off-by: Tom Zanussi
    Signed-off-by: Steven Rostedt
    Signed-off-by: Ingo Molnar

    Tom Zanussi
     
  • This patch adds run-time field descriptions to all the event formats
    exported using TRACE_EVENT_FORMAT. It also hooks up all the tracers
    that use them (i.e. the tracers in the 'ftrace subsystem') so they can
    also have their output filtered by the event-filtering mechanism.

    When I was testing this, there were a couple of things that fooled me
    into thinking the filters weren't working, when actually they were -
    I'll mention them here so others don't make the same mistakes (and file
    bug reports. ;-)

    One is that some of the tracers trace multiple events e.g. the
    sched_switch tracer uses the context_switch and wakeup events, and if
    you don't set filters on all of the traced events, the unfiltered output
    from the events without filters on them can make it look like the
    filtering as a whole isn't working properly, when actually it is doing
    what it was asked to do - it just wasn't asked to do the right thing.

    The other is that for the really high-volume tracers e.g. the function
    tracer, the volume of filtered events can be so high that it pushes the
    unfiltered events out of the ring buffer before they can be read so e.g.
    cat'ing the trace file repeatedly shows either no output, or once in
    awhile some output but that isn't there the next time you read the
    trace, which isn't what you normally expect when reading the trace file.
    If you read from the trace_pipe file though, you can catch them before
    they disappear.

    Changes from v1:

    As suggested by Frederic Weisbecker:

    - get rid of externs in functions
    - added unlikely() to filter_check_discard()

    Signed-off-by: Tom Zanussi
    Signed-off-by: Steven Rostedt
    Signed-off-by: Ingo Molnar

    Tom Zanussi
     

07 Apr, 2009

1 commit

  • If we cat debugfs/tracing/events/ftrace/bprint/format, we'll see:
    name: bprint
    ID: 6
    format:
    field:unsigned char common_type; offset:0; size:1;
    field:unsigned char common_flags; offset:1; size:1;
    field:unsigned char common_preempt_count; offset:2; size:1;
    field:int common_pid; offset:4; size:4;
    field:int common_tgid; offset:8; size:4;

    field:unsigned long ip; offset:12; size:4;
    field:char * fmt; offset:16; size:4;
    field: char buf; offset:20; size:0;

    print fmt: "%08lx (%d) fmt:%p %s"

    There is an inconsistent blank before char buf.

    Signed-off-by: Zhao Lei
    LKML-Reference:
    Signed-off-by: Steven Rostedt
    Signed-off-by: Ingo Molnar

    Zhaolei
     

11 Mar, 2009

1 commit


10 Mar, 2009

3 commits

  • Impact: clean up and enhancement

    The TRACE_EVENT_FORMAT macro looks quite ugly and is limited in its
    ability to save data as well as to print the record out. Working with
    Ingo Molnar, we came up with a new format that is much more pleasing to
    the eye of C developers. This new macro is more C style than the old
    macro, and is more obvious to what it does.

    Here's the example. The only updated macro in this patch is the
    sched_switch trace point.

    The old method looked like this:

    TRACE_EVENT_FORMAT(sched_switch,
    TP_PROTO(struct rq *rq, struct task_struct *prev,
    struct task_struct *next),
    TP_ARGS(rq, prev, next),
    TP_FMT("task %s:%d ==> %s:%d",
    prev->comm, prev->pid, next->comm, next->pid),
    TRACE_STRUCT(
    TRACE_FIELD(pid_t, prev_pid, prev->pid)
    TRACE_FIELD(int, prev_prio, prev->prio)
    TRACE_FIELD_SPECIAL(char next_comm[TASK_COMM_LEN],
    next_comm,
    TP_CMD(memcpy(TRACE_ENTRY->next_comm,
    next->comm,
    TASK_COMM_LEN)))
    TRACE_FIELD(pid_t, next_pid, next->pid)
    TRACE_FIELD(int, next_prio, next->prio)
    ),
    TP_RAW_FMT("prev %d:%d ==> next %s:%d:%d")
    );

    The above method is hard to read and requires two format fields.

    The new method:

    /*
    * Tracepoint for task switches, performed by the scheduler:
    *
    * (NOTE: the 'rq' argument is not used by generic trace events,
    * but used by the latency tracer plugin. )
    */
    TRACE_EVENT(sched_switch,

    TP_PROTO(struct rq *rq, struct task_struct *prev,
    struct task_struct *next),

    TP_ARGS(rq, prev, next),

    TP_STRUCT__entry(
    __array( char, prev_comm, TASK_COMM_LEN )
    __field( pid_t, prev_pid )
    __field( int, prev_prio )
    __array( char, next_comm, TASK_COMM_LEN )
    __field( pid_t, next_pid )
    __field( int, next_prio )
    ),

    TP_printk("task %s:%d [%d] ==> %s:%d [%d]",
    __entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
    __entry->next_comm, __entry->next_pid, __entry->next_prio),

    TP_fast_assign(
    memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
    __entry->prev_pid = prev->pid;
    __entry->prev_prio = prev->prio;
    memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
    __entry->next_pid = next->pid;
    __entry->next_prio = next->prio;
    )
    );

    This macro is called TRACE_EVENT, it is broken up into 5 parts:

    TP_PROTO: the proto type of the trace point
    TP_ARGS: the arguments of the trace point
    TP_STRUCT_entry: the structure layout of the entry in the ring buffer
    TP_printk: the printk format
    TP_fast_assign: the method used to write the entry into the ring buffer

    The structure is the definition of how the event will be saved in the
    ring buffer. The printk is used by the internal tracing in case of
    an oops, and the kernel needs to print out the format of the record
    to the console. This the TP_printk gives a means to show the records
    in a human readable format. It is also used to print out the data
    from the trace file.

    The TP_fast_assign is executed directly. It is basically like a C function,
    where the __entry is the handle to the record.

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     
  • Impact: clean up

    The macros TPPROTO, TPARGS, TPFMT, TPRAWFMT, and TPCMD all look a bit
    ugly. This patch adds an underscore to their names.

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     
  • Impact: fix compiler warnings

    On x86_64 sizeof and offsetof are treated as long, where as on x86_32
    they are int. This patch typecasts them to unsigned int to avoid
    one arch giving warnings while the other does not.

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

    Steven Rostedt
     

06 Mar, 2009

1 commit

  • Impact: allow user apps to read binary format of basic ftrace entries

    Currently, only defined raw events export their formats so a binary
    reader can parse them. There's no reason that the default ftrace entries
    can't export their formats.

    This patch adds a subsystem called "ftrace" in the events directory
    that includes the ftrace entries for basic ftrace recorded items.

    These only have three files in the events directory:

    type : printf
    available_types : printf
    format : format for the event entry

    For example:

    # cat /debug/tracing/events/ftrace/wakeup/format
    name: wakeup
    ID: 3
    format:
    field:unsigned char type; offset:0; size:1;
    field:unsigned char flags; offset:1; size:1;
    field:unsigned char preempt_count; offset:2; size:1;
    field:int pid; offset:4; size:4;
    field:int tgid; offset:8; size:4;

    field:unsigned int prev_pid; offset:12; size:4;
    field:unsigned char prev_prio; offset:16; size:1;
    field:unsigned char prev_state; offset:17; size:1;
    field:unsigned int next_pid; offset:20; size:4;
    field:unsigned char next_prio; offset:24; size:1;
    field:unsigned char next_state; offset:25; size:1;
    field:unsigned int next_cpu; offset:28; size:4;

    print fmt: "%u:%u:%u ==+ %u:%u:%u [%03u]"

    Signed-off-by: Steven Rostedt

    Steven Rostedt