Re: [PATCH 0/2] ring_buffer: updates for linux-tip

Previous thread: [PATCH 1/2] ring_buffer: remove raw from local_irq_save by Steven Rostedt on Tuesday, September 30, 2008 - 9:29 pm. (4 messages)

Next thread: [PATCH 2/2] ring_buffer: implement new locking by Steven Rostedt on Tuesday, September 30, 2008 - 9:29 pm. (2 messages)
From: Steven Rostedt
Date: Tuesday, September 30, 2008 - 9:29 pm

The first patch is just a lockdep clean up of the ring buffer.

The next patch is a new locking design. It is not lockless (yet) but
the locking is a bit cleaner than the original. The basic idea is
that the reader now has its own page to read from that is not in
the ring buffer. When the reader (a consumer) finishes a page, it
then grabs a lock to pull out a new page from the ring buffer and
replace it with the one that it just finished reading.

The writer only locks when it needs to go to the next page. We still
disable interrupts, but it would not be too hard to allow
interrupts to take place on writes. But I will leave that for
version 2 (or 1.2)

The iterator (non consuming read) still expects the tracer to
be disabled when iterating the loop (no locks taken).

The ring_buffer_{un}lock is now no longer around and not needed.

I ran this with lockdep on and it ran fine.

I did lots of testing of trace_pipe (consuming reader) while running
the function trace. The function trace with out a doubt will stress
the consumer/producer reads since the producer is much faster than the
consumer.

Tomorrow, I'll change the buffer_page from being a page_frame to
something that is allocated separately.

-- Steve

--

From: Frédéric Weisbecker
Date: Wednesday, October 1, 2008 - 12:20 am

Good idea! Sounds a real saner approach.
--

From: Ingo Molnar
Date: Wednesday, October 1, 2008 - 12:23 am

are the tracer problems you've reported yesterday fixed in latest 
tip/master?

	Ingo
--

From: Frédéric Weisbecker
Date: Wednesday, October 1, 2008 - 5:32 am

I will not have time to check until this evening. So I will report any potential
feedback tomorrow.
--

From: Frédéric Weisbecker
Date: Wednesday, October 1, 2008 - 10:08 am

Ok I just tested and it's fixed now.

Thanks Steven :)
--

From: Steven Rostedt
Date: Wednesday, October 1, 2008 - 10:14 am

With the new ring buffer infrastructure in ftrace, I'm trying to make
ftrace a little more light weight.

This patch converts a lot of the local_irq_save/restore into
preempt_disable/enable.  The original preempt count in a lot of cases
has to be sent in as a parameter so that it can be recorded correctly.
Some places were recording it incorrectly before anyway.

This is also laying the ground work to make ftrace a little bit
more reentrant, and remove all locking. The function tracers must
still protect from reentrancy.

Note: All the function tracers must be careful when using preempt_disable.
  It must do the following:

  resched = need_resched();
  preempt_disable_notrace();
  [...]
  if (resched)
	preempt_enable_no_resched_notrace();
  else
	preempt_enable_notrace();

The reason is that if this function traces schedule() itself, the
preempt_enable_notrace() will cause a schedule, which will lead
us into a recursive failure.

If we needed to reschedule before calling preempt_disable, we
should have already scheduled. Since we did not, this is most
likely that we should not and are probably inside a schedule
function.

If resched was not set, we still need to catch the need resched
flag being set when preemption was off and the if case at the
end will catch that for us.


Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/trace.c              |  123 +++++++++++++++++++-------------------
 kernel/trace/trace.h              |   13 ++--
 kernel/trace/trace_boot.c         |    2 
 kernel/trace/trace_irqsoff.c      |   13 ++--
 kernel/trace/trace_mmiotrace.c    |    4 -
 kernel/trace/trace_sched_switch.c |    9 +-
 kernel/trace/trace_sched_wakeup.c |   13 +++-
 7 files changed, 97 insertions(+), 80 deletions(-)

Index: linux-tip.git/kernel/trace/trace.c
===================================================================
--- linux-tip.git.orig/kernel/trace/trace.c	2008-10-01 10:41:59.000000000 -0400
+++ ...
Previous thread: [PATCH 1/2] ring_buffer: remove raw from local_irq_save by Steven Rostedt on Tuesday, September 30, 2008 - 9:29 pm. (4 messages)

Next thread: [PATCH 2/2] ring_buffer: implement new locking by Steven Rostedt on Tuesday, September 30, 2008 - 9:29 pm. (2 messages)