提交 c521efd1 编写于 作者: S Steven Rostedt 提交者: Steven Rostedt

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.
Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
上级 6ec22f9b
...@@ -2898,6 +2898,10 @@ static int tracing_release_pipe(struct inode *inode, struct file *file) ...@@ -2898,6 +2898,10 @@ static int tracing_release_pipe(struct inode *inode, struct file *file)
else else
cpumask_clear_cpu(iter->cpu_file, tracing_reader_cpumask); cpumask_clear_cpu(iter->cpu_file, tracing_reader_cpumask);
if (iter->trace->pipe_open)
iter->trace->pipe_close(iter);
mutex_unlock(&trace_types_lock); mutex_unlock(&trace_types_lock);
free_cpumask_var(iter->started); free_cpumask_var(iter->started);
......
...@@ -272,6 +272,7 @@ struct tracer_flags { ...@@ -272,6 +272,7 @@ struct tracer_flags {
* @pipe_open: called when the trace_pipe file is opened * @pipe_open: called when the trace_pipe file is opened
* @wait_pipe: override how the user waits for traces on trace_pipe * @wait_pipe: override how the user waits for traces on trace_pipe
* @close: called when the trace file is released * @close: called when the trace file is released
* @pipe_close: called when the trace_pipe file is released
* @read: override the default read callback on trace_pipe * @read: override the default read callback on trace_pipe
* @splice_read: override the default splice_read callback on trace_pipe * @splice_read: override the default splice_read callback on trace_pipe
* @selftest: selftest to run on boot (see trace_selftest.c) * @selftest: selftest to run on boot (see trace_selftest.c)
...@@ -290,6 +291,7 @@ struct tracer { ...@@ -290,6 +291,7 @@ struct tracer {
void (*pipe_open)(struct trace_iterator *iter); void (*pipe_open)(struct trace_iterator *iter);
void (*wait_pipe)(struct trace_iterator *iter); void (*wait_pipe)(struct trace_iterator *iter);
void (*close)(struct trace_iterator *iter); void (*close)(struct trace_iterator *iter);
void (*pipe_close)(struct trace_iterator *iter);
ssize_t (*read)(struct trace_iterator *iter, ssize_t (*read)(struct trace_iterator *iter,
struct file *filp, char __user *ubuf, struct file *filp, char __user *ubuf,
size_t cnt, loff_t *ppos); size_t cnt, loff_t *ppos);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册