From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Tom Zanussi <zanussi@kernel.org>
Subject: [for-next][PATCH 05/21] tracing: Separate hist state updates from hist registration
Date: Wed, 27 Apr 2022 15:36:28 -0400 [thread overview]
Message-ID: <20220427193640.337907450@goodmis.org> (raw)
In-Reply-To: 20220427193623.529296556@goodmis.org
From: Tom Zanussi <zanussi@kernel.org>
hist_register_trigger() handles both new hist registration as well as
existing hist registration through event_command.reg().
Adding a new function, existing_hist_update_only(), that checks and
updates existing histograms and exits after doing so allows the
confusing logic in event_hist_trigger_parse() to be simplified.
Link: https://lkml.kernel.org/r/211b2cd3e3d7e00f4f8ad45ef8b33063da6a7e05.1644010576.git.zanussi@kernel.org
Signed-off-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
kernel/trace/trace_events_hist.c | 66 +++++++++++++++++++++++---------
1 file changed, 48 insertions(+), 18 deletions(-)
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 1b71bdb0bcb1..998dfe2162fc 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -5929,6 +5929,48 @@ static bool hist_trigger_match(struct event_trigger_data *data,
return true;
}
+static bool existing_hist_update_only(char *glob,
+ struct event_trigger_data *data,
+ struct trace_event_file *file)
+{
+ struct hist_trigger_data *hist_data = data->private_data;
+ struct event_trigger_data *test, *named_data = NULL;
+ bool updated = false;
+
+ if (!hist_data->attrs->pause && !hist_data->attrs->cont &&
+ !hist_data->attrs->clear)
+ goto out;
+
+ if (hist_data->attrs->name) {
+ named_data = find_named_trigger(hist_data->attrs->name);
+ if (named_data) {
+ if (!hist_trigger_match(data, named_data, named_data,
+ true))
+ goto out;
+ }
+ }
+
+ if (hist_data->attrs->name && !named_data)
+ goto out;
+
+ list_for_each_entry(test, &file->triggers, list) {
+ if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {
+ if (!hist_trigger_match(data, test, named_data, false))
+ continue;
+ if (hist_data->attrs->pause)
+ test->paused = true;
+ else if (hist_data->attrs->cont)
+ test->paused = false;
+ else if (hist_data->attrs->clear)
+ hist_clear(test);
+ updated = true;
+ goto out;
+ }
+ }
+ out:
+ return updated;
+}
+
static int hist_register_trigger(char *glob,
struct event_trigger_data *data,
struct trace_event_file *file)
@@ -5957,19 +5999,11 @@ static int hist_register_trigger(char *glob,
list_for_each_entry(test, &file->triggers, list) {
if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {
- if (!hist_trigger_match(data, test, named_data, false))
- continue;
- if (hist_data->attrs->pause)
- test->paused = true;
- else if (hist_data->attrs->cont)
- test->paused = false;
- else if (hist_data->attrs->clear)
- hist_clear(test);
- else {
+ if (hist_trigger_match(data, test, named_data, false)) {
hist_err(tr, HIST_ERR_TRIGGER_EEXIST, 0);
ret = -EEXIST;
+ goto out;
}
- goto out;
}
}
new:
@@ -6008,8 +6042,6 @@ static int hist_register_trigger(char *glob,
if (named_data)
destroy_hist_data(hist_data);
-
- ret++;
out:
return ret;
}
@@ -6277,14 +6309,12 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,
goto out_free;
}
- ret = event_trigger_register(cmd_ops, file, glob, trigger_data);
- if (ret)
+ if (existing_hist_update_only(glob, trigger_data, file))
goto out_free;
- if (ret == 0) {
- if (!(attrs->pause || attrs->cont || attrs->clear))
- ret = -ENOENT;
+
+ ret = event_trigger_register(cmd_ops, file, glob, trigger_data);
+ if (ret < 0)
goto out_free;
- }
if (get_named_trigger_data(trigger_data))
goto enable;
--
2.35.1
next prev parent reply other threads:[~2022-04-27 19:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 19:36 [for-next][PATCH 00/21] tracing: Updates for 5.19 Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 01/21] tracing: Cleanup double word in comment Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 02/21] tracing: Remove logic for registering multiple event triggers at a time Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 03/21] tracing: Remove redundant trigger_ops params Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 04/21] tracing: Have existing event_command.parse() implementations use helpers Steven Rostedt
2022-04-27 19:36 ` Steven Rostedt [this message]
2022-04-27 19:36 ` [for-next][PATCH 06/21] tracing: Fix inconsistent style of mini-HOWTO Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 07/21] tracing: Fix kernel-doc Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 08/21] MAINTAINERS: Enlarge coverage of TRACING inside architectures Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 09/21] tracing: Fix tracing_map_sort_entries() kernel-doc comment Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 10/21] bootconfig: Make the bootconfig.o as a normal object file Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 11/21] bootconfig: Check the checksum before removing the bootconfig from initrd Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 12/21] bootconfig: Support embedding a bootconfig file in kernel Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 13/21] docs: bootconfig: Add how to embed the bootconfig into kernel Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 14/21] tracing: Make tp_printk work on syscall tracepoints Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 15/21] tracing: Return -EINVAL if WARN_ON(!glob) triggered in event_hist_trigger_parse() Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 16/21] tracing: Change `if (strlen(glob))` to `if (glob[0])` Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 17/21] tracing: Fix sleeping function called from invalid context on RT kernel Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 18/21] tracing: Use WARN instead of printk and WARN_ON Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 19/21] ring-buffer: Simplify if-if to if-else Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 20/21] tracing: Avoid adding tracer option before update_tracer_options Steven Rostedt
2022-04-27 19:36 ` [for-next][PATCH 21/21] tracing: make tracer_init_tracefs initcall asynchronous 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=20220427193640.337907450@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@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