linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>,
	Sameeruddin Shaik <sameeruddin.shaik8@gmail.com>
Cc: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: Re: Fw: [Bug 210643] libtracefs: Add ways to set the filtering of function tracing
Date: Wed, 24 Feb 2021 09:39:49 +0200	[thread overview]
Message-ID: <CAPpZLN7tsF8=o1RQJc2rMAdbrFgmFvZmKWK9avbCPCa42U_iDw@mail.gmail.com> (raw)
In-Reply-To: <20210223120130.280e7838@gandalf.local.home>

On Tue, Feb 23, 2021 at 7:07 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
>
> Forwarding this to the mailing list, as well. Any discussions on this may
> be easier to discuss here than on the bugzilla.
>
> -- Steve
>
>
> https://bugzilla.kernel.org/show_bug.cgi?id=210643
>
> --- Comment #7 from Steven Rostedt (rostedt@goodmis.org) ---
> After some discussions on the mailing lists, I found that it is important to
> establish the requirements that I expect of this API. I'm doing it in the
> bugzilla instead of the mailing list (but will also forward this to the
> mailing list), as this is more about the feature request and not about the
> development of it.
>
> The prototype should be:
>
>  int tracefs_function_filter(struct tracefs_instance *instance,
>                              const char * const *filters,
>                              const char *module,
>                              boolean reset);

I think there should be a complementary API for deleting the filters,
may be something like
  int tracefs_function_filter_remove(struct tracefs_instance *instance,
                                                        const char *
const *filters,
                                                        const char *module)
It should be able to remove the filters, configured by the first API
with the same "filters, module" input parameters.

>
> If @instance is NULL, the filter for the top level tracing directory is
> used. Otherwise the filter is for the given instance.
>
> The @filters is an array of strings that holds one or more filters, and the
> array ends with a NULL pointer.
>
> If @module is set, only apply the filter to functions for a given module.
> This is ignored if NULL is passed in. I added this to the interface because
> it is commonly used, and the set_ftrace_filter has a special way to handle
> it (see more below).
>
> If @reset is set, the function filter for the given instance (or toplevel if
> @instance is NULL), is cleared before applying the new filter functions.
> Otherwise, the function filters are appended.
>
> Note on reset being set: This is an important implementation detail. The
> reset must be done by opening the file with O_WRONLY|O_TRUNC set. And the
> file is not closed until all the new filters are added. It must not clear
> the file and close it before setting the new filters. The reason is, if it
> does, then all functions will start to be traced!
>
> If the function filter has some functions in set_ftrace_filter, and the
> function tracer is active, then it is only tracing those functions in
> set_ftrace_filter. If you want to change that set of functions to a new set,
> you open the set_ftrace_filter file with O_WRONLY|O_TRUNC and add your new
> functions. On closing the file, the change takes place. The old functions
> being filtered will no longer be traced, and the new functions being filter
> will start to be traced.
>
> If the set_ftrace_filter is truncated and closed without setting the new
> functions, then the function tracer will start tracing *all* functions!
> That is not what this API should do. This is why it is important that you
> write the new filters after opening with O_TRUNC and before closing the
> file descriptor. This is another reason to use an array of filters instead
> of having the application call this function multiple times with different
> filters strings.
>
> Now when writing the filters, the following should be done for each filter.
> Write the filter to set_ftrace_filter file, and if it succeeds, then
> continue to the next filter. If it does not succeed, then check if it is a
> regex. If so, then add all the functions that match the regex that are in
> available_filter_functions.
>
> Note, if @module is not NULL, then before writing the filter strings for the
> non regex write, append ":mod:@module" to each filter string. That is, if
> @module is "bridge" and the filter is "br_*", then what should be written
> into the set_ftrace_filter file is: "br_*:mod:bridge", and the kernel will
> only apply the "br_*" to the module "bridge". Implementation detail, you
> can simply write the filter unmodified, then write ":mod:" then write
> "bridge", before writing any spaces to separate the filters. The kernel
> will process that as one string "br_*:mod:bridge". This way the function
> does not need to worry about allocating extra memory and copying the string
> to append the ":mod:bridge" before writing.
>
> If a regex is used, then the search of available_filter_functions should
> only look for function names that have the module name behind it. That is,
> if @module is "bridge" and the filter is ".*switchdev_\\(port\\|fdb\\).*",
> and @module is set, then the search over available_filter_functions should
> run the regex only on functions that have a matching module name "[bridge]".
>
> --
> You may reply to this email to add a comment.
>
> You are receiving this mail because:
> You reported the bug.
> You are watching the assignee of the bug.
> You are watching the reporter of the bug.



-- 
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center

  parent reply	other threads:[~2021-02-24  7:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23 17:01 Fw: [Bug 210643] libtracefs: Add ways to set the filtering of function tracing Steven Rostedt
2021-02-23 20:59 ` Steven Rostedt
2021-02-24  7:39 ` Tzvetomir Stoyanov [this message]
2021-02-24  9:34   ` Fw: " Sameeruddin Shaik
2021-02-24 14:19     ` Steven Rostedt
2021-02-24 14:17   ` 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='CAPpZLN7tsF8=o1RQJc2rMAdbrFgmFvZmKWK9avbCPCa42U_iDw@mail.gmail.com' \
    --to=tz.stoyanov@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=sameeruddin.shaik8@gmail.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).