1. 06 Mar, 2009 2 commits
    • Frederic Weisbecker's avatar
      vsprintf: unify the format decoding layer for its 3 users · fef20d9c
      Frederic Weisbecker authored
      An new optimization is making its way to ftrace. Its purpose is to
      make trace_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 trace_printk() will format the whole string and
      insert it into the ring buffer. 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.
      
      The new 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.
      
      Suggested by Ingo Molnar, this patch tries to factorize the most
      possible common bits from these functions.
      The real common part between them is the format decoding. Although
      they do somewhat similar jobs, their way to export or import the parameters
      is very different. Thus, only the decoding layer is extracted, unless you see
      other parts that could be worth factorized.
      
      Changes in V2:
      
      - Address a suggestion from Linus to group the format_decode() parameters inside
        a structure.
      
      Changes in v3:
      
      - Address other cleanups suggested by Ingo and Linus such as passing the
        printf_spec struct to the format helpers: pointer()/number()/string()
        Note that this struct is passed by copy and not by address. This is to
        avoid side effects because these functions often change these values and the
        changes shoudn't be persistant when a callee helper returns.
        It would be too risky.
      
      - Various cleanups (code alignement, switch/case instead of if/else fountains).
      
      - Fix a bug that printed the first format specifier following a %p
      
      Changes in v4:
      
      - drop unapropriate const qualifier loss while casting fmt to a char *
        (thanks to Vegard Nossum for having pointed this out).
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1236356510-8381-6-git-send-email-fweisbec@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      fef20d9c
    • Lai Jiangshan's avatar
      vsprintf: add binary printf · 4370aa4a
      Lai Jiangshan authored
      Impact: add new APIs for binary trace printk infrastructure
      
      vbin_printf(): write args to binary buffer, string is copied
      when "%s" is occurred.
      
      bstr_printf(): read from binary buffer for args and format a string
      
      [fweisbec@gmail.com: rebase]
      Signed-off-by: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      LKML-Reference: <1236356510-8381-2-git-send-email-fweisbec@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      4370aa4a
  2. 05 Feb, 2009 1 commit
    • Ingo Molnar's avatar
      printk: introduce printk_once() · f036be96
      Ingo Molnar authored
      This pattern shows up frequently in the kernel:
      
        static int once = 1;
        ...
      
      		if (once) {
      			once = 0;
      			printk(KERN_ERR "message\n");
      		}
        ...
      
      So add a printk_once() helper macro that reduces this to a single line
      of:
      
      		printk_once(KERN_ERR "message\n");
      
      It works analogously to WARN_ONCE() & friends. (We use a macro not
      an inline because vararg expansion in inlines looks awkward and the
      macro is simple enough.)
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      f036be96
  3. 04 Feb, 2009 37 commits