Skip to contentSkip to conversation

tracing: Add pipe_close interface

tip:tracing/urgent KOSAKI Motohiro 4 participants 4 messages Dec 9, 2009 – Dec 10, 2009 1 message not in the archive Tracing

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 26 lines
Commit-ID:  c521efd1700a8c0f7ce26f011f5eaecca17fabfa
Gitweb:     http://git.kernel.org/tip/c521efd1700a8c0f7ce26f011f5eaecca17fabfa
Author:     Steven Rostedt <[email protected]>
AuthorDate: Mon, 7 Dec 2009 09:06:24 -0500
Committer:  Steven Rostedt <[email protected]>
CommitDate: Mon, 7 Dec 2009 12:01:35 -0500

tracing: Add pipe_close interface

An ftrace plugin can add a pipe_open interface when the user opens trace_pipe. But if the plugin allocates something within the pipe_open it can not free it because there exists no pipe_close. The hook to the trace file open has a corresponding close. The closing of the trace_pipe file should also have a corresponding close.

---
 kernel/trace/trace.c |    4 ++++
 kernel/trace/trace.h |    2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)
kernel/trace/trace.c +0 -0
index 874f289..f804b40 100644

kernel/trace/trace.c static int tracing_release_pipe(struct inode *inode, struct file *file) · line 2904

Quoted 7 lines
kernel/trace/trace.c +4 -0
@@ -2898,6 +2898,10 @@ static int tracing_release_pipe(struct inode *inode, struct file *file)
 	else
 		cpumask_clear_cpu(iter->cpu_file, tracing_reader_cpumask);
 
+
+	if (iter->trace->pipe_open)
+		iter->trace->pipe_close(iter);
+

What's happen if pipe_close is NULL? Wny following straightforward check is wrong?
I mean the above description explain pipe_close is only useful if plugin allocate something at pipe_open. then allowing NULL seems natural.

	if (iter->trace->pipe_close)
		iter->trace->pipe_close(iter);

just nit.

maintainer
#2 lore raw
Quoted 18 lines · KOSAKI Motohiro

kernel/trace/trace.c static int tracing_release_pipe(struct inode *inode, struct file *file) · line 2904

Quoted 12 lines
kernel/trace/trace.c +4 -0
index 874f289..f804b40 100644
@@ -2898,6 +2898,10 @@ static int tracing_release_pipe(struct inode *inode, struct file *file)
 	else
 		cpumask_clear_cpu(iter->cpu_file, tracing_reader_cpumask);
 
+
+	if (iter->trace->pipe_open)
+		iter->trace->pipe_close(iter);
+

What's happen if pipe_close is NULL? Wny following straightforward check is wrong?
I mean the above description explain pipe_close is only useful if plugin allocate something at pipe_open. then allowing NULL seems natural.

Quoted 2 lines
	if (iter->trace->pipe_close)
		iter->trace->pipe_close(iter);

Ug, good point (stupid cut & paste should be illegal).

Ingo, I'll fix this up too in the next patch set. Want me to rebase it or just start with this fix?

-- Steve

#3 lore raw
Quoted 20 lines · Steven Rostedt
Quoted 18 lines · KOSAKI Motohiro

kernel/trace/trace.c static int tracing_release_pipe(struct inode *inode, struct file *file) · line 2904

Quoted 12 lines
kernel/trace/trace.c +4 -0
index 874f289..f804b40 100644
@@ -2898,6 +2898,10 @@ static int tracing_release_pipe(struct inode *inode, struct file *file)
 	else
 		cpumask_clear_cpu(iter->cpu_file, tracing_reader_cpumask);
 
+
+	if (iter->trace->pipe_open)
+		iter->trace->pipe_close(iter);
+

What's happen if pipe_close is NULL? Wny following straightforward check is wrong?
I mean the above description explain pipe_close is only useful if plugin allocate something at pipe_open. then allowing NULL seems natural.

Quoted 7 lines
Quoted 2 lines
	if (iter->trace->pipe_close)
		iter->trace->pipe_close(iter);

Ug, good point (stupid cut & paste should be illegal).

Ingo, I'll fix this up too in the next patch set. Want me to rebase it or just start with this fix?

I'd suggest to start with a fix. Thanks,

Ingo

#4 lore raw

[tip:tracing/core] tracing: Only call pipe_close if pipe_close is defined

In reply to KOSAKI Motohiro
Commit-ID:  29bf4a5e3fed3dde3eb629a0cb1762c1e9217458
Gitweb:     http://git.kernel.org/tip/29bf4a5e3fed3dde3eb629a0cb1762c1e9217458
Author:     Steven Rostedt <[email protected]>
AuthorDate: Wed, 9 Dec 2009 12:37:43 -0500
Committer:  Steven Rostedt <[email protected]>
CommitDate: Wed, 9 Dec 2009 12:47:35 -0500

tracing: Only call pipe_close if pipe_close is defined

This fixes a cut and paste error that had pipe_close get called if pipe_open was defined (not pipe_close).

LKML-Reference: <[email protected]>

---
 kernel/trace/trace.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/trace.c +1 -1
index f804b40..dc937e1 100644
@@ -2899,7 +2899,7 @@ static int tracing_release_pipe(struct inode *inode, struct file *file)
 		cpumask_clear_cpu(iter->cpu_file, tracing_reader_cpumask);
 
 
-	if (iter->trace->pipe_open)
+	if (iter->trace->pipe_close)
 		iter->trace->pipe_close(iter);
 
 	mutex_unlock(&trace_types_lock);