01 Nov, 2011

1 commit

  • Standardize the style for compiler based printf format verification.
    Standardized the location of __printf too.

    Done via script and a little typing.

    $ grep -rPl --include=*.[ch] -w "__attribute__" * | \
    grep -vP "^(tools|scripts|include/linux/compiler-gcc.h)" | \
    xargs perl -n -i -e 'local $/; while (<>) { s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf\s*,\s*(.+)\s*,\s*(.+)\s*\)\s*\)\s*\)/__printf($1, $2)/g ; print; }'

    [akpm@linux-foundation.org: revert arch bits]
    Signed-off-by: Joe Perches
    Cc: "Kirill A. Shutemov"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     

10 Dec, 2009

2 commits

  • The trace_seq buffer might fill up, and right now one needs to check the
    return value of each printf into the buffer to check for that.

    Instead, have the buffer keep track of whether it is full or not, and
    reject more input if it is full or would have overflowed with an input
    that wasn't added.

    Cc: Lai Jiangshan
    Signed-off-by: Johannes Berg
    Signed-off-by: Steven Rostedt

    Johannes Berg
     
  • If the seq_read fills the buffer it will call s_start again on the next
    itertation with the same position. This causes a problem with the
    function_graph tracer because it consumes the iteration in order to
    determine leaf functions.

    What happens is that the iterator stores the entry, and the function
    graph plugin will look at the next entry. If that next entry is a return
    of the same function and task, then the function is a leaf and the
    function_graph plugin calls ring_buffer_read which moves the ring buffer
    iterator forward (the trace iterator still points to the function start
    entry).

    The copying of the trace_seq to the seq_file buffer will fail if the
    seq_file buffer is full. The seq_read will not show this entry.
    The next read by userspace will cause seq_read to again call s_start
    which will reuse the trace iterator entry (the function start entry).
    But the function return entry was already consumed. The function graph
    plugin will think that this entry is a nested function and not a leaf.

    To solve this, the trace code now checks the return status of the
    seq_printf (trace_print_seq). If the writing to the seq_file buffer
    fails, we set a flag in the iterator (leftover) and we do not reset
    the trace_seq buffer. On the next call to s_start, we check the leftover
    flag, and if it is set, we just reuse the trace_seq buffer and do not
    call into the plugin print functions.

    Before this patch:

    2) | fput() {
    2) | __fput() {
    2) 0.550 us | inotify_inode_queue_event();
    2) | __fsnotify_parent() {
    2) 0.540 us | inotify_dentry_parent_queue_event();

    After the patch:

    2) | fput() {
    2) | __fput() {
    2) 0.550 us | inotify_inode_queue_event();
    2) 0.548 us | __fsnotify_parent();
    2) 0.540 us | inotify_dentry_parent_queue_event();

    [
    Updated the patch to fix a missing return 0 from the trace_print_seq()
    stub when CONFIG_TRACING is disabled.

    Reported-by: Ingo Molnar
    ]

    Reported-by: Jiri Olsa
    Cc: Frederic Weisbecker
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

24 Oct, 2009

1 commit


15 Jun, 2009

1 commit

  • when compiling linux-mips with kmemtrace enabled, there will be an
    error:

    include/linux/trace_seq.h:12: error: 'PAGE_SIZE' undeclared here (not in
    a function)

    I checked the source code and found trace_seq.h used PAGE_SIZE but not
    included the relative header file, so, fix it via adding the header file

    Acked-by: Frederic Weisbecker
    Acked-by: Pekka Enberg
    Signed-off-by: Wu Zhangjin
    LKML-Reference:
    Signed-off-by: Steven Rostedt

    Wu Zhangjin
     

10 Jun, 2009

1 commit


21 Apr, 2009

1 commit


18 Apr, 2009

1 commit

  • Due to a cut and paste error, I added the gcc attribute for printf
    format to the static inline stub of trace_seq_printf.

    This will cause a compile failure.

    [ Impact: fix compiler error when CONFIG_TRACING is off ]

    Reported-by: Ingo Molnar
    Signed-off-by: Steven Rostedt
    Cc: Andrew Morton
    Cc: =?ISO-8859-15?Q?Fr=E9d=E9ric_Weisbecker?=
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Steven Rostedt
     

15 Apr, 2009

2 commits

  • 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
     
  • In the process to make TRACE_EVENT macro work for modules, the trace_seq
    operations must be available for core kernel code.

    These operations are quite useful and can be used for other implementations.

    The main idea is that we create a trace_seq handle that acts very much
    like the seq_file handle.

    struct trace_seq *s = kmalloc(sizeof(*s, GFP_KERNEL);

    trace_seq_init(s);
    trace_seq_printf(s, "some data %d\n", variable);

    printk("%s", s->buffer);

    The main use is to allow a top level function call several other functions
    that may store printf like data into the buffer. Then at the end, the top
    level function can process all the data with any method it would like to.
    It could be passed to userspace, output via printk or even use seq_file:

    trace_seq_to_user(s, ubuf, cnt);
    seq_puts(m, s->buffer);

    Signed-off-by: Steven Rostedt

    Steven Rostedt