1. 05 3月, 2009 1 次提交
    • S
      ring-buffer: fix timestamp in partial ring_buffer_page_read · 4f3640f8
      Steven Rostedt 提交于
      If a partial ring_buffer_page_read happens, then some of the
      incremental timestamps may be lost. This patch writes the
      recent timestamp into the page that is passed back to the caller.
      
      A partial ring_buffer_page_read is where the full page would not
      be written back to the user, and instead, just part of the page
      is copied to the user. A full page would be a page swap with the
      ring buffer and the timestamps would be correct.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      4f3640f8
  2. 04 3月, 2009 4 次提交
  3. 27 2月, 2009 1 次提交
  4. 17 2月, 2009 1 次提交
  5. 13 2月, 2009 1 次提交
    • S
      ring-buffer: rename label out_unlock to out_reset · 45141d46
      Steven Rostedt 提交于
      Impact: clean up
      
      While reviewing the ring buffer code, I thougth I saw a bug with
      
      	if (!__raw_spin_trylock(&cpu_buffer->lock))
      		goto out_unlock;
      
      But I forgot that we use a variable "lock_taken" that is set if
      the spinlock is taken, and only unlock it if that variable is set.
      
      To avoid further confusion from other reviewers, this patch
      renames the label out_unlock with out_reset, which is the more
      appropriate name.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      45141d46
  6. 11 2月, 2009 3 次提交
    • A
      ring_buffer: pahole struct ring_buffer · 00f62f61
      Arnaldo Carvalho de Melo 提交于
      While fixing some bugs in pahole (built-in.o files were not being
      processed due to relocation problems) I found out about these packable
      structures:
      
      $ pahole --packable kernel/trace/ring_buffer.o  | grep ring
      ring_buffer	72	64	8
      ring_buffer_per_cpu	112	104	8
      
      If we take a look at the current layout of struct ring_buffer we can see
      that we have two 4 bytes holes.
      
      $ pahole -C ring_buffer kernel/trace/ring_buffer.o
      struct ring_buffer {
      	unsigned int               pages;           /*     0     4 */
      	unsigned int               flags;           /*     4     4 */
      	int                        cpus;            /*     8     4 */
      
      	/* XXX 4 bytes hole, try to pack */
      
      	cpumask_var_t              cpumask;         /*    16     8 */
      	atomic_t                   record_disabled; /*    24     4 */
      
      	/* XXX 4 bytes hole, try to pack */
      
      	struct mutex               mutex;           /*    32    32 */
      	/* --- cacheline 1 boundary (64 bytes) --- */
      	struct ring_buffer_per_cpu * * buffers;     /*    64     8 */
      
      	/* size: 72, cachelines: 2, members: 7 */
      	/* sum members: 64, holes: 2, sum holes: 8 */
      	/* last cacheline: 8 bytes */
      };
      
      So, if I ask pahole to reorganize it:
      
      $ pahole -C ring_buffer --reorganize kernel/trace/ring_buffer.o
      
      struct ring_buffer {
      	unsigned int               pages;           /*     0     4 */
      	unsigned int               flags;           /*     4     4 */
      	int                        cpus;            /*     8     4 */
      	atomic_t                   record_disabled; /*    12     4 */
      	cpumask_var_t              cpumask;         /*    16     8 */
      	struct mutex               mutex;           /*    24    32 */
      	struct ring_buffer_per_cpu * * buffers;     /*    56     8 */
      	/* --- cacheline 1 boundary (64 bytes) --- */
      
      	/* size: 64, cachelines: 1, members: 7 */
      };   /* saved 8 bytes and 1 cacheline! */
      
      We get it using just one 64 bytes cacheline.
      
      To see what it did:
      
      $ pahole -C ring_buffer --reorganize --show_reorg_steps \
      	kernel/trace/ring_buffer.o | grep \/
      /* Moving 'record_disabled' from after 'cpumask' to after 'cpus' */
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      00f62f61
    • H
      tracing: fix sparse warnings: fix (un-)signedness · 5e39841c
      Hannes Eder 提交于
      Fix these sparse warnings:
      
        kernel/trace/ring_buffer.c:70:37: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:84:39: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:96:43: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:2475:13: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:2475:13: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:2478:42: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:2478:42: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:2500:40: warning: incorrect type in argument 3 (different signedness)
        kernel/trace/ring_buffer.c:2505:44: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:2507:46: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/trace.c:2130:40: warning: incorrect type in argument 3 (different signedness)
        kernel/trace/trace.c:2280:40: warning: incorrect type in argument 3 (different signedness)
      Signed-off-by: NHannes Eder <hannes@hanneseder.net>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      5e39841c
    • W
      tracing: fix typos in comments · c3706f00
      Wenji Huang 提交于
      Impact: clean up.
      
      Fix typos in the comments.
      Signed-off-by: NWenji Huang <wenji.huang@oracle.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      c3706f00
  7. 10 2月, 2009 2 次提交
    • L
      ring_buffer: fix ring_buffer_read_page() · 667d2412
      Lai Jiangshan 提交于
      Impact: change API and init bpage when copy
      
      ring_buffer_read_page()/rb_remove_entries() may be called for
      a partially consumed page.
      
      Add a parameter for rb_remove_entries() and make it update
      cpu_buffer->entries correctly for partially consumed pages.
      
      ring_buffer_read_page() now returns the offset to the next event.
      
      Init the bpage's time_stamp when return value is 0.
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      667d2412
    • L
      ring_buffer: fix typing mistake · b85fa01e
      Lai Jiangshan 提交于
      Impact: Fix bug
      
      I found several very very curious line.
      It's so curious that it may be brought by typing mistake.
      
      When (cpu_buffer->reader_page == cpu_buffer->commit_page):
      
      1) We haven't copied it for bpage is changed:
         bpage = cpu_buffer->reader_page->page;
         memcpy(bpage->data, cpu_buffer->reader_page->page->data + read ... )
      2) We need update cpu_buffer->reader_page->read, but
         "cpu_buffer->reader_page += read;" is not right.
      
      [
        This bug was a typo. The commit->reader_page is a page pointer
        and not an index into the page. The line should have been
        commit->reader_page->read += read.  The other changes
        by Lai are nice clean ups to the code.  - SDR
      ]
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      b85fa01e
  8. 08 2月, 2009 2 次提交
    • S
      ring-buffer: use generic version of in_nmi · a81bd80a
      Steven Rostedt 提交于
      Impact: clean up
      
      Now that a generic in_nmi is available, this patch removes the
      special code in the ring_buffer and implements the in_nmi generic
      version instead.
      
      With this change, I was also able to rename the "arch_ftrace_nmi_enter"
      back to "ftrace_nmi_enter" and remove the code from the ring buffer.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      a81bd80a
    • S
      ring-buffer: add NMI protection for spinlocks · 78d904b4
      Steven Rostedt 提交于
      Impact: prevent deadlock in NMI
      
      The ring buffers are not yet totally lockless with writing to
      the buffer. When a writer crosses a page, it grabs a per cpu spinlock
      to protect against a reader. The spinlocks taken by a writer are not
      to protect against other writers, since a writer can only write to
      its own per cpu buffer. The spinlocks protect against readers that
      can touch any cpu buffer. The writers are made to be reentrant
      with the spinlocks disabling interrupts.
      
      The problem arises when an NMI writes to the buffer, and that write
      crosses a page boundary. If it grabs a spinlock, it can be racing
      with another writer (since disabling interrupts does not protect
      against NMIs) or with a reader on the same CPU. Luckily, most of the
      users are not reentrant and protects against this issue. But if a
      user of the ring buffer becomes reentrant (which is what the ring
      buffers do allow), if the NMI also writes to the ring buffer then
      we risk the chance of a deadlock.
      
      This patch moves the ftrace_nmi_enter called by nmi_enter() to the
      ring buffer code. It replaces the current ftrace_nmi_enter that is
      used by arch specific code to arch_ftrace_nmi_enter and updates
      the Kconfig to handle it.
      
      When an NMI is called, it will set a per cpu variable in the ring buffer
      code and will clear it when the NMI exits. If a write to the ring buffer
      crosses page boundaries inside an NMI, a trylock is used on the spin
      lock instead. If the spinlock fails to be acquired, then the entry
      is discarded.
      
      This bug appeared in the ftrace work in the RT tree, where event tracing
      is reentrant. This workaround solved the deadlocks that appeared there.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      78d904b4
  9. 06 2月, 2009 1 次提交
    • 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. 22 1月, 2009 3 次提交
  11. 21 1月, 2009 1 次提交
    • L
      ring_buffer: reset write when reserve buffer fail · 551b4048
      Lai Jiangshan 提交于
      Impact: reset struct buffer_page.write when interrupt storm
      
      if struct buffer_page.write is not reset, any succedent committing
      will corrupted ring_buffer:
      
      static inline void
      rb_set_commit_to_write(struct ring_buffer_per_cpu *cpu_buffer)
      {
      	......
      		cpu_buffer->commit_page->commit =
      			cpu_buffer->commit_page->write;
      	......
      }
      
      when "if (RB_WARN_ON(cpu_buffer, next_page == reader_page))", ring_buffer
      is disabled, but some reserved buffers may haven't been committed.
      we need reset struct buffer_page.write.
      
      when "if (unlikely(next_page == cpu_buffer->commit_page))", ring_buffer
      is still available, we should not corrupt it.
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      551b4048
  12. 20 1月, 2009 1 次提交
    • S
      ring-buffer: fix alignment problem · 082605de
      Steven Rostedt 提交于
      Impact: fix to allow some archs to use the ring buffer
      
      Commits in the ring buffer are checked by pointer arithmetic.
      If the calculation is incorrect, then the commits will never take
      place and the buffer will simply fill up and report an error.
      
      Each page in the ring buffer has a small header:
      
      struct buffer_data_page {
      	u64		time_stamp;
      	local_t		commit;
      	unsigned char	data[];
      };
      
      Unfortuntely, some of the calculations used sizeof(struct buffer_data_page)
      to know the size of the header. But this is incorrect on some archs,
      where sizeof(struct buffer_data_page) does not equal
      offsetof(struct buffer_data_page, data), and on those archs, the commits
      are never processed.
      
      This patch replaces the sizeof with offsetof.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      082605de
  13. 15 1月, 2009 1 次提交
    • L
      ring_buffer: reset write when reserve buffer fail · 6f3b3440
      Lai Jiangshan 提交于
      Impact: reset struct buffer_page.write when interrupt storm
      
      if struct buffer_page.write is not reset, any succedent committing
      will corrupted ring_buffer:
      
      static inline void
      rb_set_commit_to_write(struct ring_buffer_per_cpu *cpu_buffer)
      {
      	......
      		cpu_buffer->commit_page->commit =
      			cpu_buffer->commit_page->write;
      	......
      }
      
      when "if (RB_WARN_ON(cpu_buffer, next_page == reader_page))", ring_buffer
      is disabled, but some reserved buffers may haven't been committed.
      we need reset struct buffer_page.write.
      
      when "if (unlikely(next_page == cpu_buffer->commit_page))", ring_buffer
      is still available, we should not corrupt it.
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      6f3b3440
  14. 11 1月, 2009 2 次提交
  15. 08 1月, 2009 1 次提交
    • R
      ring_buffer: fix ring_buffer_event_length() · 465634ad
      Robert Richter 提交于
      Function ring_buffer_event_length() provides an interface to detect
      the length of data stored in an entry. However, the length contains
      offsets depending on the internal usage. This makes it unusable. This
      patch fixes this and now ring_buffer_event_length() returns the
      alligned length that has been used in ring_buffer_lock_reserve().
      
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NRobert Richter <robert.richter@amd.com>
      465634ad
  16. 01 1月, 2009 1 次提交
  17. 24 12月, 2008 2 次提交
  18. 18 12月, 2008 1 次提交
  19. 17 12月, 2008 1 次提交
  20. 12 12月, 2008 1 次提交
  21. 10 12月, 2008 1 次提交
  22. 03 12月, 2008 3 次提交
    • S
      ring-buffer: change "page" variable names to "bpage" · 044fa782
      Steven Rostedt 提交于
      Impact: clean up
      
      Andrew Morton pointed out that the kernel convention of a variable
      named page should be of type page struct. The ring buffer uses
      a variable named "page" for a pointer to something else.
      
      This patch converts those to be called "bpage" (as in "buffer page").
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      044fa782
    • S
      ring-buffer: read page interface · 8789a9e7
      Steven Rostedt 提交于
      Impact: new API to ring buffer
      
      This patch adds a new interface into the ring buffer that allows a
      page to be read from the ring buffer on a given CPU. For every page
      read, one must also be given to allow for a "swap" of the pages.
      
       rpage = ring_buffer_alloc_read_page(buffer);
       if (!rpage)
      	goto err;
       ret = ring_buffer_read_page(buffer, &rpage, cpu, full);
       if (!ret)
      	goto empty;
       process_page(rpage);
       ring_buffer_free_read_page(rpage);
      
      The caller of these functions must handle any waits that are
      needed to wait for new data. The ring_buffer_read_page will simply
      return 0 if there is no data, or if "full" is set and the writer
      is still on the current page.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      8789a9e7
    • S
      ring-buffer: move some metadata into buffer page · abc9b56d
      Steven Rostedt 提交于
      Impact: get ready for splice changes
      
      This patch moves the commit and timestamp into the beginning of each
      data page of the buffer. This change will allow the page to be moved
      to another location (disk, network, etc) and still have information
      in the page to be able to read it.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      abc9b56d
  23. 27 11月, 2008 1 次提交
  24. 23 11月, 2008 1 次提交
    • S
      ring-buffer: add tracing_off_permanent · 033601a3
      Steven Rostedt 提交于
      Impact: feature to permanently disable ring buffer
      
      This patch adds a API to the ring buffer code that will permanently
      disable the ring buffer from ever recording. This should only be
      called when some serious anomaly is detected, and the system
      may be in an unstable state. When that happens, shutting down the
      recording to the ring buffers may be appropriate.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      033601a3
  25. 19 11月, 2008 1 次提交
  26. 13 11月, 2008 1 次提交
  27. 12 11月, 2008 1 次提交