linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: sameeruddin shaik <sameeruddin.shaik8@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH 08/13 v2] libtracefs: Allow for setting filters with regex expressions
Date: Wed, 31 Mar 2021 12:39:12 -0400	[thread overview]
Message-ID: <20210331123912.6295e9c1@gandalf.local.home> (raw)
In-Reply-To: <96e9fc99-53c5-ea5a-7e5d-5ea6dafc1f7c@gmail.com>

On Thu, 1 Apr 2021 22:03:02 +0530
sameeruddin shaik <sameeruddin.shaik8@gmail.com> wrote:

> hi steve,
> 
> On 30/03/21 6:21 am, Steven Rostedt wrote:
> > From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
> >
> > All for full "regex(3)" processing of setting functions in the
> > set_ftrace_filter file. Check if the filter passed in is just a glob
> > expression that the kernel can process, or if it is a regex that should look
> > at the available_filter_functions list instead.
> >
> > If it is a regex, it will read the available_filter_functions and write in
> > each function as it finds it.
> >
> > Link: https://lore.kernel.org/linux-trace-devel/20210323013225.451281989@goodmis.org
> >
> > Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > ---
> >   Documentation/libtracefs-function-filter.txt |  10 ++
> >   src/tracefs-tools.c                          | 139 ++++++++++++++++---
> >   2 files changed, 128 insertions(+), 21 deletions(-)
> >
> > diff --git a/Documentation/libtracefs-function-filter.txt b/Documentation/libtracefs-function-filter.txt
> > index c0c89f372c21..88aa3b923d54 100644
> > --- a/Documentation/libtracefs-function-filter.txt
> > +++ b/Documentation/libtracefs-function-filter.txt
> > @@ -32,6 +32,16 @@ _errs_, is a pointer to an array of strings, which will be allocated if
> >   any of filters fail to match any available function, If _errs_ is NULL, it will
> >   be ignored.
> >   
> > +A filter in the array of _filters_ may be either a straight match of a
> > +function, a glob or regex(3). a glob is where '*' matches zero or more
> > +characters, '?' will match zero or one character, and '.' only matches a
> > +period. If the filter is determined to be a regex (where it contains
> > +anything other than alpha numeric characters, or '.', '*', '?') the filter
> > +will be processed as a regex(3) following the rules of regex(3), and '.' is
> > +not a period, but will match any one character. To force a regular
> > +expression, either prefix the filter with a '^' or append it with a '$' as
> > +all filters will act as complete matches of functions anyway.
> > +  
> 
> if we give the filter as regex "^ext4*$" from user side, ideally it 
> should match the ext4 filter functions, if i am not wrong, its not 
> matching any filter in the available_filter_functions

If you add the "^" and/or "$" it makes it into a regex. The above means
that the filter will match "ext", "ext4", "ext44", "ext4444444"

Because "*" means zero or more of the previous character. So, unless
there's a function that matches one of the above, it wont match anything
else.

If you left off the "^" and "$" then it would be a glob, where "*" means
zero or more of any character. But if you want the same in regex, you need
to use:

 "^ext4.*$"


> 
> is this expected behaviour?
> 
> if we give the filter as glob "ext4*" from userside, its making the 
> regex and matching the ext4 filter functions in the 
> available_filter_functions.

Yes, because the conversion changes the glob "ext4*" into "^ext4.*$".

Also, for email etiquette, please sign you last comment, or cut the rest of
the reply. That way I don't have to scroll the rest of the email to know if
there's anything else you commented on.

-- Steve

  reply	other threads:[~2021-03-31 16:39 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30  0:51 [PATCH 00/13 v2] libtracefs: Add tracefs_function_filter() Steven Rostedt
2021-03-30  0:51 ` [PATCH 01/13 v2] libtracefs: An API to set the filtering of functions Steven Rostedt
2021-03-30  0:51 ` [PATCH 02/13 v2] libtracefs: Document function_filter API Steven Rostedt
2021-03-30  0:51 ` [PATCH 03/13 v2] libtracefs: Fix notations of tracefs_function_filter() and module parameter Steven Rostedt
2021-03-30  0:51 ` [PATCH 04/13 v2] libtracefs: Move opening of file out of controlled_write() Steven Rostedt
2021-03-30  0:51 ` [PATCH 05/13 v2] libtracefs: Add add_errors() helper function for control_write() Steven Rostedt
2021-03-30  0:51 ` [PATCH 06/13 v2] libtracefs: Add checking of available_filter_functions to tracefs_function_filter() Steven Rostedt
2021-03-30  0:51 ` [PATCH 07/13 v2] libtracefs: Add write_filter() helper function Steven Rostedt
2021-03-30  0:51 ` [PATCH 08/13 v2] libtracefs: Allow for setting filters with regex expressions Steven Rostedt
2021-04-01 16:33   ` sameeruddin shaik
2021-03-31 16:39     ` Steven Rostedt [this message]
2021-04-02  1:59       ` sameeruddin shaik
2021-04-01  2:41         ` Steven Rostedt
2021-03-30  0:51 ` [PATCH 09/13 v2] libtracefs: Add indexing to set functions in tracefs_function_filter() Steven Rostedt
2021-03-30  0:51 ` [PATCH 10/13 v2] libtracefs: Pass in reset via flags to tracefs_function_filter() Steven Rostedt
2021-03-30 14:29   ` Tzvetomir Stoyanov
2021-03-30 14:53     ` Steven Rostedt
2021-03-30  0:51 ` [PATCH 11/13 v2] libtracefs: Add pthread_mutex_lock() around tracefs_function_filter() Steven Rostedt
2021-03-30  0:51 ` [PATCH 12/13 v2] libtracefs: Move struct tracefs_instance to tracefs-local.h Steven Rostedt
2021-03-30  0:51 ` [PATCH 13/13 v2] libtracefs: Add CONTINUE to tracefs_function_filter() Steven Rostedt
2021-03-30 14:29   ` Tzvetomir Stoyanov
2021-03-30 14:52     ` Steven Rostedt
2021-03-30 15:14       ` Steven Rostedt
2021-03-30 15:32       ` Tzvetomir Stoyanov
2021-03-30 16:03         ` Steven Rostedt
2021-03-30  1:03 ` [RFC][PATCH 14/13 v2] libtracefs: Just past one filter in for tracefs_function_filter() Steven Rostedt
2021-03-30 14:31   ` Tzvetomir Stoyanov

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=20210331123912.6295e9c1@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.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).