From: Nicholas Lowell <nicholas.lowell@gmail.com>
To: rostedt@goodmis.org, mhiramat@kernel.org,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Cc: Nicholas Lowell <nlowell@lexmark.com>
Subject: [PATCH v2] trace: tracing_event_filter: fast path when no subsystem filters
Date: Mon, 2 Oct 2023 10:41:48 -0400 [thread overview]
Message-ID: <20231002144149.1325-1-Nicholas.Lowell@gmail.com> (raw)
From: Nicholas Lowell <nlowell@lexmark.com>
If there are no filters in the event subsystem, then there's no
reason to continue and hit the potentially time consuming
tracepoint_synchronize_unregister function. This should give
a speed up for initial disabling/configuring
Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
---
Notes:
v2: switch from needless counting to boolean
WARN_ON_ONCE if no preds but filter exists
kernel/trace/trace_events_filter.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 33264e510d16..baa108f88032 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1317,22 +1317,29 @@ void free_event_filter(struct event_filter *filter)
__free_filter(filter);
}
-static inline void __remove_filter(struct trace_event_file *file)
+static inline bool __remove_filter(struct trace_event_file *file)
{
filter_disable(file);
+ if (!file->filter)
+ return false;
+
remove_filter_string(file->filter);
+ return true;
}
-static void filter_free_subsystem_preds(struct trace_subsystem_dir *dir,
+static bool filter_free_subsystem_preds(struct trace_subsystem_dir *dir,
struct trace_array *tr)
{
struct trace_event_file *file;
+ bool do_sync = false;
list_for_each_entry(file, &tr->events, list) {
if (file->system != dir)
continue;
- __remove_filter(file);
+ if (__remove_filter(file))
+ do_sync = true;
}
+ return do_sync;
}
static inline void __free_subsystem_filter(struct trace_event_file *file)
@@ -2411,7 +2418,12 @@ int apply_subsystem_event_filter(struct trace_subsystem_dir *dir,
}
if (!strcmp(strstrip(filter_string), "0")) {
- filter_free_subsystem_preds(dir, tr);
+ /* If nothing was freed, we do not need to sync */
+ if (!filter_free_subsystem_preds(dir, tr)) {
+ if(!(WARN_ON_ONCE(system->filter)))
+ goto out_unlock;
+ }
+
remove_filter_string(system->filter);
filter = system->filter;
system->filter = NULL;
--
2.25.1
next reply other threads:[~2023-10-02 14:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-02 14:41 Nicholas Lowell [this message]
2023-10-04 2:30 ` [PATCH v2] trace: tracing_event_filter: fast path when no subsystem filters Steven Rostedt
2023-10-04 14:39 ` Nick Lowell
2023-10-04 14:53 ` Steven Rostedt
2023-10-12 20:37 ` Nick Lowell
2023-11-22 21:20 ` 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=20231002144149.1325-1-Nicholas.Lowell@gmail.com \
--to=nicholas.lowell@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=nlowell@lexmark.com \
--cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).