Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2962084rwj; Mon, 19 Dec 2022 11:01:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf6AHXyVyda1n4hYQcQT8+921M3w8U1QpgJob2Z23/H7oteIq0vw1qsJLyfpOaqzWESnyMGD X-Received: by 2002:a17:906:9705:b0:7c0:fd1e:972e with SMTP id k5-20020a170906970500b007c0fd1e972emr32856737ejx.46.1671476474991; Mon, 19 Dec 2022 11:01:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671476474; cv=none; d=google.com; s=arc-20160816; b=dFcJosM9tfn2aPuvd2beA/CE+nnYFvGgcz8iuZk/E3B06bIojzDcE/8tg0KbnFSJXl wvqzy34jiCBfcfvMlI/jivkEj+QoSgPylbs/NH31OA7gjyR9bsW24DCIib+shi+I+XIH XPCYN82yI2Ikj0j9nk41YbUygS6armVuil9NXnZBui+qzqlPKLSP1Nnar/O0BszHZGtx RzLP650CPVkt5wX6nhn7jCtOvv9Kk1g2XLUd2Has8ePoMWbZnPWAyHgFjeFvL+O9mLjL tLxSYWQd/Q78beulU+R5Hk6OHGXJr1Hi3G7HcDTmeS8rqBPhsQZ2oCWuZz99oIxnl8gf 88zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id; bh=Sn/OcFpxGNDXNl/pKTYnahkoq6uTxg/iAJOQaDNJ5jo=; b=c1pQMcnw4E3Z2OlIeRgmsUhZejx8V6Tr+83theBpIMADMQAcBAn6g/Hz6ojX3W5zIK KZlqIrWtezofDmPxjvUW0xgsAHvZcIt85JrkO1XU4z/Mvt9zoUinwSpdwZCpRWGqNP2b R2xfwt3OJnH5rtaMsIrnDB91e4CeSbY95guMdVDnoSZGwpaC0tOwjoWLLBbXJqZZ4OA7 Vcv1bFLt2CW5PqOYJ/QJCs8QEtdLY0hakDspSaxWQXuqtGSE7FkIjbNb6Num3hpYjaE9 2vd3qgBGVfIjRtb09Cm5UXQhPG8g8LWydw2AaxBZbKZKa44J9AD+v+3tkqeyo8Sy3jkn 7OaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pg20-20020a170907205400b007bc30c06aa2si7452320ejb.902.2022.12.19.11.00.58; Mon, 19 Dec 2022 11:01:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232348AbiLSSfU (ORCPT + 70 others); Mon, 19 Dec 2022 13:35:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232655AbiLSSe3 (ORCPT ); Mon, 19 Dec 2022 13:34:29 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A565213FAB; Mon, 19 Dec 2022 10:32:17 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 60C1FB80F6F; Mon, 19 Dec 2022 18:32:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CF6BC4339B; Mon, 19 Dec 2022 18:32:15 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1p7Kvu-0005TZ-0g; Mon, 19 Dec 2022 13:32:14 -0500 Message-ID: <20221219183214.075559302@goodmis.org> User-Agent: quilt/0.66 Date: Mon, 19 Dec 2022 13:31:08 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Andrew Morton , Ross Zwisler , Tom Zanussi , Zheng Yejian , Shuah Khan , Shuah Khan , linux-kselftest@vger.kernel.org Subject: [PATCH 2/2] tracing/selftests: Add test for event filtering on function name References: <20221219183106.518341498@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Steven Rostedt (Google)" 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 Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Suggested-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- .../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