From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796134350; b=UiZXLi8rQCTRJSpXb+sftp6GdniR2x+mf343I1B1ZQ65R4fU6URlDRNbWi/s+k+5VZ6C 4rI+12Zomz+R65QhDw8aoiTkc+PJVWi7KoHhtpgakAA/ykvwij6Xz3Tp0cUJSnUR2joMB H09u5GBgr3HP3wR7lx6HXDYWvHuMjxbDDyzalQvRQ11B214c85Z5I5bJ0ZCjhZHJ/xca9 yN1yid8iAC3bjiX+VWFzQQmfvXTubBmVcvW/C0An4JxNn0tOw1AVeOiWn70sUysE4Ay/+ CC8CaG/IwtXo+FVscxay3Uny0s9GOwYWM1Hzlgdem4Ti6SvO0XdzCYW1fgT3hqjXDEQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796134350; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=NO3yq9n7eAMXAWrqlh7QuoflmU+S+ERE+0O1jTVAnT4=; b=Qc5RlPHufaqhIdrElgouk3eBSpshdnxXVHLKm+0eo3fL/0fMqRs5pOa7U/3yOn9JepQH 2Fv84QEpRBhIcbUnuOVK/zOaGher1HysQlFWRP+67nHGdXANZ+oiSZZB4XgeAh1ha2kKo GXtylYBARfnRQXZfz/OrjxtLdeQQyHPKyL6UKqRnXDa6kKnrz9PxzhNeUH7u0Db8WQHM+ cnOmhedsY7QM3dqPZp2DwCDtvGC0VQUBdonqb1jmiUipO7wlXhpJq88KTTsgqQWN1STcH RgwKyKMlCTUefR6vo8N7gN3FBLQOcjNt6ovmdAXtgKnU+vPYNR3J4BP4X32Gsyq4ROQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="kf/MYHcs"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA80B606A325; Tue, 1 Dec 2026 14:12:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kf/MYHcs Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62E751F00898; Tue, 1 Dec 2026 14:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796134350; bh=NO3yq9n7eAMXAWrqlh7QuoflmU+S+ERE+0O1jTVAnT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kf/MYHcs/4czTviam9MtEwEbUXvKY5g4TkxLBRaMPZT+UEG5cSWl35ObA3MtR4/1R p9f/sw0ClBIBldHavQ6uJHUEo6IylFN45BBEdDBbkKr5qaetJf34V5lImarkXbBiLk 9n0TOILlDVDOUBoGoGX+y94XVMPcAG6uI3n3Z6DskdLNWACz1LNKvdFyiUri9DU4Fb aXjWUrxNVZ+x1Onc00eZ4b68csjYTSCqwFjxsBcx/4Y4UMzShl+Xt+x3pBpCQqN5k1 913wST7VGu2izA6Ivoyxuh+wke4Yxs4M+mWKLvqkj2L3IjsauXcpMRzGDEHoUW78Vo grVwTBET/6VnQ== From: "Masami Hiramatsu (Google)" To: Steven Rostedt , Peter Zijlstra , Ingo Molnar Cc: Jinchao Wang , Mathieu Desnoyers , Thomas Gleixner , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Alexander Shishkin , Ian Rogers , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-perf-users@vger.kernel.org, x86@kernel.org Subject: [PATCH v21 06/11] selftests: tracing: Add a basic testcase for wprobe Date: Mon, 30 Nov 2026 02:02:58 +0000 Message-ID: <20261130020252.32126-7-mhiramat@kernel.org> X-Mailer: UndineD 0.1 In-Reply-To: <20261130020252.32126-1-mhiramat@kernel.org> References: <20261130020252.32126-1-mhiramat@kernel.org> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Add 'add_remove_wprobe.tc' testcase for testing wprobe event that tests adding and removing operations of the wprobe event. Signed-off-by: Masami Hiramatsu (Google) --- Changes in v20: - Verify $addr and $value fetchargs in trace output. - Add test checks for access modes (r@, rw@), length specifiers, symbol offset, and spec-based event removal ('!w:...' and '-:...'). Changes in v17: - Catch failures when enabling wprobe and call exit_unresolved in case hardware watchpoints are exhausted. Changes in v9: - Fix command check logic to prevent early exit under 'set -e' (errexit) when grep or test fails. - Simplify enable/disable status checks by removing cat pipes. Changes in v8: - Fixed silently test failure path. --- tools/testing/selftests/ftrace/config | 1 + .../test.d/dynevent/add_remove_wprobe.tc | 81 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/dynevent/add_remove_wprobe.tc diff --git a/tools/testing/selftests/ftrace/config b/tools/testing/selftests/ftrace/config index 29f05f7c6e2c..c2caea1ba1f5 100644 --- a/tools/testing/selftests/ftrace/config +++ b/tools/testing/selftests/ftrace/config @@ -33,3 +33,4 @@ CONFIG_SYNTH_EVENTS=y CONFIG_TRACER_SNAPSHOT=y CONFIG_UPROBES=y CONFIG_UPROBE_EVENTS=y +CONFIG_WPROBE_EVENTS=y diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_wprobe.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_wprobe.tc new file mode 100644 index 000000000000..40c69c3f2ba5 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_wprobe.tc @@ -0,0 +1,81 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Generic dynamic event - add/remove wprobe events +# requires: dynamic_events "w[:[/][]] [r|w|rw]@[:]":README + +echo 0 > events/enable +echo > dynamic_events + +# Use jiffies as a variable that is frequently written to. +TARGET=jiffies + +echo "w:my_wprobe w@$TARGET addr=\$addr val=\$value" >> dynamic_events + +if ! grep -q my_wprobe dynamic_events; then + echo "Failed to create wprobe event" + exit_fail +fi + +if [ ! -d events/wprobes/my_wprobe ]; then + echo "Failed to create wprobe event directory" + exit_fail +fi + +if ! echo 1 > events/wprobes/my_wprobe/enable; then + echo "Failed to enable wprobe (hardware watchpoints may be exhausted)" + exit_unresolved +fi + +# Check if the event is enabled +if ! grep -q 1 events/wprobes/my_wprobe/enable; then + echo "Failed to enable wprobe event" + exit_fail +fi + +# Let some time pass to trigger the breakpoint +sleep 1 + +# Check if we got any trace output with fetchargs +if ! grep -q "my_wprobe:.*addr=.*val=" trace; then + echo "wprobe event was not triggered or missing fetchargs" + exit_fail +fi + +echo 0 > events/wprobes/my_wprobe/enable + +# Check if the event is disabled +if ! grep -q 0 events/wprobes/my_wprobe/enable; then + echo "Failed to disable wprobe event" + exit_fail +fi + +echo "-:my_wprobe" >> dynamic_events + +if grep -q my_wprobe dynamic_events; then + echo "Failed to remove wprobe event" + exit_fail +fi + +if [ -d events/wprobes/my_wprobe ]; then + echo "Failed to remove wprobe event directory" + exit_fail +fi + +# Test access modes, lengths, symbol offset, and spec-based removal +echo "w:my_wprobe1 r@$TARGET:1" >> dynamic_events +echo "w:my_wprobe2 rw@$TARGET+4:4 val=+0(\$addr)" >> dynamic_events +echo "!w:wprobes/my_wprobe1 r@$TARGET:1" >> dynamic_events +if grep -q my_wprobe1 dynamic_events; then + echo "Failed to remove my_wprobe1 with '!' syntax" + exit_fail +fi + +echo "-:wprobes/my_wprobe2 rw@$TARGET+4:4 val=+0(\$addr)" >> dynamic_events +if grep -q my_wprobe2 dynamic_events; then + echo "Failed to remove my_wprobe2 with full spec" + exit_fail +fi + +clear_trace + +exit 0 -- 2.43.0