[lkml]   [2009]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH][RFC] vsprintf: unify the format decoding layer for its 3 users
    On Thu, Feb 26, 2009 at 10:46:56PM -0800, Andrew Morton wrote:
    > On Fri, 27 Feb 2009 07:19:37 +0100 Frederic Weisbecker <> wrote:
    > >
    > > An new optimization is making its way to ftrace. Its purpose is to
    > > make ftrace_printk() consuming less memory and be faster.
    > >
    > > Written by Lai Jiangshan, the approach is to delay the formatting
    > > job from tracing time to output time.
    > > Currently, a call to ftrace_printk will format the whole string and
    > > insert it into the ring buffer.
    > It does that? eek.
    > > Then you can read it on /debug/tracing/trace
    > > file.
    > >
    > > The new implementation stores the address of the format string and
    > > the binary parameters into the ring buffer, making the packet more compact
    > > and faster to insert.
    > > Later, when the user exports the traces, the format string is retrieved
    > > with the binary parameters and the formatting job is eventually done.
    > >
    > > Here is the result of a small comparative benchmark while putting the following
    > > ftrace_printk on the timer interrupt. ftrace_printk is the old implementation,
    > > ftrace_bprintk is a the new one:
    > >
    > > ftrace_printk("This is the timer interrupt: %llu", jiffies_64);
    > >
    > > After some time running on low load (no X, no really active processes):
    > >
    > > ftrace_printk: duration average: 2044 ns, avg of bytes stored per entry: 39
    > > ftrace_bprintk: duration average: 1426 ns, avg of bytes stored per entry: 16
    > >
    > > Higher load (started X and launched a cat running on an X console looping on
    > > traces printing):
    > >
    > > ftrace_printk: duration average: 8812 ns
    > > ftrace_bprintk: duration average: 2611 ns
    > >
    > > Which means the new implementation can be 70 % faster on higher load.
    > > And it consumes lesser memory on the ring buffer.
    > >
    > > The curent implementation rewrites a lot of format decoding bits from
    > > vsnprintf() function, making now 3 differents functions to maintain
    > > in their duplicated parts of printf format decoding bits.
    > <looks for ftrace_bprintk() in linux-next, fails>

    It hasn't been applied for now, waiting for this cleanup.
    Grr, I can't find an http link for the patchset...

    > Why does the current ftrace_bprintk() need to hack around in (or
    > duplicate) vprintk() internals? It's a bit grubby, but by placing an
    > upper bound on the number of args, it could simply call vscnprintf()
    > directly?

    The problem is more in the way to save the parameters.

    You have two functions:

    _int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args)

    This one creates a compact binary packet of all args described in the format.
    The result is a binary set of random values on bin_buf.

    _int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)

    This one lately parses the buffer filled by vbin_printf() and eventually format
    this binary contiguous set of binary values according to the format in fmt (which is the
    same that was passed to vbin_printf()
    The result is formatted in buf.

    vbin uses too much specific write-to-bin_buf operations to allow us to wrap

    It's the same for bstr_printf, but in the read from buffer way.

     \ /
      Last update: 2009-02-27 08:15    [W:0.028 / U:3.852 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site