23 Jan, 2015

2 commits


14 Nov, 2014

1 commit

  • Printing a single character to a seqfile might as well be done with
    seq_putc instead of seq_puts; this avoids a strlen() call and a memory
    access. It also shaves another few bytes off the generated code.

    Link: http://lkml.kernel.org/r/1415479332-25944-4-git-send-email-linux@rasmusvillemoes.dk

    Signed-off-by: Rasmus Villemoes
    Signed-off-by: Steven Rostedt

    Rasmus Villemoes
     

27 Jul, 2013

1 commit

  • There are several tracepoints (mostly in RCU), that reference a string
    pointer and uses the print format of "%s" to display the string that
    exists in the kernel, instead of copying the actual string to the
    ring buffer (saves time and ring buffer space).

    But this has an issue with userspace tools that read the binary buffers
    that has the address of the string but has no access to what the string
    itself is. The end result is just output that looks like:

    rcu_dyntick: ffffffff818adeaa 1 0
    rcu_dyntick: ffffffff818adeb5 0 140000000000000
    rcu_dyntick: ffffffff818adeb5 0 140000000000000
    rcu_utilization: ffffffff8184333b
    rcu_utilization: ffffffff8184333b

    The above is pretty useless when read by the userspace tools. Ideally
    we would want something that looks like this:

    rcu_dyntick: Start 1 0
    rcu_dyntick: End 0 140000000000000
    rcu_dyntick: Start 140000000000000 0
    rcu_callback: rcu_preempt rhp=0xffff880037aff710 func=put_cred_rcu 0/4
    rcu_callback: rcu_preempt rhp=0xffff880078961980 func=file_free_rcu 0/5
    rcu_dyntick: End 0 1

    The trace_printk() which also only stores the address of the string
    format instead of recording the string into the buffer itself, exports
    the mapping of kernel addresses to format strings via the printk_format
    file in the debugfs tracing directory.

    The tracepoint strings can use this same method and output the format
    to the same file and the userspace tools will be able to decipher
    the address without any modification.

    The tracepoint strings need its own section to save the strings because
    the trace_printk section will cause the trace_printk() buffers to be
    allocated if anything exists within the section. trace_printk() is only
    used for debugging and should never exist in the kernel, we can not use
    the trace_printk sections.

    Add a new tracepoint_str section that will also be examined by the output
    of the printk_format file.

    Cc: Paul E. McKenney
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     

24 Apr, 2012

1 commit

  • Currently, trace_printk() uses a single buffer to write into
    to calculate the size and format needed to save the trace. To
    do this safely in an SMP environment, a spin_lock() is taken
    to only allow one writer at a time to the buffer. But this could
    also affect what is being traced, and add synchronization that
    would not be there otherwise.

    Ideally, using percpu buffers would be useful, but since trace_printk()
    is only used in development, having per cpu buffers for something
    never used is a waste of space. Thus, the use of the trace_bprintk()
    format section is changed to be used for static fmts as well as dynamic ones.
    Then at boot up, we can check if the section that holds the trace_printk
    formats is non-empty, and if it does contain something, then we
    know a trace_printk() has been added to the kernel. At this time
    the trace_printk per cpu buffers are allocated. A check is also
    done at module load time in case a module is added that contains a
    trace_printk().

    Once the buffers are allocated, they are never freed. If you use
    a trace_printk() then you should know what you are doing.

    A buffer is made for each type of context:

    normal
    softirq
    irq
    nmi

    The context is checked and the appropriate buffer is used.
    This allows for totally lockless usage of trace_printk(),
    and they no longer even disable interrupts.

    Requested-by: Peter Zijlstra
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

11 Aug, 2011

1 commit


09 Jun, 2011

1 commit

  • The fix to fix the printk_formats of modules broke the
    printk_formats of trace_printks in the kernel.

    The update of what to show via the seq_file was only updated
    if the passed in fmt was NULL, which happens only on the first
    iteration. The result was showing the first format every time
    instead of iterating through the available formats.

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

05 Apr, 2011

2 commits

  • The file debugfs/tracing/printk_formats maps the addresses
    to the formats that are used by trace_bprintk() so that userspace
    tools can read the buffer and be able to decode trace_bprintk events
    to get the format saved when reading the ring buffer directly.

    This is because trace_bprintk() does not store the format into the
    buffer, but just the address of the format, which is hidden in
    the kernel memory.

    But currently it only exports trace_bprintk()s from the kernel core
    and not for modules. The modules need their formats exported
    as well.

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     
  • The trace_printk() formats for modules do not show up in the
    debugfs/tracing/printk_formats file. Only the formats that are
    for trace_printk()s that are in the kernel core.

    To facilitate the change to add trace_printk() formats from modules
    into that file as well, we need to convert the structure that
    holds the formats from char fmt[], into const char *fmt,
    and allocate them separately.

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

19 Sep, 2009

1 commit

  • Now that the last users of markers have migrated to the event
    tracer we can kill off the (now orphan) support code.

    Signed-off-by: Christoph Hellwig
    Acked-by: Mathieu Desnoyers
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Christoph Hellwig
     

23 Jul, 2009

1 commit

  • Since the trace_printk may use pointers to the format fields
    in the buffer, they are exported via debugfs/tracing/printk_formats.
    This is used by utilities that read the ring buffer in binary format.
    It helps the utilities map the address of the format in the binary
    buffer to what the printf format looks like.

    Unfortunately, the way the output code works, it exports the address
    of the pointer to the format address, and not the format address
    itself. This makes the file totally useless in trying to figure
    out what format string a binary address belongs to.

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

24 Jun, 2009

1 commit

  • It's wrong to increment @pos in t_start(), otherwise we'll lose
    some entries when reading printk_formats, if the output is larger
    than PAGE_SIZE.

    Reported-by: Lai Jiangshan
    Reviewed-by: Liming Wang
    Signed-off-by: Li Zefan
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Li Zefan
     

07 Apr, 2009

1 commit


20 Mar, 2009

1 commit


13 Mar, 2009

2 commits

  • The binary printk saves a pointer to the format string in the ring buffer.
    On output, the format is processed. But if the user is reading the
    ring buffer through a binary interface, the pointer is meaningless.

    This patch creates a file called printk_formats that maps the pointers
    to the formats.

    # cat /debug/tracing/printk_formats
    0xffffffff80713d40 : "irq_handler_entry: irq=%d handler=%s\n"
    0xffffffff80713d48 : "lock_acquire: %s%s%s\n"
    0xffffffff80713d50 : "lock_release: %s\n"

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     
  • Impact: fix callsites with dynamic format strings

    Since its new binary implementation, trace_printk() internally uses static
    containers for the format strings on each callsites. But the value is
    assigned once at build time, which means that it can't take dynamic
    formats.

    So this patch unearthes the raw trace_printk implementation for the callers
    that will need trace_printk to be able to carry these dynamic format
    strings. The trace_printk() macro will use the appropriate implementation
    for each callsite. Most of the time however, the binary implementation will
    still be used.

    The other impact of this patch is that mmiotrace_printk() will use the old
    implementation because it calls the low level trace_vprintk and we can't
    guess here whether the format passed in it is dynamic or not.

    Some parts of this patch have been written by Steven Rostedt (most notably
    the part that chooses the appropriate implementation for each callsites).

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

    Frederic Weisbecker
     

07 Mar, 2009

1 commit

  • Impact: faster and lighter tracing

    Now that we have trace_bprintk() which is faster and consume lesser
    memory than trace_printk() and has the same purpose, we can now drop
    the old implementation in favour of the binary one from trace_bprintk(),
    which means we move all the implementation of trace_bprintk() to
    trace_printk(), so the Api doesn't change except that we must now use
    trace_seq_bprintk() to print the TRACE_PRINT entries.

    Some changes result of this:

    - Previously, trace_bprintk depended of a single tracer and couldn't
    work without. This tracer has been dropped and the whole implementation
    of trace_printk() (like the module formats management) is now integrated
    in the tracing core (comes with CONFIG_TRACING), though we keep the file
    trace_printk (previously trace_bprintk.c) where we can find the module
    management. Thus we don't overflow trace.c

    - changes some parts to use trace_seq_bprintk() to print TRACE_PRINT entries.

    - change a bit trace_printk/trace_vprintk macros to support non-builtin formats
    constants, and fix 'const' qualifiers warnings. But this is all transparent for
    developers.

    - etc...

    V2:

    - Rebase against last changes
    - Fix mispell on the changelog

    V3:

    - Rebase against last changes (moving trace_printk() to kernel.h)

    Signed-off-by: Frederic Weisbecker
    Acked-by: Steven Rostedt
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker