All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] [GIT PULL][v2.6.33] ring-buffer: resizing issues
@ 2009-12-11  4:50 Steven Rostedt
  2009-12-11  4:50 ` [PATCH 1/2] [PATCH 1/2] ring-buffer: Use sync sched protection on ring buffer resizing Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-12-11  4:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton


Ingo,

Please pull the latest tip/tracing/urgent tree, which can be found at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/urgent


Steven Rostedt (2):
      ring-buffer: Use sync sched protection on ring buffer resizing
      ring-buffer: Move resize integrity check under reader lock

----
 kernel/trace/ring_buffer.c |   29 +++++++++++------------------
 1 files changed, 11 insertions(+), 18 deletions(-)

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

* [PATCH 1/2] [PATCH 1/2] ring-buffer: Use sync sched protection on ring buffer resizing
  2009-12-11  4:50 [PATCH 0/2] [GIT PULL][v2.6.33] ring-buffer: resizing issues Steven Rostedt
@ 2009-12-11  4:50 ` Steven Rostedt
  2009-12-11  4:50 ` [PATCH 2/2] [PATCH 2/2] ring-buffer: Move resize integrity check under reader lock Steven Rostedt
  2009-12-11  8:04 ` [PATCH 0/2] [GIT PULL][v2.6.33] ring-buffer: resizing issues Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-12-11  4:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton

[-- Attachment #1: 0001-ring-buffer-Use-sync-sched-protection-on-ring-buffer.patch --]
[-- Type: text/plain, Size: 3210 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

There was a comment in the ring buffer code that says the calling
layers should prevent tracing or reading of the ring buffer while
resizing. I have discovered that the tracers do not honor this
arrangement.

This patch moves the disabling and synchronizing the ring buffer to
a higher layer during resizing. This guarantees that no writes
are occurring while the resize takes place.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ring_buffer.c |   25 +++++++++----------------
 1 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index a1ca495..0d64c51 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1193,9 +1193,6 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned nr_pages)
 	struct list_head *p;
 	unsigned i;
 
-	atomic_inc(&cpu_buffer->record_disabled);
-	synchronize_sched();
-
 	spin_lock_irq(&cpu_buffer->reader_lock);
 	rb_head_page_deactivate(cpu_buffer);
 
@@ -1214,9 +1211,6 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned nr_pages)
 	spin_unlock_irq(&cpu_buffer->reader_lock);
 
 	rb_check_pages(cpu_buffer);
-
-	atomic_dec(&cpu_buffer->record_disabled);
-
 }
 
 static void
@@ -1227,9 +1221,6 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,
 	struct list_head *p;
 	unsigned i;
 
-	atomic_inc(&cpu_buffer->record_disabled);
-	synchronize_sched();
-
 	spin_lock_irq(&cpu_buffer->reader_lock);
 	rb_head_page_deactivate(cpu_buffer);
 
@@ -1245,8 +1236,6 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,
 	spin_unlock_irq(&cpu_buffer->reader_lock);
 
 	rb_check_pages(cpu_buffer);
-
-	atomic_dec(&cpu_buffer->record_disabled);
 }
 
 /**
@@ -1254,11 +1243,6 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,
  * @buffer: the buffer to resize.
  * @size: the new size.
  *
- * The tracer is responsible for making sure that the buffer is
- * not being used while changing the size.
- * Note: We may be able to change the above requirement by using
- *  RCU synchronizations.
- *
  * Minimum size is 2 * BUF_PAGE_SIZE.
  *
  * Returns -1 on failure.
@@ -1290,6 +1274,11 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
 	if (size == buffer_size)
 		return size;
 
+	atomic_inc(&buffer->record_disabled);
+
+	/* Make sure all writers are done with this buffer. */
+	synchronize_sched();
+
 	mutex_lock(&buffer->mutex);
 	get_online_cpus();
 
@@ -1352,6 +1341,8 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
 	put_online_cpus();
 	mutex_unlock(&buffer->mutex);
 
+	atomic_dec(&buffer->record_disabled);
+
 	return size;
 
  free_pages:
@@ -1361,6 +1352,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
 	}
 	put_online_cpus();
 	mutex_unlock(&buffer->mutex);
+	atomic_dec(&buffer->record_disabled);
 	return -ENOMEM;
 
 	/*
@@ -1370,6 +1362,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
  out_fail:
 	put_online_cpus();
 	mutex_unlock(&buffer->mutex);
+	atomic_dec(&buffer->record_disabled);
 	return -1;
 }
 EXPORT_SYMBOL_GPL(ring_buffer_resize);
-- 
1.6.5



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

* [PATCH 2/2] [PATCH 2/2] ring-buffer: Move resize integrity check under reader lock
  2009-12-11  4:50 [PATCH 0/2] [GIT PULL][v2.6.33] ring-buffer: resizing issues Steven Rostedt
  2009-12-11  4:50 ` [PATCH 1/2] [PATCH 1/2] ring-buffer: Use sync sched protection on ring buffer resizing Steven Rostedt
@ 2009-12-11  4:50 ` Steven Rostedt
  2009-12-11  8:04 ` [PATCH 0/2] [GIT PULL][v2.6.33] ring-buffer: resizing issues Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-12-11  4:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton

[-- Attachment #1: 0002-ring-buffer-Move-resize-integrity-check-under-reader.patch --]
[-- Type: text/plain, Size: 1454 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

While using an application that does splice on the ftrace ring
buffer at start up, I triggered an integrity check failure.

Looking into this, I discovered that resizing the buffer performs
an integrity check after the buffer is resized. This check unfortunately
is preformed after it releases the reader lock. If a reader is
reading the buffer it may cause the integrity check to trigger a
false failure.

This patch simply moves the integrity checker under the protection
of the ring buffer reader lock.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ring_buffer.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 0d64c51..eccb4cf 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1208,9 +1208,9 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned nr_pages)
 		return;
 
 	rb_reset_cpu(cpu_buffer);
-	spin_unlock_irq(&cpu_buffer->reader_lock);
-
 	rb_check_pages(cpu_buffer);
+
+	spin_unlock_irq(&cpu_buffer->reader_lock);
 }
 
 static void
@@ -1233,9 +1233,9 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,
 		list_add_tail(&bpage->list, cpu_buffer->pages);
 	}
 	rb_reset_cpu(cpu_buffer);
-	spin_unlock_irq(&cpu_buffer->reader_lock);
-
 	rb_check_pages(cpu_buffer);
+
+	spin_unlock_irq(&cpu_buffer->reader_lock);
 }
 
 /**
-- 
1.6.5



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

* Re: [PATCH 0/2] [GIT PULL][v2.6.33] ring-buffer: resizing issues
  2009-12-11  4:50 [PATCH 0/2] [GIT PULL][v2.6.33] ring-buffer: resizing issues Steven Rostedt
  2009-12-11  4:50 ` [PATCH 1/2] [PATCH 1/2] ring-buffer: Use sync sched protection on ring buffer resizing Steven Rostedt
  2009-12-11  4:50 ` [PATCH 2/2] [PATCH 2/2] ring-buffer: Move resize integrity check under reader lock Steven Rostedt
@ 2009-12-11  8:04 ` Ingo Molnar
  2 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2009-12-11  8:04 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Andrew Morton,
	=?unknown-8bit?B?RnLDqWTDqXJpYw==?= Weisbecker


* Steven Rostedt <rostedt@goodmis.org> wrote:

> 
> Ingo,
> 
> Please pull the latest tip/tracing/urgent tree, which can be found at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> tip/tracing/urgent
> 
> 
> Steven Rostedt (2):
>       ring-buffer: Use sync sched protection on ring buffer resizing
>       ring-buffer: Move resize integrity check under reader lock
> 
> ----
>  kernel/trace/ring_buffer.c |   29 +++++++++++------------------
>  1 files changed, 11 insertions(+), 18 deletions(-)

Pulled, thanks Steve!

	Ingo

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

end of thread, other threads:[~2009-12-11  8:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-11  4:50 [PATCH 0/2] [GIT PULL][v2.6.33] ring-buffer: resizing issues Steven Rostedt
2009-12-11  4:50 ` [PATCH 1/2] [PATCH 1/2] ring-buffer: Use sync sched protection on ring buffer resizing Steven Rostedt
2009-12-11  4:50 ` [PATCH 2/2] [PATCH 2/2] ring-buffer: Move resize integrity check under reader lock Steven Rostedt
2009-12-11  8:04 ` [PATCH 0/2] [GIT PULL][v2.6.33] ring-buffer: resizing issues Ingo Molnar

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.