All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] oprofile: remove double ring buffering
@ 2010-04-01  1:17 Andi Kleen
  2010-04-01 15:49 ` [stable] " Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Andi Kleen @ 2010-04-01  1:17 UTC (permalink / raw)
  To: robert.richter, oprofile-list, linux-kernel, rostedt; +Cc: stable

Got confirmation now this patch fixes most of the dropped oprofile
samples problem on a particular intensive test on a large system.
So now submitting the previous RFC formally.
.34 / Stable candidate.

-Andi

---

oprofile: remove double ring buffering
    
oprofile used a double buffer scheme for its cpu event buffer
to avoid races on reading with the old locked ring buffer.
    
But that is obsolete now with the new ring buffer, so simply
use a single buffer. This greatly simplifies the code and avoids
a lot of sample drops on large runs, especially with call graph.
    
Based on suggestions from Steven Rostedt
    
Signed-off-by: Andi Kleen <ak@linux.intel.com>

diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index 166b67e..de82183 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -30,23 +30,7 @@
 
 #define OP_BUFFER_FLAGS	0
 
-/*
- * Read and write access is using spin locking. Thus, writing to the
- * buffer by NMI handler (x86) could occur also during critical
- * sections when reading the buffer. To avoid this, there are 2
- * buffers for independent read and write access. Read access is in
- * process context only, write access only in the NMI handler. If the
- * read buffer runs empty, both buffers are swapped atomically. There
- * is potentially a small window during swapping where the buffers are
- * disabled and samples could be lost.
- *
- * Using 2 buffers is a little bit overhead, but the solution is clear
- * and does not require changes in the ring buffer implementation. It
- * can be changed to a single buffer solution when the ring buffer
- * access is implemented as non-locking atomic code.
- */
-static struct ring_buffer *op_ring_buffer_read;
-static struct ring_buffer *op_ring_buffer_write;
+static struct ring_buffer *op_ring_buffer;
 DEFINE_PER_CPU(struct oprofile_cpu_buffer, op_cpu_buffer);
 
 static void wq_sync_buffer(struct work_struct *work);
@@ -68,12 +52,9 @@ void oprofile_cpu_buffer_inc_smpl_lost(void)
 
 void free_cpu_buffers(void)
 {
-	if (op_ring_buffer_read)
-		ring_buffer_free(op_ring_buffer_read);
-	op_ring_buffer_read = NULL;
-	if (op_ring_buffer_write)
-		ring_buffer_free(op_ring_buffer_write);
-	op_ring_buffer_write = NULL;
+	if (op_ring_buffer)
+		ring_buffer_free(op_ring_buffer);
+	op_ring_buffer = NULL;
 }
 
 #define RB_EVENT_HDR_SIZE 4
@@ -86,11 +67,8 @@ int alloc_cpu_buffers(void)
 	unsigned long byte_size = buffer_size * (sizeof(struct op_sample) +
 						 RB_EVENT_HDR_SIZE);
 
-	op_ring_buffer_read = ring_buffer_alloc(byte_size, OP_BUFFER_FLAGS);
-	if (!op_ring_buffer_read)
-		goto fail;
-	op_ring_buffer_write = ring_buffer_alloc(byte_size, OP_BUFFER_FLAGS);
-	if (!op_ring_buffer_write)
+	op_ring_buffer = ring_buffer_alloc(byte_size, OP_BUFFER_FLAGS);
+	if (!op_ring_buffer)
 		goto fail;
 
 	for_each_possible_cpu(i) {
@@ -162,16 +140,11 @@ struct op_sample
 *op_cpu_buffer_write_reserve(struct op_entry *entry, unsigned long size)
 {
 	entry->event = ring_buffer_lock_reserve
-		(op_ring_buffer_write, sizeof(struct op_sample) +
+		(op_ring_buffer, sizeof(struct op_sample) +
 		 size * sizeof(entry->sample->data[0]));
-	if (entry->event)
-		entry->sample = ring_buffer_event_data(entry->event);
-	else
-		entry->sample = NULL;
-
-	if (!entry->sample)
+	if (!entry->event)
 		return NULL;
-
+	entry->sample = ring_buffer_event_data(entry->event);
 	entry->size = size;
 	entry->data = entry->sample->data;
 
@@ -180,25 +153,16 @@ struct op_sample
 
 int op_cpu_buffer_write_commit(struct op_entry *entry)
 {
-	return ring_buffer_unlock_commit(op_ring_buffer_write, entry->event);
+	return ring_buffer_unlock_commit(op_ring_buffer, entry->event);
 }
 
 struct op_sample *op_cpu_buffer_read_entry(struct op_entry *entry, int cpu)
 {
 	struct ring_buffer_event *e;
-	e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL);
-	if (e)
-		goto event;
-	if (ring_buffer_swap_cpu(op_ring_buffer_read,
-				 op_ring_buffer_write,
-				 cpu))
+	e = ring_buffer_consume(op_ring_buffer, cpu, NULL);
+	if (!e)
 		return NULL;
-	e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL);
-	if (e)
-		goto event;
-	return NULL;
 
-event:
 	entry->event = e;
 	entry->sample = ring_buffer_event_data(e);
 	entry->size = (ring_buffer_event_length(e) - sizeof(struct op_sample))
@@ -209,8 +173,7 @@ event:
 
 unsigned long op_cpu_buffer_entries(int cpu)
 {
-	return ring_buffer_entries_cpu(op_ring_buffer_read, cpu)
-		+ ring_buffer_entries_cpu(op_ring_buffer_write, cpu);
+	return ring_buffer_entries_cpu(op_ring_buffer, cpu);
 }
 
 static int

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [stable] [PATCH] oprofile: remove double ring buffering
  2010-04-01  1:17 [PATCH] oprofile: remove double ring buffering Andi Kleen
@ 2010-04-01 15:49 ` Greg KH
  2010-04-01 19:02 ` Robert Richter
  2010-04-23 15:38 ` Robert Richter
  2 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2010-04-01 15:49 UTC (permalink / raw)
  To: Andi Kleen; +Cc: robert.richter, oprofile-list, linux-kernel, rostedt, stable

On Thu, Apr 01, 2010 at 03:17:25AM +0200, Andi Kleen wrote:
> Got confirmation now this patch fixes most of the dropped oprofile
> samples problem on a particular intensive test on a large system.
> So now submitting the previous RFC formally.
> .34 / Stable candidate.

For automatic inclusion in stable trees when the patch goes into Linus's
tree, just add:
	Cc: stable <stable@kernel.org>
to the Signed-off-by: area of the patch and we will be automatically
notified of it and you will not have to do anything else (and I will not
have to dig through the git trees to see if it has been commited or not,
and if so, what the id is...)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] oprofile: remove double ring buffering
  2010-04-01  1:17 [PATCH] oprofile: remove double ring buffering Andi Kleen
  2010-04-01 15:49 ` [stable] " Greg KH
@ 2010-04-01 19:02 ` Robert Richter
  2010-04-01 19:11   ` Steven Rostedt
  2010-04-22 14:33   ` John Villalovos
  2010-04-23 15:38 ` Robert Richter
  2 siblings, 2 replies; 14+ messages in thread
From: Robert Richter @ 2010-04-01 19:02 UTC (permalink / raw)
  To: Andi Kleen; +Cc: oprofile-list, linux-kernel, rostedt, stable

On 01.04.10 03:17:25, Andi Kleen wrote:
> Got confirmation now this patch fixes most of the dropped oprofile
> samples problem on a particular intensive test on a large system.
> So now submitting the previous RFC formally.
> .34 / Stable candidate.

Thanks Andi, will take a look at this next week.

-Robert

-- 
Advanced Micro Devices, Inc.
Operating System Research Center
email: robert.richter@amd.com


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] oprofile: remove double ring buffering
  2010-04-01 19:02 ` Robert Richter
@ 2010-04-01 19:11   ` Steven Rostedt
  2010-04-04 10:01     ` Andi Kleen
  2010-04-22 14:33   ` John Villalovos
  1 sibling, 1 reply; 14+ messages in thread
From: Steven Rostedt @ 2010-04-01 19:11 UTC (permalink / raw)
  To: Robert Richter; +Cc: Andi Kleen, oprofile-list, linux-kernel, stable

On Thu, 2010-04-01 at 21:02 +0200, Robert Richter wrote:
> On 01.04.10 03:17:25, Andi Kleen wrote:
> > Got confirmation now this patch fixes most of the dropped oprofile
> > samples problem on a particular intensive test on a large system.
> > So now submitting the previous RFC formally.
> > .34 / Stable candidate.
> 
> Thanks Andi, will take a look at this next week.

Note, I just sent out a patch set yesterday which will conflict with
this change.

I Cc'd both you and Andi on that patch.

-- Steve



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] oprofile: remove double ring buffering
  2010-04-01 19:11   ` Steven Rostedt
@ 2010-04-04 10:01     ` Andi Kleen
  2010-04-04 13:07       ` Steven Rostedt
  0 siblings, 1 reply; 14+ messages in thread
From: Andi Kleen @ 2010-04-04 10:01 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Robert Richter, Andi Kleen, oprofile-list, linux-kernel, stable

On Thu, Apr 01, 2010 at 03:11:24PM -0400, Steven Rostedt wrote:
> On Thu, 2010-04-01 at 21:02 +0200, Robert Richter wrote:
> > On 01.04.10 03:17:25, Andi Kleen wrote:
> > > Got confirmation now this patch fixes most of the dropped oprofile
> > > samples problem on a particular intensive test on a large system.
> > > So now submitting the previous RFC formally.
> > > .34 / Stable candidate.
> > 
> > Thanks Andi, will take a look at this next week.
> 
> Note, I just sent out a patch set yesterday which will conflict with
> this change.
> 
> I Cc'd both you and Andi on that patch.

Steve, is your ring buffer patch intended for stable? 

I plan to submit the oprofile patch for stable and if your is not
it would be more convenient if your patch was based on mine instead
of the other way round. If yours is for stable I can rebase on top
of yours.

Thanks,

-Andi
-- 
ak@linux.intel.com -- Speaking for myself only.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] oprofile: remove double ring buffering
  2010-04-04 10:01     ` Andi Kleen
@ 2010-04-04 13:07       ` Steven Rostedt
  0 siblings, 0 replies; 14+ messages in thread
From: Steven Rostedt @ 2010-04-04 13:07 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Robert Richter, oprofile-list, linux-kernel, stable, Ingo Molnar

On Sun, 2010-04-04 at 12:01 +0200, Andi Kleen wrote:

> > Note, I just sent out a patch set yesterday which will conflict with
> > this change.
> > 
> > I Cc'd both you and Andi on that patch.
> 
> Steve, is your ring buffer patch intended for stable? 
> 
> I plan to submit the oprofile patch for stable and if your is not
> it would be more convenient if your patch was based on mine instead
> of the other way round. If yours is for stable I can rebase on top
> of yours.

No, my patch is not intended for stable, and in fact, is intended for
35.

When yours gets into Linus's tree, we can fix the conflict. It should be
trivial to fix, since the conflict is just me adding another parameter
(NULL) to a function you changed.

I just wanted you to be aware of the change, you don't need to do
anything about it.

-- Steve





^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] oprofile: remove double ring buffering
  2010-04-01 19:02 ` Robert Richter
  2010-04-01 19:11   ` Steven Rostedt
@ 2010-04-22 14:33   ` John Villalovos
  2010-04-22 23:04     ` Andrew Morton
  1 sibling, 1 reply; 14+ messages in thread
From: John Villalovos @ 2010-04-22 14:33 UTC (permalink / raw)
  To: Robert Richter; +Cc: Andi Kleen, oprofile-list, linux-kernel, rostedt, stable

On Thu, Apr 1, 2010 at 3:02 PM, Robert Richter <robert.richter@amd.com> wrote:
> On 01.04.10 03:17:25, Andi Kleen wrote:
>> Got confirmation now this patch fixes most of the dropped oprofile
>> samples problem on a particular intensive test on a large system.
>> So now submitting the previous RFC formally.
>> .34 / Stable candidate.
>
> Thanks Andi, will take a look at this next week.

I was wondering what the state of this patch is.  I don't see it in
linux-2.6 or linux-next. or in
git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git

Thanks,
John

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] oprofile: remove double ring buffering
  2010-04-22 14:33   ` John Villalovos
@ 2010-04-22 23:04     ` Andrew Morton
  2010-04-23  9:00       ` Robert Richter
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Morton @ 2010-04-22 23:04 UTC (permalink / raw)
  To: John Villalovos
  Cc: Robert Richter, Andi Kleen, oprofile-list, linux-kernel, rostedt, stable

On Thu, 22 Apr 2010 10:33:56 -0400
John Villalovos <sodarock@gmail.com> wrote:

> On Thu, Apr 1, 2010 at 3:02 PM, Robert Richter <robert.richter@amd.com> wrote:
> > On 01.04.10 03:17:25, Andi Kleen wrote:
> >> Got confirmation now this patch fixes most of the dropped oprofile
> >> samples problem on a particular intensive test on a large system.
> >> So now submitting the previous RFC formally.
> >> .34 / Stable candidate.
> >
> > Thanks Andi, will take a look at this next week.
> 
> I was wondering what the state of this patch is.  I don't see it in
> linux-2.6 or linux-next. or in
> git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git
> 

I queued it in my for-2.6.34-via-subsystem-maintainer pile.  I'll start
sending those things out for everyone to ignore early next week I guess.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] oprofile: remove double ring buffering
  2010-04-22 23:04     ` Andrew Morton
@ 2010-04-23  9:00       ` Robert Richter
  2010-04-23 15:38         ` Robert Richter
  0 siblings, 1 reply; 14+ messages in thread
From: Robert Richter @ 2010-04-23  9:00 UTC (permalink / raw)
  To: Andrew Morton
  Cc: John Villalovos, Andi Kleen, oprofile-list, linux-kernel,
	rostedt, stable

On 22.04.10 16:04:11, Andrew Morton wrote:
> > I was wondering what the state of this patch is.  I don't see it in
> > linux-2.6 or linux-next. or in
> > git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git
> > 
> 
> I queued it in my for-2.6.34-via-subsystem-maintainer pile.  I'll start
> sending those things out for everyone to ignore early next week I guess.

I just make my tree ready for v2.6.35 and will put it in there.

The patch looks good, will run some tests.

-Robert

-- 
Advanced Micro Devices, Inc.
Operating System Research Center
email: robert.richter@amd.com


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] oprofile: remove double ring buffering
  2010-04-01  1:17 [PATCH] oprofile: remove double ring buffering Andi Kleen
  2010-04-01 15:49 ` [stable] " Greg KH
  2010-04-01 19:02 ` Robert Richter
@ 2010-04-23 15:38 ` Robert Richter
  2 siblings, 0 replies; 14+ messages in thread
From: Robert Richter @ 2010-04-23 15:38 UTC (permalink / raw)
  To: Andi Kleen; +Cc: oprofile-list, linux-kernel, rostedt, stable

On 01.04.10 03:17:25, Andi Kleen wrote:
> Got confirmation now this patch fixes most of the dropped oprofile
> samples problem on a particular intensive test on a large system.
> So now submitting the previous RFC formally.
> .34 / Stable candidate.

Patch applied to

 git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git core

Thanks Andi and sorry for this late response.

-Robert

-- 
Advanced Micro Devices, Inc.
Operating System Research Center
email: robert.richter@amd.com


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] oprofile: remove double ring buffering
  2010-04-23  9:00       ` Robert Richter
@ 2010-04-23 15:38         ` Robert Richter
  0 siblings, 0 replies; 14+ messages in thread
From: Robert Richter @ 2010-04-23 15:38 UTC (permalink / raw)
  To: Andrew Morton
  Cc: John Villalovos, Andi Kleen, oprofile-list, linux-kernel,
	rostedt, stable

On 23.04.10 11:00:45, Robert Richter wrote:
> I just make my tree ready for v2.6.35 and will put it in there.
> 
> The patch looks good, will run some tests.

The patch is now in the oprofile tree. Sorry for this late response.

-Robert

-- 
Advanced Micro Devices, Inc.
Operating System Research Center
email: robert.richter@amd.com


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] oprofile: remove double ring buffering
  2010-03-20  4:45 ` Steven Rostedt
@ 2010-03-20  4:59   ` Andi Kleen
  0 siblings, 0 replies; 14+ messages in thread
From: Andi Kleen @ 2010-03-20  4:59 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Andi Kleen, linux-kernel, robert.richter

On Sat, Mar 20, 2010 at 12:45:20AM -0400, Steven Rostedt wrote:
> On Sat, 2010-03-20 at 01:03 +0100, Andi Kleen wrote:
> > [This is currently being tested if it fixes the excessive samples
> > dropping I have been complaining about for some time. Still wanted
> > to post the patch for review.]
> > 
> > commit 49e66e8ab54f1114237e6dc24dc32ac912870c41
> > Author: Andi Kleen <ak@linux.intel.com>
> > Date:   Fri Mar 19 21:03:48 2010 +0100
> > 
> >     oprofile: remove double ring buffering
> >     
> >     oprofile used a double buffer scheme for its cpu event buffer
> >     to avoid races on reading with the old lock less ring buffer.
> 
> The old ring buffer was not lockless, hence the need for two ring
> buffers because of NMIs. The new ring buffer is lockless.

Thanks. Description fixed.

-Andi

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] oprofile: remove double ring buffering
  2010-03-20  0:03 Andi Kleen
@ 2010-03-20  4:45 ` Steven Rostedt
  2010-03-20  4:59   ` Andi Kleen
  0 siblings, 1 reply; 14+ messages in thread
From: Steven Rostedt @ 2010-03-20  4:45 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kernel, robert.richter

On Sat, 2010-03-20 at 01:03 +0100, Andi Kleen wrote:
> [This is currently being tested if it fixes the excessive samples
> dropping I have been complaining about for some time. Still wanted
> to post the patch for review.]
> 
> commit 49e66e8ab54f1114237e6dc24dc32ac912870c41
> Author: Andi Kleen <ak@linux.intel.com>
> Date:   Fri Mar 19 21:03:48 2010 +0100
> 
>     oprofile: remove double ring buffering
>     
>     oprofile used a double buffer scheme for its cpu event buffer
>     to avoid races on reading with the old lock less ring buffer.

The old ring buffer was not lockless, hence the need for two ring
buffers because of NMIs. The new ring buffer is lockless.

>     
>     But that is obsolete now with the new ring buffer, so simply
>     use a single buffer. This greatly simplifies the code and avoids
>     some situations where samples could be dropped.
>     
>     Based on suggestions from Steven Rostedt

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

>     
>     Signed-off-by: Andi Kleen <ak@linux.intel.com>
> 



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] oprofile: remove double ring buffering
@ 2010-03-20  0:03 Andi Kleen
  2010-03-20  4:45 ` Steven Rostedt
  0 siblings, 1 reply; 14+ messages in thread
From: Andi Kleen @ 2010-03-20  0:03 UTC (permalink / raw)
  To: linux-kernel, robert.richter, rostedt

[This is currently being tested if it fixes the excessive samples
dropping I have been complaining about for some time. Still wanted
to post the patch for review.]

commit 49e66e8ab54f1114237e6dc24dc32ac912870c41
Author: Andi Kleen <ak@linux.intel.com>
Date:   Fri Mar 19 21:03:48 2010 +0100

    oprofile: remove double ring buffering
    
    oprofile used a double buffer scheme for its cpu event buffer
    to avoid races on reading with the old lock less ring buffer.
    
    But that is obsolete now with the new ring buffer, so simply
    use a single buffer. This greatly simplifies the code and avoids
    some situations where samples could be dropped.
    
    Based on suggestions from Steven Rostedt
    
    Signed-off-by: Andi Kleen <ak@linux.intel.com>

diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index 166b67e..de82183 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -30,23 +30,7 @@
 
 #define OP_BUFFER_FLAGS	0
 
-/*
- * Read and write access is using spin locking. Thus, writing to the
- * buffer by NMI handler (x86) could occur also during critical
- * sections when reading the buffer. To avoid this, there are 2
- * buffers for independent read and write access. Read access is in
- * process context only, write access only in the NMI handler. If the
- * read buffer runs empty, both buffers are swapped atomically. There
- * is potentially a small window during swapping where the buffers are
- * disabled and samples could be lost.
- *
- * Using 2 buffers is a little bit overhead, but the solution is clear
- * and does not require changes in the ring buffer implementation. It
- * can be changed to a single buffer solution when the ring buffer
- * access is implemented as non-locking atomic code.
- */
-static struct ring_buffer *op_ring_buffer_read;
-static struct ring_buffer *op_ring_buffer_write;
+static struct ring_buffer *op_ring_buffer;
 DEFINE_PER_CPU(struct oprofile_cpu_buffer, op_cpu_buffer);
 
 static void wq_sync_buffer(struct work_struct *work);
@@ -68,12 +52,9 @@ void oprofile_cpu_buffer_inc_smpl_lost(void)
 
 void free_cpu_buffers(void)
 {
-	if (op_ring_buffer_read)
-		ring_buffer_free(op_ring_buffer_read);
-	op_ring_buffer_read = NULL;
-	if (op_ring_buffer_write)
-		ring_buffer_free(op_ring_buffer_write);
-	op_ring_buffer_write = NULL;
+	if (op_ring_buffer)
+		ring_buffer_free(op_ring_buffer);
+	op_ring_buffer = NULL;
 }
 
 #define RB_EVENT_HDR_SIZE 4
@@ -86,11 +67,8 @@ int alloc_cpu_buffers(void)
 	unsigned long byte_size = buffer_size * (sizeof(struct op_sample) +
 						 RB_EVENT_HDR_SIZE);
 
-	op_ring_buffer_read = ring_buffer_alloc(byte_size, OP_BUFFER_FLAGS);
-	if (!op_ring_buffer_read)
-		goto fail;
-	op_ring_buffer_write = ring_buffer_alloc(byte_size, OP_BUFFER_FLAGS);
-	if (!op_ring_buffer_write)
+	op_ring_buffer = ring_buffer_alloc(byte_size, OP_BUFFER_FLAGS);
+	if (!op_ring_buffer)
 		goto fail;
 
 	for_each_possible_cpu(i) {
@@ -162,16 +140,11 @@ struct op_sample
 *op_cpu_buffer_write_reserve(struct op_entry *entry, unsigned long size)
 {
 	entry->event = ring_buffer_lock_reserve
-		(op_ring_buffer_write, sizeof(struct op_sample) +
+		(op_ring_buffer, sizeof(struct op_sample) +
 		 size * sizeof(entry->sample->data[0]));
-	if (entry->event)
-		entry->sample = ring_buffer_event_data(entry->event);
-	else
-		entry->sample = NULL;
-
-	if (!entry->sample)
+	if (!entry->event)
 		return NULL;
-
+	entry->sample = ring_buffer_event_data(entry->event);
 	entry->size = size;
 	entry->data = entry->sample->data;
 
@@ -180,25 +153,16 @@ struct op_sample
 
 int op_cpu_buffer_write_commit(struct op_entry *entry)
 {
-	return ring_buffer_unlock_commit(op_ring_buffer_write, entry->event);
+	return ring_buffer_unlock_commit(op_ring_buffer, entry->event);
 }
 
 struct op_sample *op_cpu_buffer_read_entry(struct op_entry *entry, int cpu)
 {
 	struct ring_buffer_event *e;
-	e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL);
-	if (e)
-		goto event;
-	if (ring_buffer_swap_cpu(op_ring_buffer_read,
-				 op_ring_buffer_write,
-				 cpu))
+	e = ring_buffer_consume(op_ring_buffer, cpu, NULL);
+	if (!e)
 		return NULL;
-	e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL);
-	if (e)
-		goto event;
-	return NULL;
 
-event:
 	entry->event = e;
 	entry->sample = ring_buffer_event_data(e);
 	entry->size = (ring_buffer_event_length(e) - sizeof(struct op_sample))
@@ -209,8 +173,7 @@ event:
 
 unsigned long op_cpu_buffer_entries(int cpu)
 {
-	return ring_buffer_entries_cpu(op_ring_buffer_read, cpu)
-		+ ring_buffer_entries_cpu(op_ring_buffer_write, cpu);
+	return ring_buffer_entries_cpu(op_ring_buffer, cpu);
 }
 
 static int

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-04-23 15:38 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-01  1:17 [PATCH] oprofile: remove double ring buffering Andi Kleen
2010-04-01 15:49 ` [stable] " Greg KH
2010-04-01 19:02 ` Robert Richter
2010-04-01 19:11   ` Steven Rostedt
2010-04-04 10:01     ` Andi Kleen
2010-04-04 13:07       ` Steven Rostedt
2010-04-22 14:33   ` John Villalovos
2010-04-22 23:04     ` Andrew Morton
2010-04-23  9:00       ` Robert Richter
2010-04-23 15:38         ` Robert Richter
2010-04-23 15:38 ` Robert Richter
  -- strict thread matches above, loose matches on Subject: below --
2010-03-20  0:03 Andi Kleen
2010-03-20  4:45 ` Steven Rostedt
2010-03-20  4:59   ` Andi Kleen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.