From patchwork Fri May 31 09:43:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 13681442 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 23AA9133993; Fri, 31 May 2024 09:43:41 +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=1717148622; cv=none; b=n3l+ffv4D9fs9LDZ3OxE7046s+82LaIBMA2f1cxiIHapgeEI2CRR9KEujRp2SA974N+ajTEJ6tNxfzYkVkpQZyUx89Uj/f9GrVbStyQe2Iz7LplS5IOUXJjWc+ckBFwCk/ML9XBVooWZGmR9913JwN+7vRWTYpLcpOZayR0M3Z8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717148622; c=relaxed/simple; bh=KIRMeRLfAg2SfzPVmF2jfjZK9BOA5aUG46aIO9jkl5o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ikCayL9KJ0WUWotOIleaxnO4GolOfUFtqdXUc2k11Zled3KH+WaUSXTSzPFWpx1mLln4Kpcid9IuDD2bE7K75j4JyzkSGEN/IE9h/mH2v+uwM9lI/PKm2ez9Rm3ZY+k9PMUPfKCXHtYi6Sl9KLJD5cD8DRLooxJwqdJOkvoDEu4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RciYkpdX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RciYkpdX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D226C116B1; Fri, 31 May 2024 09:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717148621; bh=KIRMeRLfAg2SfzPVmF2jfjZK9BOA5aUG46aIO9jkl5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RciYkpdXpJWT8QaHFwbj1Bh82LBXeCOws7iQk1BBlY5vhqpXkNIxnO9Fq7XI/FPU6 vShzrLPHJ+6E88TEMoA69hJhGQ0BFgpQTLE7hnWS5ktoD0dU8NPvBi9wH53e3j4uG8 IX1grK6gn6heXUxnlA5Lo/lJa3iFXdwVh4W4ZjhCynS0j2t8z5SmjdxSby2d3Sszvm 0BvZ7mNoXzNy2sbJrx7S6TJNwoMHFuW5FJPq4aWzc53f44bnyECT9/aCcjWhDJk0dO 0ChA6G8XozeDGgGvZP6glJP2vXWXvMNHibdLHL/X/J6JTHrhOQAVPyR/TAEUEF0AcI ZEk3EA6oeTF6A== From: "Masami Hiramatsu (Google)" To: Steven Rostedt , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mhiramat@kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 1/2] selftests/tracing: Fix event filter test to retry up to 10 times Date: Fri, 31 May 2024 18:43:37 +0900 Message-Id: <171714861780.198407.16488694516653649947.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <171714860864.198407.18416314586430149538.stgit@devnote2> References: <171714860864.198407.18416314586430149538.stgit@devnote2> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Masami Hiramatsu (Google) Commit eb50d0f250e9 ("selftests/ftrace: Choose target function for filter test from samples") choose the target function from samples, but sometimes this test failes randomly because the target function does not hit at the next time. So retry getting samples up to 10 times. Fixes: eb50d0f250e9 ("selftests/ftrace: Choose target function for filter test from samples") Signed-off-by: Masami Hiramatsu (Google) --- .../ftrace/test.d/filter/event-filter-function.tc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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 index 3f74c09c56b6..118247b8dd84 100644 --- a/tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc +++ b/tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc @@ -10,7 +10,6 @@ fail() { #msg } sample_events() { - echo > trace echo 1 > events/kmem/kmem_cache_free/enable echo 1 > tracing_on ls > /dev/null @@ -22,6 +21,7 @@ echo 0 > tracing_on echo 0 > events/enable echo "Get the most frequently calling function" +echo > trace sample_events target_func=`cat trace | grep -o 'call_site=\([^+]*\)' | sed 's/call_site=//' | sort | uniq -c | sort | tail -n 1 | sed 's/^[ 0-9]*//'` @@ -32,7 +32,16 @@ echo > trace echo "Test event filter function name" echo "call_site.function == $target_func" > events/kmem/kmem_cache_free/filter + +sample_events +max_retry=10 +while [ `grep kmem_cache_free trace| wc -l` -eq 0 ]; do sample_events +max_retry=$((max_retry - 1)) +if [ $max_retry -eq 0 ]; then + exit_fail +fi +done hitcnt=`grep kmem_cache_free trace| grep $target_func | wc -l` misscnt=`grep kmem_cache_free trace| grep -v $target_func | wc -l` @@ -49,7 +58,16 @@ address=`grep " ${target_func}\$" /proc/kallsyms | cut -d' ' -f1` echo "Test event filter function address" echo "call_site.function == 0x$address" > events/kmem/kmem_cache_free/filter +echo > trace +sample_events +max_retry=10 +while [ `grep kmem_cache_free trace| wc -l` -eq 0 ]; do sample_events +max_retry=$((max_retry - 1)) +if [ $max_retry -eq 0 ]; then + exit_fail +fi +done hitcnt=`grep kmem_cache_free trace| grep $target_func | wc -l` misscnt=`grep kmem_cache_free trace| grep -v $target_func | wc -l` From patchwork Fri May 31 09:43:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 13681443 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 4EC7A133993; Fri, 31 May 2024 09:43:51 +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=1717148631; cv=none; b=shlGpXaWcLASdr66tpRDDa+xRJNBloRnYeMiu02s84ulB3BxtF+1uq4PmvexvxW/1+22dUyYXob8QwbtrHjoiQs1k/o1x20uCTmugHuE1wj3fns1gzkRMeNm55H1JaNntJ3MAOJgI2RqI4zjmOEkgSyLhZsUb52YNtG0Tw2QKA8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717148631; c=relaxed/simple; bh=Ji/BCrczZrXFzdJ9KBTdLjwgMFK+b2bHwQAPjUjuiF0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=gRhIAo39hmE7SZYOPadQcyTcB2V1zBxVbGoyZVbrJpo65mY6rgdRwPzaip7qtTqmbZPq9vTYUH6c6akSt7HlTfcYrZvvmHcCeCHpiSQ4MOYzKgFk4sO20B+/q5O9RB48Net3Cc8FIkCgfxntrgu7Wm8ACmDzkB2XwDpL9TX10S8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p+4d0iY2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p+4d0iY2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71019C116B1; Fri, 31 May 2024 09:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717148631; bh=Ji/BCrczZrXFzdJ9KBTdLjwgMFK+b2bHwQAPjUjuiF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p+4d0iY2y4Jo1b9nwvfmTfqGVsA5/JeClcvI1M1tX1bS2C5KXjcqZwTp6Vq06c48S wrMTRPvJVID5Xt89uFTbo4ADWegnJRdcon9tPHknmaQNE/BES6SCutOjMCXKDC2G5G B4gq4P+QJNb8eVnZWYTFC1VeCtNSDJmkMwt4AWafOd4Us18f4idAX0eoifa14g8KGf BAdlrRdg/X+GmK0cCl/UrE5+yybqgWWUz5nwEx6xxJeqcifdJnD6paTxI/X5B9Chl2 OTtoPF0obQmt86/r/jObajHDXLbHNFwkc+EOdBm/Fs+u/YzYwiSFa8gPCFGQ3fpjyX ldqRx67ejfbSg== From: "Masami Hiramatsu (Google)" To: Steven Rostedt , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mhiramat@kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 2/2] selftests/tracing: Fix to check the required syscall event Date: Fri, 31 May 2024 18:43:47 +0900 Message-Id: <171714862700.198407.14000969067636098427.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <171714860864.198407.18416314586430149538.stgit@devnote2> References: <171714860864.198407.18416314586430149538.stgit@devnote2> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Masami Hiramatsu (Google) Since test_duplicates.tc depends on syscalls/sys_enter_openat event, it must add the event file to `requires`. Without this fix, the test fails if CONFIG_FTRACE_SYSCALLS=n. Fixes: 297e1dcdca3d ("selftests/ftrace: Add selftest for testing duplicate eprobes and kprobes") Signed-off-by: Masami Hiramatsu (Google) --- .../ftrace/test.d/dynevent/test_duplicates.tc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/test_duplicates.tc b/tools/testing/selftests/ftrace/test.d/dynevent/test_duplicates.tc index d3a79da215c8..5f72abe6fa79 100644 --- a/tools/testing/selftests/ftrace/test.d/dynevent/test_duplicates.tc +++ b/tools/testing/selftests/ftrace/test.d/dynevent/test_duplicates.tc @@ -1,7 +1,7 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 # description: Generic dynamic event - check if duplicate events are caught -# requires: dynamic_events "e[:[/][]] . []":README +# requires: dynamic_events "e[:[/][]] . []":README events/syscalls/sys_enter_openat echo 0 > events/enable