Re: [PATCH] tracing: Use kstrdup_const() for constant hist field type
From: Steven Rostedt <rostedt@goodmis.org>
Date: 2026-05-27 01:50:44
Also in:
lkml
On Wed, 27 May 2026 10:10:15 +0900 Masami Hiramatsu (Google) [off-list ref] wrote:
On Tue, 26 May 2026 17:51:05 +0800 Yu Peng [off-list ref] wrote:quoted
The HIST_FIELD_FL_CONST path duplicates the literal "u64" type with kstrdup(), then releases it through kfree_const(). Use kstrdup_const() instead, avoiding the allocation for a .rodata string while keeping the matching free helper.Since we are using kfree_const() to free hist_field->type, we can just point it as same as HIST_FIELD_FL_HITCOUNT case.
Agreed.
Thanks,quoted
Signed-off-by: Yu Peng <redacted> --- kernel/trace/trace_events_hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index eb2c2bc8bc3d..6ffe9f4720a0 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c@@ -1992,7 +1992,7 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data, if (flags & HIST_FIELD_FL_CONST) { hist_field->fn_num = HIST_FIELD_FN_CONST; hist_field->size = sizeof(u64); - hist_field->type = kstrdup("u64", GFP_KERNEL); + hist_field->type = kstrdup_const("u64", GFP_KERNEL);
This can simply be made to point to "u64". Thanks, -- Steve
quoted
if (!hist_field->type) goto free; goto out; -- 2.43.0