1. 08 Mar, 2009 2 commits
    • KOSAKI Motohiro's avatar
      ftrace: tracing header should put '#' at the beginning of a line · 888b55dc
      KOSAKI Motohiro authored
      In a recent discussion, Andrew Morton pointed out that tracing header
      should put '#' at the beginning of a line.
      
      Then, we can easily filtered the header by following grep usage:
      
        cat trace | grep -v '^#'
      
      Wakeup trace also has the same header problem.
      
      Comparison of headers displayed:
      
      before this patch:
      
       # tracer: wakeup
       #
       wakeup latency trace v1.1.5 on 2.6.29-rc7-tip-tip
       --------------------------------------------------------------------
        latency: 19059 us, #21277/21277, CPU#1 | (M:desktop VP:0, KP:0, SP:0 HP:0 #P:4)
           -----------------
           | task: kondemand/1-1644 (uid:0 nice:-5 policy:0 rt_prio:0)
           -----------------
      
       #                  _------=> CPU#
       #                 / _-----=> irqs-off
       #                | / _----=> need-resched
       #                || / _---=> hardirq/softirq
       #                ||| / _--=> preempt-depth
       #                |||| /
       #                |||||     delay
       #  cmd     pid   ||||| time  |   caller
       #     \   /      |||||   \   |   /
       irqbalan-1887    1d.s.    0us :   1887:120:R   + [001]  1644:115:S kondemand/1
       irqbalan-1887    1d.s.    1us : default_wake_function <-autoremove_wake_function
       irqbalan-1887    1d.s.    2us : check_preempt_wakeup <-try_to_wake_up
      
      after this patch:
      
       # tracer: wakeup
       #
       # wakeup latency trace v1.1.5 on 2.6.29-rc7-tip-tip
       # --------------------------------------------------------------------
       # latency: 529 us, #530/530, CPU#0 | (M:desktop VP:0, KP:0, SP:0 HP:0 #P:4)
       #    -----------------
       #    | task: kondemand/0-1641 (uid:0 nice:-5 policy:0 rt_prio:0)
       #    -----------------
       #
       #                  _------=> CPU#
       #                 / _-----=> irqs-off
       #                | / _----=> need-resched
       #                || / _---=> hardirq/softirq
       #                ||| / _--=> preempt-depth
       #                |||| /
       #                |||||     delay
       #  cmd     pid   ||||| time  |   caller
       #     \   /      |||||   \   |   /
           sshd-2496    0d.s.    0us :   2496:120:R   + [000]  1641:115:S kondemand/0
           sshd-2496    0d.s.    1us : default_wake_function <-autoremove_wake_function
           sshd-2496    0d.s.    1us : check_preempt_wakeup <-try_to_wake_up
      Signed-off-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      LKML-Reference: <20090308124421.23C3.A69D9226@jp.fujitsu.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      888b55dc
    • Ingo Molnar's avatar
      Merge branches 'tracing/doc', 'tracing/ftrace', 'tracing/printk' and... · dba58e39
      Ingo Molnar authored
      Merge branches 'tracing/doc', 'tracing/ftrace', 'tracing/printk' and 'tracing/textedit' into tracing/core
      dba58e39
  2. 06 Mar, 2009 20 commits
    • Ingo Molnar's avatar
      tracing: trace_bprintk() cleanups · 9de36825
      Ingo Molnar authored
      Impact: cleanup
      
      Remove a few leftovers and clean up the code a bit.
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1236356510-8381-5-git-send-email-fweisbec@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      9de36825
    • Frederic Weisbecker's avatar
      tracing/core: drop the old trace_printk() implementation in favour of trace_bprintk() · 769b0441
      Frederic Weisbecker authored
      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: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1236356510-8381-5-git-send-email-fweisbec@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      769b0441
    • Lai Jiangshan's avatar
      tracing: add trace_bprintk() · 1ba28e02
      Lai Jiangshan authored
      Impact: add a generic printk() for tracing, like trace_printk()
      
      trace_bprintk() uses the infrastructure to record events on ring_buffer.
      
      [ fweisbec@gmail.com: ported to latest -tip, made it work if
        !CONFIG_MODULES, never free the format strings from modules
        because we can't keep track of them and conditionnaly create
        the ftrace format strings section (reported by Steven Rostedt) ]
      Signed-off-by: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1236356510-8381-4-git-send-email-fweisbec@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      1ba28e02
    • Lai Jiangshan's avatar
      tracing: infrastructure for supporting binary record · 1427cdf0
      Lai Jiangshan authored
      Impact: save on memory for tracing
      
      Current tracers are typically using a struct(like struct ftrace_entry,
      struct ctx_switch_entry, struct special_entr etc...)to record a binary
      event. These structs can only record a their own kind of events.
      A new kind of tracer need a new struct and a lot of code too handle it.
      
      So we need a generic binary record for events. This infrastructure
      is for this purpose.
      
      [fweisbec@gmail.com: rebase against latest -tip, make it safe while sched
      tracing as reported by Steven Rostedt]
      Signed-off-by: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1236356510-8381-3-git-send-email-fweisbec@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      1427cdf0
    • Ingo Molnar's avatar
      546e5354
    • 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
    • Masami Hiramatsu's avatar
      x86: implement atomic text_poke() via fixmap · 78ff7fae
      Masami Hiramatsu authored
      Use fixmaps instead of vmap/vunmap in text_poke() for avoiding
      page allocation and delayed unmapping.
      
      At the result of above change, text_poke() becomes atomic and can be called
      from stop_machine() etc.
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
      Acked-by: default avatarMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
      LKML-Reference: <49B14352.2040705@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      78ff7fae
    • Masami Hiramatsu's avatar
      tracing, Text Edit Lock - SMP alternatives support · 3945dab4
      Masami Hiramatsu authored
      Use the mutual exclusion provided by the text edit lock in alternatives code.
      Since alternative_smp_* will be called from module init code, etc,
      we'd better protect it from other subsystems.
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
      LKML-Reference: <49B14332.9030109@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      3945dab4
    • Mathieu Desnoyers's avatar
      tracing, Text Edit Lock - kprobes architecture independent support · 4460fdad
      Mathieu Desnoyers authored
      Use the mutual exclusion provided by the text edit lock in the kprobes code. It
      allows coherent manipulation of the kernel code by other subsystems.
      
      Changelog:
      
      Move the kernel_text_lock/unlock out of the for loops.
      Use text_mutex directly instead of a function.
      Remove whitespace modifications.
      
      (note : kprobes_mutex is always taken outside of text_mutex)
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
      Acked-by: default avatarAnanth N Mavinakayanahalli <ananth@in.ibm.com>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
      LKML-Reference: <49B14306.2080202@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      4460fdad
    • Mathieu Desnoyers's avatar
      tracing, Text Edit Lock - Architecture Independent Code · 0e39ac44
      Mathieu Desnoyers authored
      This is an architecture independant synchronization around kernel text
      modifications through use of a global mutex.
      
      A mutex has been chosen so that kprobes, the main user of this, can sleep
      during memory allocation between the memory read of the instructions it
      must replace and the memory write of the breakpoint.
      
      Other user of this interface: immediate values.
      
      Paravirt and alternatives are always done when SMP is inactive, so there
      is no need to use locks.
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
      LKML-Reference: <49B142D8.7020601@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      0e39ac44
    • Ingo Molnar's avatar
      Merge branch 'x86/core' into tracing/textedit · f0ef0398
      Ingo Molnar authored
      Conflicts:
      	arch/x86/Kconfig
      	block/blktrace.c
      	kernel/irq/handle.c
      
      Semantic conflict:
      	kernel/trace/blktrace.c
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      f0ef0398
    • Ingo Molnar's avatar
      tracing, power-trace: make it build even if the power-tracer is turned off · af438c0f
      Ingo Molnar authored
      Impact: build fix
      
      The 'struct power_trace' definition is needed (for the event tracer) even if
      the power-tracer plugin is turned off in the .config.
      
      Cc: Steven Rostedt <srostedt@redhat.com>
      LKML-Reference: <20090306104106.GF31042@elte.hu>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      af438c0f
    • KOSAKI Motohiro's avatar
      tracing: fix deadlock when setting set_ftrace_pid · 10dd3ebe
      KOSAKI Motohiro authored
      Impact: fix deadlock while using set_ftrace_pid
      
      Reproducer:
      
      	# cd /sys/kernel/debug/tracing
      	# echo $$ > set_ftrace_pid
      
      	then, console becomes hung.
      
      Details:
      
      when writing set_ftracepid, kernel callstack is following
      
      	ftrace_pid_write()
      		mutex_lock(&ftrace_lock);
      		ftrace_update_pid_func()
      			mutex_lock(&ftrace_lock);
      			mutex_unlock(&ftrace_lock);
      		mutex_unlock(&ftrace_lock);
      
      then, system always deadlocks when ftrace_pid_write() is called.
      
      In past days, ftrace_pid_write() used ftrace_start_lock, but
      commit e6ea44e9 consolidated
      ftrace_start_lock to ftrace_lock.
      Signed-off-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Reviewed-by: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
      Cc: Steven Rostedt <srostedt@redhat.com>
      LKML-Reference: <20090306151155.0778.A69D9226@jp.fujitsu.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      10dd3ebe
    • KOSAKI Motohiro's avatar
      tracing: current tip/master can't enable ftrace · 422d3c7a
      KOSAKI Motohiro authored
      After commit 40ada30f,
      "make menuconfig" doesn't display "Tracer" item.
      
      Following modification restores it.
      422d3c7a
    • Ingo Molnar's avatar
      Merge branch 'tip/tracing/ftrace' of... · bc722f50
      Ingo Molnar authored
      Merge branch 'tip/tracing/ftrace' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into tracing/ftrace
      bc722f50
    • Ingo Molnar's avatar
    • Steven Rostedt's avatar
      tracing: add format files for ftrace default entries · 770cb243
      Steven Rostedt authored
      Impact: allow user apps to read binary format of basic ftrace entries
      
      Currently, only defined raw events export their formats so a binary
      reader can parse them. There's no reason that the default ftrace entries
      can't export their formats.
      
      This patch adds a subsystem called "ftrace" in the events directory
      that includes the ftrace entries for basic ftrace recorded items.
      
      These only have three files in the events directory:
      
       type             : printf
       available_types  : printf
       format           : format for the event entry
      
      For example:
      
       # cat /debug/tracing/events/ftrace/wakeup/format
      name: wakeup
      ID: 3
      format:
              field:unsigned char type;       offset:0;       size:1;
              field:unsigned char flags;      offset:1;       size:1;
              field:unsigned char preempt_count;      offset:2;       size:1;
              field:int pid;  offset:4;       size:4;
              field:int tgid; offset:8;       size:4;
      
              field:unsigned int prev_pid;    offset:12;      size:4;
              field:unsigned char prev_prio;  offset:16;      size:1;
              field:unsigned char prev_state; offset:17;      size:1;
              field:unsigned int next_pid;    offset:20;      size:4;
              field:unsigned char next_prio;  offset:24;      size:1;
              field:unsigned char next_state; offset:25;      size:1;
              field:unsigned int next_cpu;    offset:28;      size:4;
      
      print fmt: "%u:%u:%u  ==+ %u:%u:%u [%03u]"
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      770cb243
    • Steven Rostedt's avatar
      tracing: move print of event format to separate file · 33b0c229
      Steven Rostedt authored
      Impact: clean up
      
      Move the macro that creates the event format file to a separate header.
      This will allow the default ftrace events to use this same macro
      to create the formats to read those events.
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      33b0c229
    • Steven Rostedt's avatar
      tracing: make all file_operations const · 5e2336a0
      Steven Rostedt authored
      Impact: cleanup
      
      All file_operations structures should be constant. No one is going to
      change them.
      Reported-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      5e2336a0
  3. 05 Mar, 2009 18 commits