All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Sameeruddin Shaik <sameeruddin.shaik8@gmail.com>
Cc: Linux Trace Devel <linux-trace-devel@vger.kernel.org>,
	Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
Subject: Re: [Bug 210643] libtracefs: Add ways to set the filtering of function tracing
Date: Tue, 23 Feb 2021 15:59:00 -0500	[thread overview]
Message-ID: <20210223155900.500b2556@gandalf.local.home> (raw)
In-Reply-To: <20210223120130.280e7838@gandalf.local.home>


Hi Sameer,

I forgot to include you on the Cc for this email. Talking with Tzvetomir,
he suggested that I create a more detailed requirement list of what I
expect from the tracefs_function_filter() API. Thinking about how I plan on
using it, I modified it a little. Namely, I added the "module" parameter.

Below is the requirements for the function. If you have any questions, feel
free to email Tzvetomir and myself.

Thanks,

-- Steve


On Tue, 23 Feb 2021 12:01:30 -0500
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);
> 
> 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]".
> 


  reply	other threads:[~2021-02-23 21:00 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 [this message]
2021-02-24  7:39 ` Tzvetomir Stoyanov
2021-02-24  9:34   ` 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=20210223155900.500b2556@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=sameeruddin.shaik8@gmail.com \
    --cc=tz.stoyanov@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.