tracing: Have histogram types be constant when possible
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Thu, 22 Jul 2021 14:27:06 +0000 (10:27 -0400)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Mon, 16 Aug 2021 15:37:20 +0000 (11:37 -0400)
commit3347d80baa41c357cf263923f60aa8051a753d76
treee4d30c75539ad63456975d6bfafdca0cac753bef
parent370364351926e4fcc7c1a486901bfaae0172b7d9
tracing: Have histogram types be constant when possible

Instead of kstrdup("const", GFP_KERNEL), have the hist_field type simply
assign the constant hist_field->type = "const"; And when the value passed
to it is a variable, use "kstrdup_const(var, GFP_KERNEL);" which will just
copy the value if the variable is already a constant. This saves on having
to allocate when not needed.

All frees of the hist_field->type will need to use kfree_const().

Link: https://lkml.kernel.org/r/20210722142837.280718447@goodmis.org
Suggested-by: Masami Hiramatsu <mhiramat@kernel.org>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace_events_hist.c