All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Tom Zanussi <zanussi@kernel.org>,
	Zheng Yejian <zhengyejian1@huawei.com>,
	linux-kselftest@vger.kernel.org,
	Ross Zwisler <zwisler@google.com>,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: [for-next][PATCH 02/12] tracing/selftests: Add test for event filtering on function name
Date: Wed, 25 Jan 2023 12:12:54 -0500	[thread overview]
Message-ID: <20230125171338.659803282@goodmis.org> (raw)
In-Reply-To: 20230125171252.431857411@goodmis.org

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

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.

Link: https://lkml.kernel.org/r/20221219183214.075559302@goodmis.org

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Tom Zanussi <zanussi@kernel.org>
Cc: Zheng Yejian <zhengyejian1@huawei.com>
Cc: linux-kselftest@vger.kernel.org
Suggested-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reviewed-by: Ross Zwisler <zwisler@google.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 .../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.39.0

  parent reply	other threads:[~2023-01-25 17:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-25 17:12 [for-next][PATCH 00/12] tracing: Updates for 6.3 Steven Rostedt
2023-01-25 17:12 ` [for-next][PATCH 01/12] tracing: Add a way to filter function addresses to function names Steven Rostedt
2023-01-25 17:12 ` Steven Rostedt [this message]
2023-01-25 17:12 ` [for-next][PATCH 03/12] ftrace: Add sample with custom ops Steven Rostedt
2023-01-25 17:12 ` [for-next][PATCH 04/12] tracing: Add NULL checks for buffer in ring_buffer_free_read_page() Steven Rostedt
2023-01-25 17:12 ` [for-next][PATCH 05/12] tracing: Simplify calculating entry size using struct_size() Steven Rostedt
2023-01-25 17:12 ` [for-next][PATCH 06/12] tracing: Allow stacktraces to be saved as histogram variables Steven Rostedt
2023-01-25 17:12 ` [for-next][PATCH 07/12] tracing: Allow synthetic events to pass around stacktraces Steven Rostedt
2023-01-25 17:13 ` [for-next][PATCH 08/12] tracing/histogram: Add stacktrace type Steven Rostedt
2023-01-25 17:13 ` [for-next][PATCH 09/12] tracing/histogram: Document variable stacktrace Steven Rostedt
2023-01-25 17:13 ` [for-next][PATCH 10/12] tracing/histogram: Add simple tests for stacktrace usage of synthetic events Steven Rostedt
2023-01-25 17:13 ` [for-next][PATCH 11/12] perf/tracing: Use stage6 of tracing to not duplicate macros Steven Rostedt
2023-01-25 17:13 ` [for-next][PATCH 12/12] bpf/tracing: " 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=20230125171338.659803282@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=zanussi@kernel.org \
    --cc=zhengyejian1@huawei.com \
    --cc=zwisler@google.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.