Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp156778lqb; Tue, 4 Jun 2024 07:49:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUWRwyP+Hua1Votxu4ii4gMGvb2SU7YoFwDCs+AL6PoPbF+4bpYbPp2rsDzsAw8iWwcd0H0bU25pJnDvt22vLkPk3gqjhJU+sRxgggTlA== X-Google-Smtp-Source: AGHT+IET7VhrDTYME5jQwtdsZE65RIeHJwYr9aQDzJmMC84rxeNdhS9VZ3WrKknP4TERLtkx5uMn X-Received: by 2002:a50:c8cd:0:b0:574:eba7:4741 with SMTP id 4fb4d7f45d1cf-57a365afe40mr6858328a12.42.1717512573233; Tue, 04 Jun 2024 07:49:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717512573; cv=pass; d=google.com; s=arc-20160816; b=umWOr6WS4giXoOUz+OOP0sQOAR6vX/OGv7wpARKB3zWro/P93wKlmT55sN1HQrxYI6 0HIc64P2LKII/J357ReIZk3af2FDFd28TsclBF9ufRF/6d/1lhIeH75R6GNQxOehzgUa aRMciW4FTz0LnyRKeoNEc40m7KDXRXKWjKCr9ftMv22gYjWzMVoEZqqqTlFlpFJgwofz zKDq2HAYgKGs14HdalxErTbw7LbTQ6tD2FTchl4JtxQNYULmkw1BqqMbvhvRyojv+a78 RTtxRWhIvRpwpSCGKVZpHAsy6eT3jL+wcJtW+e9zhSf6uTcxjkzFa+mrfKqnkbYsTohN GJbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=9N7F9JCHY9e324dvH+4xd3SGXSPLqgd865AsK5R/q+c=; fh=/wy5e/q+z2qlOMkv0QH/u80KV4ZXPtz68q6c1OyjqGY=; b=cdVK+4nQ6Pb9RJ7KYp9R0zACsLHfLG90ZTt2beepi0yYFls0OMxeteJMfE8pFW10O4 yaop/d5IkCUzs/Kn/q66PyQTjavQYgv0rNtgxHt/BCsj6gc8W2Ia8LYRvbE/8waXJktD SSbgQpOtmQPYBwP0V5nEyqd4Ucaf+mT0AJzFEVtDem/Hv+2EMynZd14yXmjJDozIEAmQ wBjku29xlnAoRZq0S7kzXEGBlmV0On88wy/9TpPaXjAbylsnph0zNJ6MtzOtPWbbe4O+ r8ebeInVjyysqbB1f/47imjffsIMPNE1CCjH1HUwFC/PQSzODJ7vI75DIdrUrvYRAYMC YGEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-200887-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200887-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31b81381si5173271a12.60.2024.06.04.07.49.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 07:49:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200887-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-200887-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200887-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DE7B11F270CA for ; Tue, 4 Jun 2024 14:49:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1A8D14F121; Tue, 4 Jun 2024 14:42:25 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E7C414A633; Tue, 4 Jun 2024 14:42:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717512139; cv=none; b=fLRG1SLSRgd7RDoe6wygd012KF7rLk8W0SNEkKJzAoJF4tdLueLVdUpk7XXwAX+yknjjbfD1yRLS9nZPOFl/m8n3YHyw1bgPx+iJEg/65SB/BQrUHXWGrAvgexmXyQIMALGqTemofm1Bv2Xe48LJSKmLyFiP480P/5b3kKoYVLU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717512139; c=relaxed/simple; bh=72PZE7jo4rhH6rkropdR1LoNIVfrBlRAv33/Lvh0aFw=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=g360FhPNeouxj7qJnUqsO0nVu5HwjHjcFWkABQFPsM4COUN6qRzzV7jQ3BSVPmFNkCPZkgWEy4u/2OfdlcnfH5OhKnKlThwneoU8E/w75lIVkUny8qprHILSjUbKlj+oe7NXU8ABR1q62B9kW2gX4zNzrgtsW7qDvB142BNDQE0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8829CC32786; Tue, 4 Jun 2024 14:42:19 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sEVMg-00000000Z6V-1wl4; Tue, 04 Jun 2024 10:42:18 -0400 Message-ID: <20240604144218.325348498@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 04 Jun 2024 10:41:30 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Alexei Starovoitov , Florent Revest , Martin KaFai Lau , bpf , Sven Schnelle , Alexei Starovoitov , Jiri Olsa , Arnaldo Carvalho de Melo , Daniel Borkmann , Alan Maguire , Peter Zijlstra , Thomas Gleixner , Guo Ren Subject: [for-next][PATCH 27/27] selftests/ftrace: Add fgraph-multi.tc test References: <20240604144103.293353991@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: "Steven Rostedt (Google)" Add a test that creates 3 instances and enables function_graph tracer in each as well as the top instance, where each will enable a filter (but one that traces all functions) and check that they are filtering properly. Link: https://lore.kernel.org/linux-trace-kernel/20240603190825.252845939@goodmis.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Alexei Starovoitov Cc: Florent Revest Cc: Martin KaFai Lau Cc: bpf Cc: Sven Schnelle Cc: Alexei Starovoitov Cc: Jiri Olsa Cc: Arnaldo Carvalho de Melo Cc: Daniel Borkmann Cc: Alan Maguire Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Guo Ren Reviewed-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- .../ftrace/test.d/ftrace/fgraph-multi.tc | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-multi.tc diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-multi.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-multi.tc new file mode 100644 index 000000000000..ff88f97e41fb --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-multi.tc @@ -0,0 +1,103 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: ftrace - function graph filters +# requires: set_ftrace_filter function_graph:tracer + +# Make sure that function graph filtering works + +INSTANCE1="instances/test1_$$" +INSTANCE2="instances/test2_$$" +INSTANCE3="instances/test3_$$" + +WD=`pwd` + +do_reset() { + cd $WD + if [ -d $INSTANCE1 ]; then + echo nop > $INSTANCE1/current_tracer + rmdir $INSTANCE1 + fi + if [ -d $INSTANCE2 ]; then + echo nop > $INSTANCE2/current_tracer + rmdir $INSTANCE2 + fi + if [ -d $INSTANCE3 ]; then + echo nop > $INSTANCE3/current_tracer + rmdir $INSTANCE3 + fi +} + +mkdir $INSTANCE1 +if ! grep -q function_graph $INSTANCE1/available_tracers; then + echo "function_graph not allowed with instances" + rmdir $INSTANCE1 + exit_unsupported +fi + +mkdir $INSTANCE2 +mkdir $INSTANCE3 + +fail() { # msg + do_reset + echo $1 + exit_fail +} + +disable_tracing +clear_trace + +do_test() { + REGEX=$1 + TEST=$2 + + # filter something, schedule is always good + if ! echo "$REGEX" > set_ftrace_filter; then + fail "can not enable filter $REGEX" + fi + + echo > trace + echo function_graph > current_tracer + enable_tracing + sleep 1 + # search for functions (has "{" or ";" on the line) + echo 0 > tracing_on + count=`cat trace | grep -v '^#' | grep -e '{' -e ';' | grep -v "$TEST" | wc -l` + echo 1 > tracing_on + if [ $count -ne 0 ]; then + fail "Graph filtering not working by itself against $TEST?" + fi + + # Make sure we did find something + echo 0 > tracing_on + count=`cat trace | grep -v '^#' | grep -e '{' -e ';' | grep "$TEST" | wc -l` + echo 1 > tracing_on + if [ $count -eq 0 ]; then + fail "No traces found with $TEST?" + fi +} + +do_test '*sched*' 'sched' +cd $INSTANCE1 +do_test '*lock*' 'lock' +cd $WD +cd $INSTANCE2 +do_test '*rcu*' 'rcu' +cd $WD +cd $INSTANCE3 +echo function_graph > current_tracer + +sleep 1 +count=`cat trace | grep -v '^#' | grep -e '{' -e ';' | grep "$TEST" | wc -l` +if [ $count -eq 0 ]; then + fail "No traces found with all tracing?" +fi + +cd $WD +echo nop > current_tracer +echo nop > $INSTANCE1/current_tracer +echo nop > $INSTANCE2/current_tracer +echo nop > $INSTANCE3/current_tracer + +do_reset + +exit 0 -- 2.43.0