1. 03 4月, 2009 1 次提交
    • C
      blktrace: NUL-terminate user space messages · a4b3ada8
      Carl Henrik Lunde 提交于
      Impact: fix corrupted blkparse output
      
      Make sure messages from user space are NUL-terminated strings,
      otherwise we could dump random memory to the block trace file.
      
      Additionally, I've limited the message to BLK_TN_MAX_MSG-1
      characters, because the last character would be stripped by
      vscnprintf anyway.
      Signed-off-by: NCarl Henrik Lunde <chlunde@ping.uio.no>
      Cc: Li Zefan <lizf@cn.fujitsu.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: "Alan D. Brunelle" <alan.brunelle@hp.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <20090403122714.GT5178@kernel.dk>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      a4b3ada8
  2. 31 3月, 2009 9 次提交
    • L
      blktrace: print out BLK_TN_MESSAGE properly · 18cea459
      Li Zefan 提交于
      Impact: improve ftrace plugin output
      
      Before this patch:
      
       # cat trace
               make-5383  [001]   741.240059:   8,7    P   N [make]
       __trace_note_message: cfq1074
      
       # echo 1 > options/blk_classic
       # cat trace
         8,7    1     0.692221252     0  C   W 130411392 + 1024 [0]
       Bad pc action 6361
       Bad pc action 283d
      
       # echo 0 > options/blk_classic
       # echo bin > trace_options
       # cat trace_pipe | blkparse -i -
       (can't parse messages generated by blk_add_trace_msg())
      
      After this patch:
       # cat trace
            <idle>-0     [001]   187.600933:   8,7    C   W 145220224 + 8 [0]
            <idle>-0     [001]   187.600946:   8,7    m   N cfq1076 complete
      
       # echo 1 > options/blk_classic
       # cat trace
         8,7    1     0.256378996   238  I   W 113190728 + 8 [pdflush]
         8,7    1     0.256378998   238  m   N cfq1076 insert_request
      
       # echo 0 > options/blk_classic
       # echo bin > trace_options
       # cat trace_pipe | blkparse -i -
        8,7    1        0    22.973250293     0  C   W 102770576 + 8 [0]
        8,7    1        0    22.973259213     0  m   N cfq1076 complete
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: NJens Axboe <jens.axboe@oracle.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      18cea459
    • L
      blktrace: extract duplidate code · b6a4b0c3
      Li Zefan 提交于
      Impact: cleanup
      
      blk_trace_event_print() and blk_tracer_print_line() share most of the code.
      
         text    data     bss     dec     hex filename
         8605     393      12    9010    2332 kernel/trace/blktrace.o.orig
         text    data     bss     dec     hex filename
         8555     393      12    8960    2300 kernel/trace/blktrace.o
      
      This patch also prepares for the next patch, that prints out BLK_TN_MESSAGE.
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: NJens Axboe <jens.axboe@oracle.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      b6a4b0c3
    • L
      blktrace: fix memory leak when freeing struct blk_io_trace · ad5dd549
      Li Zefan 提交于
      Impact: fix mixed ioctl and ftrace-plugin blktrace use memory leak
      
      When mixing the use of ioctl-based blktrace and ftrace-based blktrace,
      we can leak memory in this way:
      
        # btrace /dev/sda > /dev/null &
        # echo 0 > /sys/block/sda/sda1/trace/enable
      
      now we leak bt->dropped_file, bt->msg_file, bt->rchan...
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: NJens Axboe <jens.axboe@oracle.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      ad5dd549
    • L
      blktrace: fix blk_probes_ref chaos · 17ba97e3
      Li Zefan 提交于
      Impact: fix mixed ioctl and ftrace-plugin blktrace use refcount bugs
      
      ioctl-based blktrace allocates bt and registers tracepoints when
      ioctl(BLKTRACESETUP), and do all cleanups when ioctl(BLKTRACETEARDOWN).
      
      while ftrace-based blktrace allocates/frees bt when:
        # echo 1/0 > /sys/block/sda/sda1/trace/enable
      
      and registers/unregisters tracepoints when:
        # echo blk/nop > /debugfs/tracing/current_tracer
      or
        # echo 1/0 > /debugfs/tracing/tracing_enable
      
      The separatation of allocation and registeration causes 2 problems:
      
        1. current user-space blktrace still calls ioctl(TEARDOWN) when
           ioctl(SETUP) failed:
             # echo 1 > /sys/block/sda/sda1/trace/enable
             # blktrace /dev/sda
               BLKTRACESETUP: Device or resource busy
               ^C
           and now blk_probes_ref == -1
      
        2. Another way to make blk_probes_ref == -1:
           # plugin sdb && mount sdb1
           # echo 1 > /sys/block/sdb/sdb1/trace/enable
           # remove sdb
      
      This patch does the allocation and registeration when writing
      sdaX/trace/enable.
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: NJens Axboe <jens.axboe@oracle.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      17ba97e3
    • L
      blktrace: make classic output more classic · 35ac51bf
      Li Zefan 提交于
      Impact: fix ftrace plugin timestamp output
      
      In the classic user-space blktrace, the output timestamp is sec.nsec
      not sec.usec.
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: NJens Axboe <jens.axboe@oracle.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      35ac51bf
    • L
      blktrace: fix off-by-one bug · eb08f8eb
      Li Zefan 提交于
      'what' is used as the index of array what2act, so it can't >= the array size.
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: NJens Axboe <jens.axboe@oracle.com>
      Acked-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      eb08f8eb
    • L
      blktrace: fix the original blktrace · 55547204
      Li Zefan 提交于
      Currently the original blktrace, which is using relay and is used via
      ioctl, is broken. You can use ftrace to see the output of blktrace,
      but user-space blktrace is unusable.
      
      It's broken by "blktrace: add ftrace plugin"
      (c71a8961)
      
       -	if (unlikely(bt->trace_state != Blktrace_running))
       +	if (unlikely(bt->trace_state != Blktrace_running || !blk_tracer_enabled))
      		return;
      
      With this patch, both ioctl and ftrace can be used, but of course you
      can't use both of them at the same time.
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: NJens Axboe <jens.axboe@oracle.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      55547204
    • L
      blktrace: fix a race when creating blk_tree_root in debugfs · b5230b56
      Li Zefan 提交于
      t1                                t2
      ------                            ------
      do_blk_trace_setup()              do_blk_trace_setup()
        if (!blk_tree_root) {
                                          if (!blk_tree_root)
          blk_tree_root = create_dir()
                                            blk_tree_root = create_dir();
                                            (now blk_tree_root == NULL)
        ...
        dir = create_dir(name, blk_tree_root);
      
      Due to this race, t1 will create 'dir' in /debugfs but not /debugfs/block.
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: NJens Axboe <jens.axboe@oracle.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      b5230b56
    • L
      blktrace: fix timestamp in binary output · 6c051ce0
      Li Zefan 提交于
      I found the timestamp is wrong:
      
       # echo bin > trace_option
       # echo blk > current_tracer
       # cat trace_pipe | blkparse -i -
       8,0    0        0     0.000000000   504  A   W ...
       ...
       8,7    1        0     0.008534097     0  C   R ...
                  (should be 8.534097xxx)
      
      user-space blkparse expects the timestamp to be nanosecond.
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: NJens Axboe <jens.axboe@oracle.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      6c051ce0
  3. 24 3月, 2009 4 次提交
  4. 21 3月, 2009 7 次提交
  5. 17 3月, 2009 1 次提交
    • S
      tracing: protect reader of cmdline output · 4ca53085
      Steven Rostedt 提交于
      Impact: fix to one cause of incorrect comm outputs in trace
      
      The spinlock only protected the creation of a comm <=> pid pair.
      But it was possible that a reader could look up a pid, and get the
      wrong comm because it had no locking.
      
      This also required changing trace_find_cmdline to copy the comm cache
      and not just send back a pointer to it.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      4ca53085
  6. 11 3月, 2009 1 次提交
  7. 05 3月, 2009 1 次提交
  8. 09 2月, 2009 1 次提交
  9. 06 2月, 2009 3 次提交
    • A
      trace: Call tracing_reset_online_cpus before tracer->init() · b6f11df2
      Arnaldo Carvalho de Melo 提交于
      Impact: cleanup
      
      To make it easy for ftrace plugin writers, as this was open coded in
      the existing plugins
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NFrédéric Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      b6f11df2
    • A
      tracing: Introduce trace_buffer_{lock_reserve,unlock_commit} · 51a763dd
      Arnaldo Carvalho de Melo 提交于
      Impact: new API
      
      These new functions do what previously was being open coded, reducing
      the number of details ftrace plugin writers have to worry about.
      
      It also standardizes the handling of stacktrace, userstacktrace and
      other trace options we may introduce in the future.
      
      With this patch, for instance, the blk tracer (and some others already
      in the tree) can use the "userstacktrace" /d/tracing/trace_options
      facility.
      
      $ codiff /tmp/vmlinux.before /tmp/vmlinux.after
      linux-2.6-tip/kernel/trace/trace.c:
        trace_vprintk              |   -5
        trace_graph_return         |  -22
        trace_graph_entry          |  -26
        trace_function             |  -45
        __ftrace_trace_stack       |  -27
        ftrace_trace_userstack     |  -29
        tracing_sched_switch_trace |  -66
        tracing_stop               |   +1
        trace_seq_to_user          |   -1
        ftrace_trace_special       |  -63
        ftrace_special             |   +1
        tracing_sched_wakeup_trace |  -70
        tracing_reset_online_cpus  |   -1
       13 functions changed, 2 bytes added, 355 bytes removed, diff: -353
      
      linux-2.6-tip/block/blktrace.c:
        __blk_add_trace |  -58
       1 function changed, 58 bytes removed, diff: -58
      
      linux-2.6-tip/kernel/trace/trace.c:
        trace_buffer_lock_reserve  |  +88
        trace_buffer_unlock_commit |  +86
       2 functions changed, 174 bytes added, diff: +174
      
      /tmp/vmlinux.after:
       16 functions changed, 176 bytes added, 413 bytes removed, diff: -237
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NFrédéric Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      51a763dd
    • A
      ring_buffer: remove unused flags parameter · 0a987751
      Arnaldo Carvalho de Melo 提交于
      Impact: API change, cleanup
      
      >From ring_buffer_{lock_reserve,unlock_commit}.
      
      $ codiff /tmp/vmlinux.before /tmp/vmlinux.after
      linux-2.6-tip/kernel/trace/trace.c:
        trace_vprintk              |  -14
        trace_graph_return         |  -14
        trace_graph_entry          |  -10
        trace_function             |   -8
        __ftrace_trace_stack       |   -8
        ftrace_trace_userstack     |   -8
        tracing_sched_switch_trace |   -8
        ftrace_trace_special       |  -12
        tracing_sched_wakeup_trace |   -8
       9 functions changed, 90 bytes removed, diff: -90
      
      linux-2.6-tip/block/blktrace.c:
        __blk_add_trace |   -1
       1 function changed, 1 bytes removed, diff: -1
      
      /tmp/vmlinux.after:
       10 functions changed, 91 bytes removed, diff: -91
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NFrédéric Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      0a987751
  10. 05 2月, 2009 4 次提交
  11. 03 2月, 2009 3 次提交
  12. 30 1月, 2009 1 次提交
  13. 29 1月, 2009 1 次提交
  14. 27 1月, 2009 1 次提交
  15. 26 1月, 2009 1 次提交
    • A
      blktrace: add ftrace plugin · c71a8961
      Arnaldo Carvalho de Melo 提交于
      Impact: New way of using the blktrace infrastructure
      
      This drops the requirement of userspace utilities to use the blktrace
      facility.
      
      Configuration is done thru sysfs, adding a "trace" directory to the
      partition directory where blktrace can be enabled for the associated
      request_queue.
      
      The same filters present in the IOCTL interface are present as sysfs
      device attributes.
      
      The /sys/block/sdX/sdXN/trace/enable file allows tracing without any
      filters.
      
      The other files in this directory: pid, act_mask, start_lba and end_lba
      can be used with the same meaning as with the IOCTL interface.
      
      Using the sysfs interface will only setup the request_queue->blk_trace
      fields, tracing will only take place when the "blk" tracer is selected
      via the ftrace interface, as in the following example:
      
      To see the trace, one can use the /d/tracing/trace file or the
      /d/tracign/trace_pipe file, with semantics defined in the ftrace
      documentation in Documentation/ftrace.txt.
      
      [root@f10-1 ~]# cat /t/trace
             kjournald-305   [000]  3046.491224:   8,1    A WBS 6367 + 8 <- (8,1) 6304
             kjournald-305   [000]  3046.491227:   8,1    Q   R 6367 + 8 [kjournald]
             kjournald-305   [000]  3046.491236:   8,1    G  RB 6367 + 8 [kjournald]
             kjournald-305   [000]  3046.491239:   8,1    P  NS [kjournald]
             kjournald-305   [000]  3046.491242:   8,1    I RBS 6367 + 8 [kjournald]
             kjournald-305   [000]  3046.491251:   8,1    D  WB 6367 + 8 [kjournald]
             kjournald-305   [000]  3046.491610:   8,1    U  WS [kjournald] 1
                <idle>-0     [000]  3046.511914:   8,1    C  RS 6367 + 8 [6367]
      [root@f10-1 ~]#
      
      The default line context (prefix) format is the one described in the ftrace
      documentation, with the blktrace specific bits using its existing format,
      described in blkparse(8).
      
      If one wants to have the classic blktrace formatting, this is possible by
      using:
      
      [root@f10-1 ~]# echo blk_classic > /t/trace_options
      [root@f10-1 ~]# cat /t/trace
        8,1    0  3046.491224   305  A WBS 6367 + 8 <- (8,1) 6304
        8,1    0  3046.491227   305  Q   R 6367 + 8 [kjournald]
        8,1    0  3046.491236   305  G  RB 6367 + 8 [kjournald]
        8,1    0  3046.491239   305  P  NS [kjournald]
        8,1    0  3046.491242   305  I RBS 6367 + 8 [kjournald]
        8,1    0  3046.491251   305  D  WB 6367 + 8 [kjournald]
        8,1    0  3046.491610   305  U  WS [kjournald] 1
        8,1    0  3046.511914     0  C  RS 6367 + 8 [6367]
      [root@f10-1 ~]#
      
      Using the ftrace standard format allows more flexibility, such
      as the ability of asking for backtraces via trace_options:
      
      [root@f10-1 ~]# echo noblk_classic > /t/trace_options
      [root@f10-1 ~]# echo stacktrace > /t/trace_options
      
      [root@f10-1 ~]# cat /t/trace
             kjournald-305   [000]  3318.826779:   8,1    A WBS 6375 + 8 <- (8,1) 6312
             kjournald-305   [000]  3318.826782:
       <= submit_bio
       <= submit_bh
       <= sync_dirty_buffer
       <= journal_commit_transaction
       <= kjournald
       <= kthread
       <= child_rip
             kjournald-305   [000]  3318.826836:   8,1    Q   R 6375 + 8 [kjournald]
             kjournald-305   [000]  3318.826837:
       <= generic_make_request
       <= submit_bio
       <= submit_bh
       <= sync_dirty_buffer
       <= journal_commit_transaction
       <= kjournald
       <= kthread
      
      Please read the ftrace documentation to use aditional, standardized
      tracing filters such as /d/tracing/trace_cpumask, etc.
      
      See also /d/tracing/trace_mark to add comments in the trace stream,
      that is equivalent to the /d/block/sdaN/msg interface.
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      c71a8961
  16. 26 11月, 2008 1 次提交