* [PATCH 0/2] [GIT PULL] ftrace updates for 2.6.30
@ 2009-03-30 18:41 Steven Rostedt
2009-03-30 18:41 ` [PATCH 1/2] function-graph: allow unregistering twice Steven Rostedt
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-03-30 18:41 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker
Ingo,
Please pull the latest tip/tracing/ftrace tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/ftrace
Steven Rostedt (2):
function-graph: allow unregistering twice
ring-buffer: do not remove reader page from list on ring buffer free
----
kernel/trace/ftrace.c | 4 ++++
kernel/trace/ring_buffer.c | 1 -
2 files changed, 4 insertions(+), 1 deletions(-)
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] function-graph: allow unregistering twice
2009-03-30 18:41 [PATCH 0/2] [GIT PULL] ftrace updates for 2.6.30 Steven Rostedt
@ 2009-03-30 18:41 ` Steven Rostedt
2009-03-30 18:41 ` [PATCH 2/2] ring-buffer: do not remove reader page from list on ring buffer free Steven Rostedt
2009-04-01 12:49 ` [PATCH 0/2] [GIT PULL] ftrace updates for 2.6.30 Ingo Molnar
2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-03-30 18:41 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Steven Rostedt
[-- Attachment #1: 0001-function-graph-allow-unregistering-twice.patch --]
[-- Type: text/plain, Size: 1235 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Impact: fix to permanent disabling of function graph tracer
There should be nothing to prevent a tracer from unregistering a
function graph callback more than once. This can simplify error paths.
But currently, the counter does not account for mulitple unregistering
of the function graph callback. If it happens, the function graph
tracer will be permanently disabled.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/trace/ftrace.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 1752a63..f1ed080 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2719,6 +2719,9 @@ void unregister_ftrace_graph(void)
{
mutex_lock(&ftrace_lock);
+ if (!unlikely(atomic_read(&ftrace_graph_active)))
+ goto out;
+
atomic_dec(&ftrace_graph_active);
unregister_trace_sched_switch(ftrace_graph_probe_sched_switch);
ftrace_graph_return = (trace_func_graph_ret_t)ftrace_stub;
@@ -2726,6 +2729,7 @@ void unregister_ftrace_graph(void)
ftrace_shutdown(FTRACE_STOP_FUNC_RET);
unregister_pm_notifier(&ftrace_suspend_notifier);
+ out:
mutex_unlock(&ftrace_lock);
}
--
1.6.2.1
--
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ring-buffer: do not remove reader page from list on ring buffer free
2009-03-30 18:41 [PATCH 0/2] [GIT PULL] ftrace updates for 2.6.30 Steven Rostedt
2009-03-30 18:41 ` [PATCH 1/2] function-graph: allow unregistering twice Steven Rostedt
@ 2009-03-30 18:41 ` Steven Rostedt
2009-04-01 12:49 ` [PATCH 0/2] [GIT PULL] ftrace updates for 2.6.30 Ingo Molnar
2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-03-30 18:41 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Steven Rostedt
[-- Attachment #1: 0002-ring-buffer-do-not-remove-reader-page-from-list-on.patch --]
[-- Type: text/plain, Size: 2132 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Impact: prevent possible memory leak
The reader page of the ring buffer is special. Although it points
into the ring buffer, it is not part of the actual buffer. It is
a page used by the reader to swap with a page in the ring buffer.
Once the swap is made, the new reader page is again outside the
buffer.
Even though the reader page points into the buffer, it is really
pointing to residual data. Note, this data is used by the reader.
reader page
|
v
(prev) +---+ (next)
+----------| |----------+
| +---+ |
v v
+---+ +---+ +---+
-->| |------->| |------->| |--->
<--| |<-------| |<-------| |<---
+---+ +---+ +---+
^ ^ ^
\ | /
------- Buffer---------
If we perform a list_del_init() on the reader page we will actually remove
the last page the reader swapped with and not the reader page itself.
This will cause that page to not be freed, and thus is a memory leak.
Luckily, the only user of the ring buffer so far is ftrace. And ftrace
will not free its ring buffer after it allocates it. There is no current
possible memory leak. But once there are other users, or if ftrace
dynamically creates and frees its ring buffer, then this would be a
memory leak.
This patch fixes the leak for future cases.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/trace/ring_buffer.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 808b14b..e7b7072 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -518,7 +518,6 @@ static void rb_free_cpu_buffer(struct ring_buffer_per_cpu *cpu_buffer)
struct list_head *head = &cpu_buffer->pages;
struct buffer_page *bpage, *tmp;
- list_del_init(&cpu_buffer->reader_page->list);
free_buffer_page(cpu_buffer->reader_page);
list_for_each_entry_safe(bpage, tmp, head, list) {
--
1.6.2.1
--
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] [GIT PULL] ftrace updates for 2.6.30
2009-03-30 18:41 [PATCH 0/2] [GIT PULL] ftrace updates for 2.6.30 Steven Rostedt
2009-03-30 18:41 ` [PATCH 1/2] function-graph: allow unregistering twice Steven Rostedt
2009-03-30 18:41 ` [PATCH 2/2] ring-buffer: do not remove reader page from list on ring buffer free Steven Rostedt
@ 2009-04-01 12:49 ` Ingo Molnar
2 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2009-04-01 12:49 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-kernel, Andrew Morton, Frederic Weisbecker
* Steven Rostedt <rostedt@goodmis.org> wrote:
> Ingo,
>
> Please pull the latest tip/tracing/ftrace tree, which can be found at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> tip/tracing/ftrace
>
>
> Steven Rostedt (2):
> function-graph: allow unregistering twice
> ring-buffer: do not remove reader page from list on ring buffer free
>
> ----
> kernel/trace/ftrace.c | 4 ++++
> kernel/trace/ring_buffer.c | 1 -
> 2 files changed, 4 insertions(+), 1 deletions(-)
Pulled, thanks Steve!
Ingo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-04-01 12:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-30 18:41 [PATCH 0/2] [GIT PULL] ftrace updates for 2.6.30 Steven Rostedt
2009-03-30 18:41 ` [PATCH 1/2] function-graph: allow unregistering twice Steven Rostedt
2009-03-30 18:41 ` [PATCH 2/2] ring-buffer: do not remove reader page from list on ring buffer free Steven Rostedt
2009-04-01 12:49 ` [PATCH 0/2] [GIT PULL] ftrace updates for 2.6.30 Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox