Re: [PATCH 08/13 v2] libtracefs: Allow for setting filters with regex expressions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi steve,

On 31/03/21 10:09 pm, Steven Rostedt wrote:
On Thu, 1 Apr 2021 22:03:02 +0530
sameeruddin shaik <sameeruddin.shaik8@xxxxxxxxx> wrote:

hi steve,

On 30/03/21 6:21 am, Steven Rostedt wrote:
From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>

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@xxxxxxxxxxx

Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
   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.*$"

IF we use the regex in filters, running time of the program is increasing drastically.

lets say,

if we give the kernel glob as a filter, its getting converted to regex and running time of program is

5 secs, in other case where we use regex, its taking 80 secs to complete.

--sameer.



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux