From: "Steven Rostedt (Google)" <[email protected]>
With the new filter logic of passing in the name of a function to match an
instruction pointer (or the address of the function), add a test to make
sure that it is functional.
This is also the first test to test plain filtering. The filtering has
been tested via the trigger logic, which uses the same code, but there was
nothing to test just the event filter, so this test is the first to add
such a case.
Cc: Shuah Khan <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Suggested-by: Masami Hiramatsu (Google) <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>
---
.../test.d/filter/event-filter-function.tc | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc
diff --git a/tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc b/tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc
new file mode 100644
index 000000000000..e2ff3bf4df80
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc
@@ -0,0 +1,58 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: event filter function - test event filtering on functions
+# requires: set_event events/kmem/kmem_cache_free/filter
+# flags: instance
+
+fail() { #msg
+ echo $1
+ exit_fail
+}
+
+echo "Test event filter function name"
+echo 0 > tracing_on
+echo 0 > events/enable
+echo > trace
+echo 'call_site.function == exit_mmap' > events/kmem/kmem_cache_free/filter
+echo 1 > events/kmem/kmem_cache_free/enable
+echo 1 > tracing_on
+ls > /dev/null
+echo 0 > events/kmem/kmem_cache_free/enable
+
+hitcnt=`grep kmem_cache_free trace| grep exit_mmap | wc -l`
+misscnt=`grep kmem_cache_free trace| grep -v exit_mmap | wc -l`
+
+if [ $hitcnt -eq 0 ]; then
+ exit_fail
+fi
+
+if [ $misscnt -gt 0 ]; then
+ exit_fail
+fi
+
+address=`grep ' exit_mmap$' /proc/kallsyms | cut -d' ' -f1`
+
+echo "Test event filter function address"
+echo 0 > tracing_on
+echo 0 > events/enable
+echo > trace
+echo "call_site.function == 0x$address" > events/kmem/kmem_cache_free/filter
+echo 1 > events/kmem/kmem_cache_free/enable
+echo 1 > tracing_on
+sleep 1
+echo 0 > events/kmem/kmem_cache_free/enable
+
+hitcnt=`grep kmem_cache_free trace| grep exit_mmap | wc -l`
+misscnt=`grep kmem_cache_free trace| grep -v exit_mmap | wc -l`
+
+if [ $hitcnt -eq 0 ]; then
+ exit_fail
+fi
+
+if [ $misscnt -gt 0 ]; then
+ exit_fail
+fi
+
+reset_events_filter
+
+exit 0
--
2.35.1
On Mon, Dec 19, 2022 at 01:31:08PM -0500, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <[email protected]>
>
> With the new filter logic of passing in the name of a function to match an
> instruction pointer (or the address of the function), add a test to make
> sure that it is functional.
>
> This is also the first test to test plain filtering. The filtering has
> been tested via the trigger logic, which uses the same code, but there was
> nothing to test just the event filter, so this test is the first to add
> such a case.
>
> Cc: Shuah Khan <[email protected]>
> Cc: Shuah Khan <[email protected]>
> Cc: [email protected]
> Suggested-by: Masami Hiramatsu (Google) <[email protected]>
> Signed-off-by: Steven Rostedt (Google) <[email protected]>
Reviewed-by: Ross Zwisler <[email protected]>
On 12/19/22 13:57, Ross Zwisler wrote:
> On Mon, Dec 19, 2022 at 01:31:08PM -0500, Steven Rostedt wrote:
>> From: "Steven Rostedt (Google)" <[email protected]>
>>
>> With the new filter logic of passing in the name of a function to match an
>> instruction pointer (or the address of the function), add a test to make
>> sure that it is functional.
>>
>> This is also the first test to test plain filtering. The filtering has
>> been tested via the trigger logic, which uses the same code, but there was
>> nothing to test just the event filter, so this test is the first to add
>> such a case.
>>
>> Cc: Shuah Khan <[email protected]>
>> Cc: Shuah Khan <[email protected]>
>> Cc: [email protected]
>> Suggested-by: Masami Hiramatsu (Google) <[email protected]>
>> Signed-off-by: Steven Rostedt (Google) <[email protected]>
>
> Reviewed-by: Ross Zwisler <[email protected]>
Thank you both. I will apply this after rc1 comes out.
thanks,
-- Shuah
On Mon, 19 Dec 2022 15:11:39 -0700
Shuah Khan <[email protected]> wrote:
> On 12/19/22 13:57, Ross Zwisler wrote:
> > On Mon, Dec 19, 2022 at 01:31:08PM -0500, Steven Rostedt wrote:
> >> From: "Steven Rostedt (Google)" <[email protected]>
> >>
> >> With the new filter logic of passing in the name of a function to match an
> >> instruction pointer (or the address of the function), add a test to make
> >> sure that it is functional.
> >>
> >> This is also the first test to test plain filtering. The filtering has
> >> been tested via the trigger logic, which uses the same code, but there was
> >> nothing to test just the event filter, so this test is the first to add
> >> such a case.
> >>
> >> Cc: Shuah Khan <[email protected]>
> >> Cc: Shuah Khan <[email protected]>
> >> Cc: [email protected]
> >> Suggested-by: Masami Hiramatsu (Google) <[email protected]>
> >> Signed-off-by: Steven Rostedt (Google) <[email protected]>
> >
> > Reviewed-by: Ross Zwisler <[email protected]>
>
> Thank you both. I will apply this after rc1 comes out.
It's dependent on the first patch.
-- Steve
On 12/19/22 15:35, Steven Rostedt wrote:
> On Mon, 19 Dec 2022 15:11:39 -0700
> Shuah Khan <[email protected]> wrote:
>
>> On 12/19/22 13:57, Ross Zwisler wrote:
>>> On Mon, Dec 19, 2022 at 01:31:08PM -0500, Steven Rostedt wrote:
>>>> From: "Steven Rostedt (Google)" <[email protected]>
>>>>
>>>> With the new filter logic of passing in the name of a function to match an
>>>> instruction pointer (or the address of the function), add a test to make
>>>> sure that it is functional.
>>>>
>>>> This is also the first test to test plain filtering. The filtering has
>>>> been tested via the trigger logic, which uses the same code, but there was
>>>> nothing to test just the event filter, so this test is the first to add
>>>> such a case.
>>>>
>>>> Cc: Shuah Khan <[email protected]>
>>>> Cc: Shuah Khan <[email protected]>
>>>> Cc: [email protected]
>>>> Suggested-by: Masami Hiramatsu (Google) <[email protected]>
>>>> Signed-off-by: Steven Rostedt (Google) <[email protected]>
>>>
>>> Reviewed-by: Ross Zwisler <[email protected]>
>>
>> Thank you both. I will apply this after rc1 comes out.
>
> It's dependent on the first patch.
>
In which case,
Acked-by: Shuah Khan <[email protected]>
thanks,
-- Shuah
On Mon, 19 Dec 2022 17:20:39 -0700
Shuah Khan <[email protected]> wrote:
> On 12/19/22 15:35, Steven Rostedt wrote:
> > On Mon, 19 Dec 2022 15:11:39 -0700
> > Shuah Khan <[email protected]> wrote:
> >
> >> On 12/19/22 13:57, Ross Zwisler wrote:
> >>> On Mon, Dec 19, 2022 at 01:31:08PM -0500, Steven Rostedt wrote:
> >>>> From: "Steven Rostedt (Google)" <[email protected]>
> >>>>
> >>>> With the new filter logic of passing in the name of a function to match an
> >>>> instruction pointer (or the address of the function), add a test to make
> >>>> sure that it is functional.
> >>>>
> >>>> This is also the first test to test plain filtering. The filtering has
> >>>> been tested via the trigger logic, which uses the same code, but there was
> >>>> nothing to test just the event filter, so this test is the first to add
> >>>> such a case.
> >>>>
> >>>> Cc: Shuah Khan <[email protected]>
> >>>> Cc: Shuah Khan <[email protected]>
> >>>> Cc: [email protected]
> >>>> Suggested-by: Masami Hiramatsu (Google) <[email protected]>
> >>>> Signed-off-by: Steven Rostedt (Google) <[email protected]>
> >>>
> >>> Reviewed-by: Ross Zwisler <[email protected]>
> >>
> >> Thank you both. I will apply this after rc1 comes out.
> >
> > It's dependent on the first patch.
> >
>
> In which case,
>
> Acked-by: Shuah Khan <[email protected]>
>
Thanks Shuah!
-- Steve