From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Andrew Morton <akpm@linux-foundation.org>,
Tom Zanussi <zanussi@kernel.org>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15.y 1/2] tracing: Merge struct event_trigger_ops into struct event_command
Date: Wed, 16 Sep 2026 14:36:47 -0400 [thread overview]
Message-ID: <20260916183648.1771833-1-sashal@kernel.org> (raw)
In-Reply-To: <2026091628-jargon-sandstorm-f337@gregkh>
From: Steven Rostedt <rostedt@goodmis.org>
[ Upstream commit b052d70f7c9c156409a70e65c10d83b5650e7e78 ]
Now that there's pretty much a one to one mapping between the struct
event_trigger_ops and struct event_command, there's no reason to have two
different structures. Merge the function pointers of event_trigger_ops
into event_command.
There's one exception in trace_events_hist.c for the
event_hist_trigger_named_ops. This has special logic for the init and free
function pointers for "named histograms". In this case, allocate the
cmd_ops of the event_trigger_data and set it to the proper init and free
functions, which are used to initialize and free the event_trigger_data
respectively. Have the free function and the init function (on failure)
free the cmd_ops of the data element.
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://patch.msgid.link/20251125200932.446322765@kernel.org
Reviewed-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
[5.15 dependency adaptation]
Limit the merge to the histogram initialization callback needed by
6ede78d0563a ("tracing: Set the trace clock before registering the
histogram trigger"). This branch still uses get_trigger_ops(), separate
counted operation tables, and callbacks with an explicit ops argument.
Keep those interfaces and the existing trigger, print, and free callbacks.
Move the two existing histogram init callbacks to event_command with the
single-data-argument signature expected by the target. Copy the histogram
command into a static named-histogram command at command registration and
override its init callback. Existing named trigger operations continue to
handle teardown; no per-trigger command allocation or new function is
needed.
Match the target's shared-histogram cleanup context by calling the existing
remove_hist_vars() before destroying the unused histogram data. Drop the
unrelated eprobe and generic trigger conversions. Leave the clock ordering
change to the target commit.
[ sashal: Reduced backport -- upstream b052d70f7c9c1 touches 4 file(s), this
backport carries 2. Not backported here:
kernel/trace/trace_eprobe.c
kernel/trace/trace_events_trigger.c
This note is generated from the file lists only; see the resolution record
for the reasoning. ]
Stable-dep-of: 6ede78d0563a ("tracing: Set the trace clock before registering the histogram trigger")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/trace/trace.h | 4 ++++
kernel/trace/trace_events_hist.c | 27 +++++++++++++++++----------
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index a632965446b8e..eb753d623105b 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1759,6 +1759,9 @@ struct event_trigger_ops {
*
* @get_trigger_ops: The callback function invoked to retrieve the
* event_trigger_ops implementation associated with the command.
+ *
+ * @init: An optional initialization function used by histogram commands
+ * instead of the event_trigger_ops @init() method.
*/
struct event_command {
struct list_head list;
@@ -1781,6 +1784,7 @@ struct event_command {
struct event_trigger_data *data,
struct trace_event_file *file);
struct event_trigger_ops *(*get_trigger_ops)(char *cmd, char *param);
+ int (*init)(struct event_trigger_data *data);
};
/**
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 5ecc78916431d..e415be35fe6b0 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -2416,6 +2416,7 @@ static char *find_trigger_filter(struct hist_trigger_data *hist_data,
}
static struct event_command trigger_hist_cmd;
+static struct event_command trigger_hist_named_cmd;
static int event_hist_trigger_func(struct event_command *cmd_ops,
struct trace_event_file *file,
char *glob, char *cmd, char *param);
@@ -5378,8 +5379,7 @@ static int event_hist_trigger_print(struct seq_file *m,
return 0;
}
-static int event_hist_trigger_init(struct event_trigger_ops *ops,
- struct event_trigger_data *data)
+static int event_hist_trigger_init(struct event_trigger_data *data)
{
struct hist_trigger_data *hist_data = data->private_data;
@@ -5433,18 +5433,16 @@ static void event_hist_trigger_free(struct event_trigger_ops *ops,
static struct event_trigger_ops event_hist_trigger_ops = {
.func = event_hist_trigger,
.print = event_hist_trigger_print,
- .init = event_hist_trigger_init,
.free = event_hist_trigger_free,
};
-static int event_hist_trigger_named_init(struct event_trigger_ops *ops,
- struct event_trigger_data *data)
+static int event_hist_trigger_named_init(struct event_trigger_data *data)
{
data->ref++;
save_named_trigger(data->named_data->name, data);
- event_hist_trigger_init(ops, data->named_data);
+ event_hist_trigger_init(data->named_data);
return 0;
}
@@ -5467,7 +5465,6 @@ static void event_hist_trigger_named_free(struct event_trigger_ops *ops,
static struct event_trigger_ops event_hist_trigger_named_ops = {
.func = event_hist_trigger,
.print = event_hist_trigger_print,
- .init = event_hist_trigger_named_init,
.free = event_hist_trigger_named_free,
};
@@ -5636,13 +5633,16 @@ static int hist_register_trigger(char *glob, struct event_trigger_ops *ops,
data->paused = true;
if (named_data) {
+ struct event_command *cmd_ops = &trigger_hist_named_cmd;
+
data->private_data = named_data->private_data;
set_named_trigger_data(data, named_data);
data->ops = &event_hist_trigger_named_ops;
+ data->cmd_ops = cmd_ops;
}
- if (data->ops->init) {
- ret = data->ops->init(data->ops, data);
+ if (data->cmd_ops->init) {
+ ret = data->cmd_ops->init(data);
if (ret < 0)
goto out;
}
@@ -5659,8 +5659,10 @@ static int hist_register_trigger(char *glob, struct event_trigger_ops *ops,
tracing_set_filter_buffering(file->tr, true);
}
- if (named_data)
+ if (named_data) {
+ remove_hist_vars(hist_data);
destroy_hist_data(hist_data);
+ }
ret++;
out:
@@ -6002,12 +6004,17 @@ static struct event_command trigger_hist_cmd = {
.unreg_all = hist_unreg_all,
.get_trigger_ops = event_hist_get_trigger_ops,
.set_filter = set_trigger_filter,
+ .init = event_hist_trigger_init,
};
__init int register_trigger_hist_cmd(void)
{
int ret;
+ /* Named histograms share command callbacks, except for initialization. */
+ trigger_hist_named_cmd = trigger_hist_cmd;
+ trigger_hist_named_cmd.init = event_hist_trigger_named_init;
+
ret = register_event_command(&trigger_hist_cmd);
WARN_ON(ret < 0);
--
2.53.0
next prev parent reply other threads:[~2026-09-16 18:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 8:13 FAILED: patch "[PATCH] tracing: Set the trace clock before registering the histogram" failed to apply to 5.15-stable tree gregkh
2026-09-16 18:36 ` Sasha Levin [this message]
2026-09-16 18:36 ` [PATCH 5.15.y 2/2] tracing: Set the trace clock before registering the histogram trigger Sasha Levin
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=20260916183648.1771833-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=stable@vger.kernel.org \
--cc=zanussi@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox