1
0
Fork 0

tracing: Decrement trace_array when bootconfig creates an instance

The trace_array_get_by_name() creates a ftrace instance and
trace_array_put() is used to remove the reference. Even though the
trace_array_get_by_name() creates the instance, it also adds a reference
count to it, that prevents user space from removing it.

As the bootconfig just creates the instance on boot up, it should still be
used where it can be deleted by user space after boot. A trace_array_put()
is required to let that happen.

Also, change the documentation on trace_array_get_by_name() to make this not
be so confusing.

Link: https://lore.kernel.org/r/20200124205927.76128804@rorschach.local.home

Fixes: 4f712a4d04 ("tracing/boot: Add instance node support")
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
alistair/sensors
Steven Rostedt (VMware) 2020-01-24 20:47:46 -05:00
parent eba12ab71e
commit 28394da258
2 changed files with 5 additions and 0 deletions

View File

@ -8602,6 +8602,10 @@ out_unlock:
* NOTE: This function increments the reference counter associated with the
* trace array returned. This makes sure it cannot be freed while in use.
* Use trace_array_put() once the trace array is no longer needed.
* If the trace_array is to be freed, trace_array_destroy() needs to
* be called after the trace_array_put(), or simply let user space delete
* it from the tracefs instances directory. But until the
* trace_array_put() is called, user space can not delete it.
*
*/
struct trace_array *trace_array_get_by_name(const char *name)

View File

@ -327,6 +327,7 @@ trace_boot_init_instances(struct xbc_node *node)
continue;
}
trace_boot_init_one_instance(tr, inode);
trace_array_put(tr);
}
}