From: Steven Rostedt <rostedt@goodmis.org>
To: Nick Lowell <nicholas.lowell@gmail.com>
Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
Nicholas Lowell <nlowell@lexmark.com>
Subject: Re: [PATCH] trace: tracing_event_filter: fast path when no subsystem filters
Date: Mon, 2 Oct 2023 10:23:23 -0400 [thread overview]
Message-ID: <20231002102323.2fc0e4bc@gandalf.local.home> (raw)
In-Reply-To: <CAFEqNJ0SEjP4BvEHtZjyudo97uAMCv9P5jjCJ=Z7OxT3sdh67w@mail.gmail.com>
On Mon, 2 Oct 2023 09:57:34 -0400
Nick Lowell <nicholas.lowell@gmail.com> wrote:
> >
> > The above looks awkward. What about:
> >
> > if (!file->filter)
> > return 0;
> >
> > remove_filter_string(file->filter);
> > return 1;
> >
> > ?
> >
> > Or better yet:
> >
> > if (!file->filter)
> > return false;
> >
> > remove_filter_string(file->filter);
> > return true;
> >
> >
> Is it safe to assume you would like the function's return type to change
> from int to bool if I go with option 2?
Yes.
>
>
> > and ...
> >
> > > }
> > >
> > > -static void filter_free_subsystem_preds(struct trace_subsystem_dir *dir,
> > > +static int filter_free_subsystem_preds(struct trace_subsystem_dir *dir,
> > > struct trace_array *tr)
> > > {
> > > struct trace_event_file *file;
> > > + int i = 0;
> >
> > We don't really need a counter. It's either do the synchronization or
> > we don't.
> >
> > bool do_sync = false;
> >
> > >
> > > list_for_each_entry(file, &tr->events, list) {
> > > if (file->system != dir)
> > > continue;
> > > - __remove_filter(file);
> > > + i += __remove_filter(file);
> >
> > if (remove_filter(file))
> > do_sync = true;
> >
> > > }
> >
> > return do_sync;
> >
> >
> Going to assume the same here--that return type should change from int to
> bool.
>
Correct.
>
> > > + return i;
> > > }
> > >
> > > static inline void __free_subsystem_filter(struct trace_event_file
> > *file)
> > > @@ -2411,7 +2418,9 @@ int apply_subsystem_event_filter(struct
> > trace_subsystem_dir *dir,
> > > }
> > >
> > > if (!strcmp(strstrip(filter_string), "0")) {
> > > - filter_free_subsystem_preds(dir, tr);
> > > + if (filter_free_subsystem_preds(dir, tr) == 0)
> > > + goto out_unlock;
> > > +
> >
> > /* If nothing was freed, we do not need to sync */
> > if (!filter_free_subsystem_preds(dir, tr))
> > goto out_unlock;
> >
> > And yes, add the comment.
> >
> > And actually, in that block with the goto out_unlock, we should have:
> >
> > if (!filter_free_subsystem_preds(dir, tr)) {
> > if (!(WARN_ON_ONCE(system->filter))
> > goto out_unlock;
> > }
> >
> >
> Can you explain why the WARN_ON_ONCE should be in a conditional.
>
> Don't we still want the original conditional to cause the goto regardless?
>
Because if it exists, we still want to free it and do the synchronization,
and set it to NULL. In other words, it means we missed something and need
to revert back to the original behavior.
The WARN_ON_ONCE() documents that we never expect that to happen, and if it
does, it means we have a bug.
-- Steve
>
>
> if (!filter_free_subsystem_preds(dir, tr)) {
> WARN_ON_ONCE(system->filter);
> goto out_unlock;
> }
>
prev parent reply other threads:[~2023-10-02 14:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 14:20 [PATCH] trace: tracing_event_filter: fast path when no subsystem filters Nicholas Lowell
2023-09-30 8:03 ` Steven Rostedt
2023-10-02 14:01 ` Nick Lowell
[not found] ` <CAFEqNJ0SEjP4BvEHtZjyudo97uAMCv9P5jjCJ=Z7OxT3sdh67w@mail.gmail.com>
2023-10-02 14:23 ` Steven Rostedt [this message]
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=20231002102323.2fc0e4bc@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=nicholas.lowell@gmail.com \
--cc=nlowell@lexmark.com \
/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).