From: Steven Rostedt <rostedt@goodmis.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Yu Peng <pengyu@kylinos.cn>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: Use kstrdup_const() for constant hist field type
Date: Tue, 26 May 2026 21:50:33 -0400 [thread overview]
Message-ID: <20260526215033.78fdac7f@fedora> (raw)
In-Reply-To: <20260527101015.74fc2d54860f16e4aba83cd7@kernel.org>
On Wed, 27 May 2026 10:10:15 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> On Tue, 26 May 2026 17:51:05 +0800
> Yu Peng <pengyu@kylinos.cn> wrote:
>
> > 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,
>
> > Signed-off-by: Yu Peng <pengyu@kylinos.cn>
> > ---
> > 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
> > if (!hist_field->type)
> > goto free;
> > goto out;
> > --
> > 2.43.0
>
>
next prev parent reply other threads:[~2026-05-27 1:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 9:51 [PATCH] tracing: Use kstrdup_const() for constant hist field type Yu Peng
2026-05-27 1:10 ` Masami Hiramatsu
2026-05-27 1:50 ` Steven Rostedt [this message]
2026-05-27 2:18 ` [PATCH v2] tracing: Point constant hist field type to string literal Yu Peng
2026-05-27 2:26 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260526215033.78fdac7f@fedora \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=pengyu@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.