22 Sep, 2009

1 commit

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

    * 'perfcounters-rename-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    perf: Tidy up after the big rename
    perf: Do the big rename: Performance Counters -> Performance Events
    perf_counter: Rename 'event' to event_id/hw_event
    perf_counter: Rename list_entry -> group_entry, counter_list -> group_list

    Manually resolved some fairly trivial conflicts with the tracing tree in
    include/trace/ftrace.h and kernel/trace/trace_syscalls.c.

    Linus Torvalds
     

21 Sep, 2009

1 commit

  • Bye-bye Performance Counters, welcome Performance Events!

    In the past few months the perfcounters subsystem has grown out its
    initial role of counting hardware events, and has become (and is
    becoming) a much broader generic event enumeration, reporting, logging,
    monitoring, analysis facility.

    Naming its core object 'perf_counter' and naming the subsystem
    'perfcounters' has become more and more of a misnomer. With pending
    code like hw-breakpoints support the 'counter' name is less and
    less appropriate.

    All in one, we've decided to rename the subsystem to 'performance
    events' and to propagate this rename through all fields, variables
    and API names. (in an ABI compatible fashion)

    The word 'event' is also a bit shorter than 'counter' - which makes
    it slightly more convenient to write/handle as well.

    Thanks goes to Stephane Eranian who first observed this misnomer and
    suggested a rename.

    User-space tooling and ABI compatibility is not affected - this patch
    should be function-invariant. (Also, defconfigs were not touched to
    keep the size down.)

    This patch has been generated via the following script:

    FILES=$(find * -type f | grep -vE 'oprofile|[^K]config')

    sed -i \
    -e 's/PERF_EVENT_/PERF_RECORD_/g' \
    -e 's/PERF_COUNTER/PERF_EVENT/g' \
    -e 's/perf_counter/perf_event/g' \
    -e 's/nb_counters/nb_events/g' \
    -e 's/swcounter/swevent/g' \
    -e 's/tpcounter_event/tp_event/g' \
    $FILES

    for N in $(find . -name perf_counter.[ch]); do
    M=$(echo $N | sed 's/perf_counter/perf_event/g')
    mv $N $M
    done

    FILES=$(find . -name perf_event.*)

    sed -i \
    -e 's/COUNTER_MASK/REG_MASK/g' \
    -e 's/COUNTER/EVENT/g' \
    -e 's/\/event_id/g' \
    -e 's/counter/event/g' \
    -e 's/Counter/Event/g' \
    $FILES

    ... to keep it as correct as possible. This script can also be
    used by anyone who has pending perfcounters patches - it converts
    a Linux kernel tree over to the new naming. We tried to time this
    change to the point in time where the amount of pending patches
    is the smallest: the end of the merge window.

    Namespace clashes were fixed up in a preparatory patch - and some
    stylistic fallout will be fixed up in a subsequent patch.

    ( NOTE: 'counters' are still the proper terminology when we deal
    with hardware registers - and these sed scripts are a bit
    over-eager in renaming them. I've undone some of that, but
    in case there's something left where 'counter' would be
    better than 'event' we can undo that on an individual basis
    instead of touching an otherwise nicely automated patch. )

    Suggested-by: Stephane Eranian
    Acked-by: Peter Zijlstra
    Acked-by: Paul Mackerras
    Reviewed-by: Arjan van de Ven
    Cc: Mike Galbraith
    Cc: Arnaldo Carvalho de Melo
    Cc: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Benjamin Herrenschmidt
    Cc: David Howells
    Cc: Kyle McMartin
    Cc: Martin Schwidefsky
    Cc: "David S. Miller"
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Cc:
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

18 Sep, 2009

2 commits

  • Currently the trace event profile buffer is allocated in the stack. But
    this may be too much for the stack, as the events can have large
    statically defined field size and can also grow with dynamic arrays.

    Allocate two per cpu buffer for all profiled events. The first cpu
    buffer is used to host every non-nmi context traces. It is protected
    by disabling the interrupts while writing and committing the trace.

    The second buffer is reserved for nmi. So that there is no race between
    them and the first buffer.

    The whole write/commit section is rcu protected because we release
    these buffers while deactivating the last profiling trace event.

    v2: Move the buffers from trace_event to be global, as pointed by
    Steven Rostedt.

    v3: Fix the syscall events to handle the profiling buffer races
    by disabling interrupts, now that the buffers are globals.

    Suggested-by: Steven Rostedt
    Signed-off-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Li Zefan
    Cc: Jason Baron
    Cc: Masami Hiramatsu
    Cc: Ingo Molnar

    Frederic Weisbecker
     
  • Factorize the events enabling accounting in a common tracing core
    helper. This reduces the size of the profile_enable() and
    profile_disable() callbacks for each trace events.

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

    Frederic Weisbecker
     

14 Sep, 2009

2 commits


05 Sep, 2009

1 commit

  • The latency tracers (irqsoff and wakeup) can swap trace buffers
    on the fly. If an event is happening and has reserved data on one of
    the buffers, and the latency tracer swaps the global buffer with the
    max buffer, the result is that the event may commit the data to the
    wrong buffer.

    This patch changes the API to the trace recording to be recieve the
    buffer that was used to reserve a commit. Then this buffer can be passed
    in to the commit.

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

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
     

28 Aug, 2009

1 commit

  • TRACE_EVENT_FN relays on TRACE_EVENT by reprocessing its parameters
    into the ftrace events CPP macro. This leads to a double substitution
    in some cases.

    For example, a bad consequence is a format always prefixed by
    "%s, %s\n" for every TRACE_EVENT_FN based events.

    Eg:
    cat /debug/tracing/events/syscalls/sys_enter/format
    [...]
    print fmt: "%s, %s\n", "\"NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)\"",\
    "REC->id, REC->args[0], REC->args[1], REC->args[2], REC->args[3],\
    REC->args[4], REC->args[5]"

    This creates a failure in post-processing tools such as perf trace or
    trace-cmd.

    Then drop this double substitution and replace it by a new __cpparg()
    macro that relays CPP arguments containing commas.

    Signed-off-by: Frederic Weisbecker
    Cc: Josh Stone
    Cc: Li Zefan
    Cc: Steven Rostedt
    Cc: Jason Baron
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     

26 Aug, 2009

3 commits

  • …deric/random-tracing into tracing/core

    Conflicts:
    include/linux/tracepoint.h

    Signed-off-by: Ingo Molnar <mingo@elte.hu>

    Ingo Molnar
     
  • 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
     
  • It's not strictly correct for the tracepoint reg/unreg callbacks to
    occur when a client is hooking up, because the actual tracepoint may not
    be present yet. This happens to be fine for syscall, since that's in
    the core kernel, but it would cause problems for tracepoints defined in
    a module that hasn't been loaded yet. It also means the reg/unreg has
    to be EXPORTed for any modules to use the tracepoint (as in SystemTap).

    This patch removes DECLARE_TRACE_WITH_CALLBACK, and instead introduces
    DEFINE_TRACE_FN which stores the callbacks in struct tracepoint. The
    callbacks are used now when the active state of the tracepoint changes
    in set_tracepoint & disable_tracepoint.

    This also introduces TRACE_EVENT_FN, so ftrace events can also provide
    registration callbacks if needed.

    Signed-off-by: Josh Stone
    Cc: Jason Baron
    Cc: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Li Zefan
    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Mathieu Desnoyers
    Cc: Jiaying Zhang
    Cc: Martin Bligh
    Cc: Lai Jiangshan
    Cc: Paul Mundt
    Cc: Martin Schwidefsky
    Cc: Heiko Carstens
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Josh Stone
     

19 Aug, 2009

2 commits


12 Aug, 2009

2 commits

  • 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
     
  • add an optional void * pointer to 'ftrace_event_call' that is
    passed in for regfunc and unregfunc.

    This prepares for syscall tracepoints creation by passing the name of
    the syscall we want to trace and then retrieve its number through our
    arch syscall table.

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

    Jason Baron
     

11 Aug, 2009

1 commit


10 Aug, 2009

3 commits

  • After aligning the ftrace raw samples, there are dead bytes storing
    random data from the stack. We don't want to leak these to userspace,
    then zero these out.

    Before:

    0x2de88 [0x50]: event: 9
    .
    . ... raw event: size 80 bytes
    . 0000: 09 00 00 00 01 00 50 00 d0 c7 00 81 ff ff ff ff ......P........
    . 0010: 68 01 00 00 68 01 00 00 2c 00 00 00 00 00 00 00 h...h...,......
    . 0020: 2c 00 00 00 2b 00 01 02 68 01 00 00 68 01 00 00 ,...+...h...h..
    . 0030: 6b 6f 6e 64 65 6d 61 6e 64 2f 30 00 00 00 00 00 kondemand/0....
    . 0040: 68 01 00 00 40 7f 46 81 ff ff ff ff 00 10 1b 7f h...@.F........
    ^ ^ ^ ^
    Leak

    After:

    0x2d318 [0x50]: event: 9
    .
    . ... raw event: size 80 bytes
    . 0000: 09 00 00 00 01 00 50 00 d0 c7 00 81 ff ff ff ff ......P........
    . 0010: 68 01 00 00 68 01 00 00 68 14 00 00 00 00 00 00 h...h...h......
    . 0020: 2c 00 00 00 2b 00 01 02 68 01 00 00 68 01 00 00 ,...+...h...h..
    . 0030: 6b 6f 6e 64 65 6d 61 6e 64 2f 30 00 00 00 00 00 kondemand/0....
    . 0040: 68 01 00 00 a0 80 46 81 ff ff ff ff 00 00 00 00 h.....F........
    ^ ^ ^ ^
    Fixed

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

    Frederic Weisbecker
     
  • We compute the perf raw sample size by aligning the raw ftrace
    event size plus the buffer size field itself. We do that
    instead of aligning only the perf raw sample size, so that we
    might economize some in some cases.

    But this buffer size field is not stored in the perf raw
    sample, we must then substract its size from the buffer once we
    computed the alignment unless we may get a useless u32 field in
    the buffer.

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

    Frederic Weisbecker
     
  • PERF_SAMPLE_* output switches should unconditionally output the
    correct format, as they are the only way to unambiguously parse
    the PERF_EVENT_SAMPLE data.

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

    Peter Zijlstra
     

09 Aug, 2009

2 commits

  • This patch implements the kernel side support for ftrace event
    record sampling.

    A new counter sampling attribute is added:

    PERF_SAMPLE_TP_RECORD

    which requests ftrace events record sampling. In this case
    if a PERF_TYPE_TRACEPOINT counter is active and a tracepoint
    fires, we emit the tracepoint binary record to the
    perfcounter event buffer, as a sample.

    Result, after setting PERF_SAMPLE_TP_RECORD attribute from perf
    record:

    perf record -f -F 1 -a -e workqueue:workqueue_execution
    perf report -D

    0x21e18 [0x48]: event: 9
    .
    . ... raw event: size 72 bytes
    . 0000: 09 00 00 00 01 00 48 00 d0 c7 00 81 ff ff ff ff ......H........
    . 0010: 0a 00 00 00 0a 00 00 00 21 00 00 00 00 00 00 00 ........!......
    . 0020: 2b 00 01 02 0a 00 00 00 0a 00 00 00 65 76 65 6e +...........eve
    . 0030: 74 73 2f 31 00 00 00 00 00 00 00 00 0a 00 00 00 ts/1...........
    . 0040: e0 b1 31 81 ff ff ff ff .......
    .
    0x21e18 [0x48]: PERF_EVENT_SAMPLE (IP, 1): 10: 0xffffffff8100c7d0 period: 33

    The raw ftrace binary record starts at offset 0020.

    Translation:

    struct trace_entry {
    type = 0x2b = 43;
    flags = 1;
    preempt_count = 2;
    pid = 0xa = 10;
    tgid = 0xa = 10;
    }

    thread_comm = "events/1"
    thread_pid = 0xa = 10;
    func = 0xffffffff8131b1e0 = flush_to_ldisc()

    What will come next?

    - Userspace support ('perf trace'), 'flight data recorder' mode
    for perf trace, etc.

    - The unconditional copy from the profiling callback brings
    some costs however if someone wants no such sampling to
    occur, and needs to be fixed in the future. For that we need
    to have an instant access to the perf counter attribute.
    This is a matter of a flag to add in the struct ftrace_event.

    - Take care of the events recursivity! Don't ever try to record
    a lock event for example, it seems some locking is used in
    the profiling fast path and lead to a tracing recursivity.
    That will be fixed using raw spinlock or recursivity
    protection.

    - [...]

    - Profit! :-)

    Signed-off-by: Frederic Weisbecker
    Cc: Li Zefan
    Cc: Tom Zanussi
    Cc: Arnaldo Carvalho de Melo
    Cc: Peter Zijlstra
    Cc: Mike Galbraith
    Cc: Steven Rostedt
    Cc: Paul Mackerras
    Cc: Pekka Enberg
    Cc: Gabriel Munteanu
    Cc: Lai Jiangshan
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     
  • Adds possible second part to the assign argument of TP_EVENT().

    TP_perf_assign(
    __perf_count(foo);
    __perf_addr(bar);
    )

    Which, when specified make the swcounter increment with @foo instead
    of the usual 1, and report @bar for PERF_SAMPLE_ADDR (data address
    associated with the event) when this triggers a counter overflow.

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

    Peter Zijlstra
     

20 Jul, 2009

2 commits

  • When a dynamic array is defined, we add __data_loc_foo in
    trace_entry to record the offset of the array, but the
    size of the array is not recorded, which causes 2 problems:

    - the event filter just compares the first 2 chars of the strings.

    - parsers can't parse dynamic arrays.

    So we encode the size of each dynamic array in the higher 16 bits
    of __data_loc_foo, while the offset is in lower 16 bits.

    Signed-off-by: Li Zefan
    LKML-Reference:
    Acked-by: Frederic Weisbecker
    Signed-off-by: Steven Rostedt

    Li Zefan
     
  • The format file doesn't contain enough information for
    __dynamic_array/__string. The type name is missing.

    Before:
    # cat format:
    name: irq_handler_entry
    ...
    field:__data_loc name; offset:16; size:2;

    After:
    # cat format:
    name: irq_handler_entry
    ...
    field:__data_loc char[] name; offset:16; size:2;

    Signed-off-by: Lai Jiangshan
    LKML-Reference:
    Signed-off-by: Li Zefan
    Acked-by: Frederic Weisbecker
    Signed-off-by: Steven Rostedt

    Lai Jiangshan
     

11 Jun, 2009

1 commit

  • By moving the macro that creates the print format code above the
    defining of the event macro helpers (__get_str, __print_symbolic,
    and __get_dynamic_array), we get a little cleaner print format.

    Instead of:

    (char *)((void *)REC + REC->__data_loc_name)

    we get:

    __get_str(name)

    Instead of:

    ({ static const struct trace_print_flags symbols[] = { { HI_SOFTIRQ, "HI" }, {

    we get:

    __print_symbolic(REC->vec, { HI_SOFTIRQ, "HI" }, {

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

03 Jun, 2009

1 commit

  • Here is an updated patch to include the extra call to
    trace_seq_init() as requested. This is vs. the latest
    -tip tree and fixes the use of multiple __print_flags
    and __print_symbolic in a single tracer. Also tested
    to ensure its working now:

    mount.gfs2-2534 [000] 235.850587: gfs2_glock_queue: 8.7 glock 1:2 dequeue PR
    mount.gfs2-2534 [000] 235.850591: gfs2_demote_rq: 8.7 glock 1:0 demote EX to NL flags:DI
    mount.gfs2-2534 [000] 235.850591: gfs2_glock_queue: 8.7 glock 1:0 dequeue EX
    glock_workqueue-2529 [000] 235.850666: gfs2_glock_state_change: 8.7 glock 1:0 state EX => NL tgt:NL dmt:NL flags:lDpI
    glock_workqueue-2529 [000] 235.850672: gfs2_glock_put: 8.7 glock 1:0 state NL => IV flags:I

    Signed-off-by: Steven Whitehouse
    LKML-Reference:
    Signed-off-by: Steven Rostedt

    Steven Whitehouse
     

02 Jun, 2009

3 commits

  • __string() is limited:

    - it's a char array, but we may want to define array with other types
    - a source string should be available, but we may just know the string size

    We introduce __dynamic_array() to break those limitations, and __string()
    becomes a wrapper of it. As a side effect, now __get_str() can be used
    in TP_fast_assign but not only TP_print.

    Take XFS for example, we have the string length in the dirent, but the
    string itself is not NULL-terminated, so __dynamic_array() can be used:

    TRACE_EVENT(xfs_dir2,
    TP_PROTO(struct xfs_da_args *args),
    TP_ARGS(args),

    TP_STRUCT__entry(
    __field(int, namelen)
    __dynamic_array(char, name, args->namelen + 1)
    ...
    ),

    TP_fast_assign(
    char *name = __get_str(name);

    if (args->namelen)
    memcpy(name, args->name, args->namelen);
    name[args->namelen] = '\0';

    __entry->namelen = args->namelen;
    ),

    TP_printk("name %.*s namelen %d",
    __entry->namelen ? __get_str(name) : NULL
    __entry->namelen)
    );

    [ Impact: allow defining dynamic size arrays ]

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

    Li Zefan
     
  • Currently TP_fast_assign has a limitation that we can't define local
    variables in it.

    Here's one use case when we introduce __dynamic_array():

    TP_fast_assign(
    type *p = __get_dynamic_array(item);

    foo(p);
    bar(p);
    ),

    [ Impact: allow defining local variables in TP_fast_assign ]

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

    Li Zefan
     
  • "tsize" should be "\tsize". Also remove the space before "__str_loc".

    Before:
    # cat tracing/events/irq/irq_handler_entry/format
    ...
    field:int irq; offset:12; size:4;
    field: __str_loc name; offset:16;tsize:2;
    ...

    After:
    # cat tracing/events/irq/irq_handler_entry/format
    ...
    field:int irq; offset:12; size:4;
    field:__str_loc name; offset:16; size:2;
    ...

    [ Impact: standardize __string field description in events format file ]

    Signed-off-by: Li Zefan
    Signed-off-by: Frederic Weisbecker
    Signed-off-by: Steven Rostedt

    Li Zefan
     

28 May, 2009

1 commit

  • "call" is an argument of macro, but it is also used as a local
    variable name of function in macro.
    We should keep this local variable name distinct from any
    CPP macro parameter name if both are in the same macro scope,
    although it hasn't caused any problem yet.

    [ Impact: robustify macro ]

    Signed-off-by: Zhao Lei
    Acked-by: Steven Rostedt
    Signed-off-by: Frederic Weisbecker

    Zhaolei
     

27 May, 2009

2 commits

  • This patch adds __print_symbolic which is similar to __print_flags but
    works for an enumeration type instead. That is, there is only a one to one
    mapping between the values and the symbols. When a match is made, then
    it is printed, otherwise the hex value is outputed.

    [ Impact: add interface for showing symbol names in events ]

    Signed-off-by: Steven Rostedt
    Signed-off-by: Frederic Weisbecker

    Steven Rostedt
     
  • Developers have been asking for the ability in the ftrace event tracer
    to display names of bits in a flags variable.

    Instead of printing out c2, it would be easier to read FOO|BAR|GOO,
    assuming that FOO is bit 1, BAR is bit 6 and GOO is bit 7.

    Some examples where this would be useful are the state flags in a context
    switch, kmalloc flags, and even permision flags in accessing files.

    [
    v2 changes include:

    Frederic Weisbecker's idea of using a mask instead of bits,
    thus we can output GFP_KERNEL instead of GPF_WAIT|GFP_IO|GFP_FS.

    Li Zefan's idea of allowing the caller of __print_flags to add their
    own delimiter (or no delimiter) where we can get for file permissions
    rwx instead of r|w|x.
    ]

    [
    v3 changes:

    Christoph Hellwig's idea of using an array instead of va_args.
    ]

    [ Impact: better displaying of flags in trace output ]

    Signed-off-by: Steven Rostedt
    Signed-off-by: Frederic Weisbecker

    Steven Rostedt
     

26 May, 2009

1 commit

  • When defining a dynamic size string, we add __str_loc_##item to the
    trace entry, and it stores the location of the actual string in
    entry->_str_data[]

    'unsigned short' should be sufficient to store this information, thus
    we save 2 bytes per dyn-size string in the ring buffer.

    [ Impact: reduce memory occupied by dyn-size strings in ring buffer ]

    Signed-off-by: Li Zefan
    Cc: Steven Rostedt
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Li Zefan
     

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


22 Apr, 2009

3 commits

  • The __get_str() macro is used in a code part then its content should be
    protected with parenthesis.

    [ Impact: make macro definition more robust ]

    Reported-by: Steven Rostedt
    Signed-off-by: Frederic Weisbecker

    Frederic Weisbecker
     
  • This patch provides the support for dynamic size strings on
    event tracing.

    The key concept is to use a structure with an ending char array field of
    undefined size and use such ability to allocate the minimal size on the
    ring buffer to make one or more string entries fit inside, as opposite
    to a fixed length strings with upper bound.

    The strings themselves are represented using fields which have an offset
    value from the beginning of the entry.

    This patch provides three new macros:

    __string(item, src)

    This one declares a string to the structure inside TP_STRUCT__entry.
    You need to provide the name of the string field and the source that will
    be copied inside.
    This will also add the dynamic size of the string needed for the ring
    buffer entry allocation.
    A stack allocated structure is used to temporarily store the offset
    of each strings, avoiding double calls to strlen() on each event
    insertion.

    __get_str(field)

    This one will give you a pointer to the string you have created. This
    is an abstract helper to resolve the absolute address given the field
    name which is a relative address from the beginning of the trace_structure.

    __assign_str(dst, src)

    Use this macro to automatically perform the string copy from src to
    dst. src must be a variable to assign and dst is the name of a __string
    field.

    Example on how to use it:

    TRACE_EVENT(my_event,
    TP_PROTO(char *src1, char *src2),

    TP_ARGS(src1, src2),
    TP_STRUCT__entry(
    __string(str1, src1)
    __string(str2, src2)
    ),
    TP_fast_assign(
    __assign_str(str1, src1);
    __assign_str(str2, src2);
    ),
    TP_printk("%s %s", __get_str(src1), __get_str(src2))
    )

    Of course you can mix-up any __field or __array inside this
    TRACE_EVENT. The position of the __string or __assign_str
    doesn't matter.

    Changes in v2:

    Address the suggestion of Steven Rostedt: drop the opening_string() macro
    and redefine __ending_string() to get the size of the string to be copied
    instead of overwritting the whole ring buffer allocation.

    Changes in v3:

    Address other suggestions of Steven Rostedt and Peter Zijlstra with
    some changes: drop the __ending_string and the need to have only one
    string field.
    Use offsets instead of absolute addresses.

    [ Impact: allow more compact memory usage for string tracing ]

    Signed-off-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Li Zefan
    Cc: Peter Zijlstra

    Frederic Weisbecker
     
  • struct trace_entry->type is unsigned char, while trace event's id is
    int type, thus for a event with id >= 256, it's entry->type is cast
    to (id % 256), and then we can't see the trace output of this event.

    # insmod trace-events-sample.ko
    # echo foo_bar > /mnt/tracing/set_event
    # cat /debug/tracing/events/trace-events-sample/foo_bar/id
    256
    # cat /mnt/tracing/trace_pipe
    -3548 [001] 215.091142: Unknown type 0
    -3548 [001] 216.089207: Unknown type 0
    -3548 [001] 217.087271: Unknown type 0
    -3548 [001] 218.085332: Unknown type 0

    [ Impact: fix output for trace events with id >= 256 ]

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

    Li Zefan
     

17 Apr, 2009

1 commit

  • Tracepoints with no arguments can issue two warnings:

    "field" defined by not used
    "ret" is uninitialized in this function

    Mark field as being OK to leave unused, and initialize ret.

    [ Impact: fix false positive compiler warnings. ]

    Signed-off-by: Jeremy Fitzhardinge
    Acked-by: Steven Rostedt
    Cc: mathieu.desnoyers@polymtl.ca
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Jeremy Fitzhardinge
     

15 Apr, 2009

1 commit

  • Impact: allow modules to add TRACE_EVENTS on load

    This patch adds the final hooks to allow modules to use the TRACE_EVENT
    macro. A notifier and a data structure are used to link the TRACE_EVENTs
    defined in the module to connect them with the ftrace event tracing system.

    It also adds the necessary automated clean ups to the trace events when a
    module is removed.

    Cc: Rusty Russell
    Signed-off-by: Steven Rostedt

    Steven Rostedt