From nobody Sat Feb 7 17:55:18 2026 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 09F1F35CBB2 for ; Wed, 12 Nov 2025 22:19:52 +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=1762985993; cv=none; b=MQsMUf5dy7hNCrjxzGcAQJ67cnNHaeuLX0G8BstriD6VPzNkEleuMgnNvvjLvyUe0BjMFeQujx8A4yevxlveiXvk1Gp7hyHOWINbfTF8XHApcZKCxq8LMDGoBPHDgVthfK4J52aruT8WZ9ciegGMuUoJwnFk/knpbKwGX7fDehM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762985993; c=relaxed/simple; bh=p6zGcXkXOXZOM6fntSB2PcOW7ci/r7QO+B/3UUeuicA=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=I12vM4bchdmsMiXOqiLLNXFgYApcbHhVBV4LH7Rz1kplXqZrS3LLDe3URsLmNedtzvmmNXoYq7A8o6bJhEeft+m97tkSkvJjGZ9v6NqfjDDnnaeVFduCj/GKbCI2YnPT1lQtdR7jyD+2TJ2e097mQfjMGbq3vyhVKBwuakNXolA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ER/6Dmnv; 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="ER/6Dmnv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 919F9C19423; Wed, 12 Nov 2025 22:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762985992; bh=p6zGcXkXOXZOM6fntSB2PcOW7ci/r7QO+B/3UUeuicA=; h=Date:From:To:Cc:Subject:References:From; b=ER/6Dmnvv46tjcTwP7oN79ieg0jErA6DxhAv73dPej9rOqHAAcwL/YBZB0HFU3IOT Z6ZEa7jzvLoNx/dIYZhRUuAy6v1jgRT/CEabLJdrLGIgtG2y6bcwBKo+aiu7XM20mi PbMG2rdTc1tgUBKLMBZVnCcjkHwwG6t3FHMwWM3pTBh0fqYec18tHmFL5xiaoHQO20 g2BuQN26ODEetX55lpCd02AE6kCBs6XLasapIWIOZadpLeZ14neQ1gdQxueDdLRDBt OKEVKQzIUPSBqXq/8GAgV77gSmcnBWF8yAXla+In+qw5ylKDRoGHpmm3GGhfTuHiHb V/QuNLUzECWRw== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1vJJCA-00000001EVr-39Sq; Wed, 12 Nov 2025 17:20:06 -0500 Message-ID: <20251112222006.608234586@kernel.org> User-Agent: quilt/0.68 Date: Wed, 12 Nov 2025 17:19:47 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Gabriele Monaco , Nam Cao , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [for-next][PATCH 1/5] selftest/ftrace: Generalise ftracetest to use with RV References: <20251112221946.389142361@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Gabriele Monaco The ftracetest script is a fairly complete test framework for tracefs-like subsystem, but it can only be used for ftrace selftests. If OPT_TEST_DIR is provided and includes a function file, use that as test directory going forward rather than just grabbing tests from it. Generalise function names like initialize_ftrace to initialize_system. Add the --rv argument to set up the test for rv, basically changing the trace directory to $TRACING_DIR/rv and displaying an error if that cannot be found. This prepares for rv selftests inclusion. Link: https://lore.kernel.org/r/20251017115203.140080-2-gmonaco@redhat.com Signed-off-by: Gabriele Monaco --- tools/testing/selftests/ftrace/ftracetest | 34 +++++++++++++------ .../ftrace/test.d/00basic/mount_options.tc | 2 +- .../testing/selftests/ftrace/test.d/functions | 6 ++-- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/self= tests/ftrace/ftracetest index cce72f8b03dc..3230bd54dba8 100755 --- a/tools/testing/selftests/ftrace/ftracetest +++ b/tools/testing/selftests/ftrace/ftracetest @@ -22,6 +22,7 @@ echo " --fail-unresolved Treat UNRESOLVED as a failure" echo " -d|--debug Debug mode (trace all shell commands)" echo " -l|--logdir Save logs on the " echo " If is -, all logs output in console only" +echo " --rv Run RV selftests instead of ftrace ones" exit $1 } =20 @@ -133,6 +134,10 @@ parse_opts() { # opts LINK_PTR=3D shift 2 ;; + --rv) + RV_TEST=3D1 + shift 1 + ;; *.tc) if [ -f "$1" ]; then OPT_TEST_CASES=3D"$OPT_TEST_CASES `abspath $1`" @@ -152,9 +157,13 @@ parse_opts() { # opts ;; esac done - if [ ! -z "$OPT_TEST_CASES" ]; then + if [ -n "$OPT_TEST_CASES" ]; then TEST_CASES=3D$OPT_TEST_CASES fi + if [ -n "$OPT_TEST_DIR" -a -f "$OPT_TEST_DIR"/test.d/functions ]; then + TOP_DIR=3D$OPT_TEST_DIR + TEST_DIR=3D$TOP_DIR/test.d + fi } =20 # Parameters @@ -190,10 +199,6 @@ fi TOP_DIR=3D`absdir $0` TEST_DIR=3D$TOP_DIR/test.d TEST_CASES=3D`find_testcases $TEST_DIR` -LOG_TOP_DIR=3D$TOP_DIR/logs -LOG_DATE=3D`date +%Y%m%d-%H%M%S` -LOG_DIR=3D$LOG_TOP_DIR/$LOG_DATE/ -LINK_PTR=3D$LOG_TOP_DIR/latest KEEP_LOG=3D0 KTAP=3D0 DEBUG=3D0 @@ -201,14 +206,23 @@ VERBOSE=3D0 UNSUPPORTED_RESULT=3D0 UNRESOLVED_RESULT=3D0 STOP_FAILURE=3D0 +RV_TEST=3D0 # Parse command-line options parse_opts $* =20 +LOG_TOP_DIR=3D$TOP_DIR/logs +LOG_DATE=3D`date +%Y%m%d-%H%M%S` +LOG_DIR=3D$LOG_TOP_DIR/$LOG_DATE/ +LINK_PTR=3D$LOG_TOP_DIR/latest + [ $DEBUG -ne 0 ] && set -x =20 -# Verify parameters -if [ -z "$TRACING_DIR" -o ! -d "$TRACING_DIR" ]; then - errexit "No ftrace directory found" +if [ $RV_TEST -ne 0 ]; then + TRACING_DIR=3D$TRACING_DIR/rv + if [ ! -d "$TRACING_DIR" ]; then + err_ret=3D$err_skip + errexit "rv is not configured in this kernel" + fi fi =20 # Preparing logs @@ -419,7 +433,7 @@ trap 'SIG_RESULT=3D$XFAIL' $SIG_XFAIL __run_test() { # testfile # setup PID and PPID, $$ is not updated. (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x; - checkreq $1; initialize_ftrace; . $1) + checkreq $1; initialize_system; . $1) [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID } =20 @@ -496,7 +510,7 @@ for t in $TEST_CASES; do exit 1 fi done -(cd $TRACING_DIR; finish_ftrace) # for cleanup +(cd $TRACING_DIR; finish_system) # for cleanup =20 prlog "" prlog "# of passed: " `echo $PASSED_CASES | wc -w` diff --git a/tools/testing/selftests/ftrace/test.d/00basic/mount_options.tc= b/tools/testing/selftests/ftrace/test.d/00basic/mount_options.tc index 8a7ce647a60d..318939451caf 100644 --- a/tools/testing/selftests/ftrace/test.d/00basic/mount_options.tc +++ b/tools/testing/selftests/ftrace/test.d/00basic/mount_options.tc @@ -28,7 +28,7 @@ unmount_tracefs() { local mount_point=3D"$1" =20 # Need to make sure the mount isn't busy so that we can umount it - (cd $mount_point; finish_ftrace;) + (cd $mount_point; finish_system;) =20 cleanup } diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testin= g/selftests/ftrace/test.d/functions index a1052bf460fc..e8e718139294 100644 --- a/tools/testing/selftests/ftrace/test.d/functions +++ b/tools/testing/selftests/ftrace/test.d/functions @@ -104,7 +104,7 @@ clear_dynamic_events() { # reset all current dynamic ev= ents done } =20 -initialize_ftrace() { # Reset ftrace to initial-state +initialize_system() { # Reset ftrace to initial-state # As the initial state, ftrace will be set to nop tracer, # no events, no triggers, no filters, no function filters, # no probes, and tracing on. @@ -134,8 +134,8 @@ initialize_ftrace() { # Reset ftrace to initial-state enable_tracing } =20 -finish_ftrace() { - initialize_ftrace +finish_system() { + initialize_system # And recover it to default. [ -f options/pause-on-trace ] && echo 0 > options/pause-on-trace } --=20 2.51.0 From nobody Sat Feb 7 17:55:18 2026 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 51A692765FF for ; Wed, 12 Nov 2025 22:19:53 +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=1762985993; cv=none; b=u9zMdcQsG+LpcLbFQnws5g8Hh/FwFIqPdMK4WFQapzDqYzZoVu5kFEMl34kJzIRFhKpBRR2Cl4pAfEWlyeVwfjSaEhPBP4OsYAXcDWnNvoZMJAaWxm4/i9bfjBA27GPL7LRfPyBtchSUba/bkdeXAXpMhwNfccUHnFNDfh9+IUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762985993; c=relaxed/simple; bh=n4Tqndp+kJVHsZQsNWwWa7X/ogK2HmtX2Vdn4QbD6QU=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=V9A9eRSdGClr/STlbRKmYPDMZgFgFLsEW780o6MCf9LsN9fwM2huWHBkPILgMAnkblA/EHGIBR/Rke7ju7Qf+MMSird9REkpYDAxaOyAxHqQCrQnFGEPO0VH9lVO7rljqPGOlWinB9bLDHsXfOMQT+C4rg9upe9R9cBGRqm7Q9c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qr29ueHW; 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="qr29ueHW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2458C2BC86; Wed, 12 Nov 2025 22:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762985992; bh=n4Tqndp+kJVHsZQsNWwWa7X/ogK2HmtX2Vdn4QbD6QU=; h=Date:From:To:Cc:Subject:References:From; b=qr29ueHWhJYjEjj6bR4JAuPiV7+UGQRFixLDdjex0bnomWpYfbRpfbqXvOcOwwgSA eGujX4KJWM9kM2Q9MTOcuId4T7n2jHDXHU7G8RjE5UYQ1/PR+3SeLpfUjeifu4PRq4 LcFQQhL8D+YMmD6kYpPE2q4LmKQMpMC5Dl/HY3HQqjFBDlVtej8N6SQWNtJxUdsQJI yR+snqAhtWYsowEFBy4j3QMjFrTICURUSf1z6stu3/lWiZPVvZlHud295j6Bwq7hjZ K30pd0DNYVyxRGdrMSZLPo8Z1lWqD46MjIUSFt1P4A9F/STd79Q1TGwauHNahK7G/6 vf7922ca7b54Q== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1vJJCA-00000001EWM-3ql6; Wed, 12 Nov 2025 17:20:06 -0500 Message-ID: <20251112222006.772387903@kernel.org> User-Agent: quilt/0.68 Date: Wed, 12 Nov 2025 17:19:48 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Gabriele Monaco , Nam Cao , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [for-next][PATCH 2/5] selftests/verification: Add initial RV tests References: <20251112221946.389142361@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Gabriele Monaco Add a series of tests to validate the RV tracefs API and basic functionality. * available monitors: Check that all monitors (from the monitors folder) appear as available and have a description. Works with nested monitors. * enable/disable: Enable and disable all monitors and validate both the enabled file and the enabled_monitors. Check that enabling container monitors enables all nested monitors. * reactors: Set all reactors and validate the setting, also for nested monitors. * wwnr with printk: wwnr is broken on purpose, run it with a load and check that the printk reactor works. Also validate disabling reacting_on or monitoring_on prevents reactions. These tests use the ftracetest suite. Acked-by: Nam Cao Link: https://lore.kernel.org/r/20251017115203.140080-3-gmonaco@redhat.com Signed-off-by: Gabriele Monaco --- MAINTAINERS | 1 + .../testing/selftests/verification/.gitignore | 2 + tools/testing/selftests/verification/Makefile | 8 ++ tools/testing/selftests/verification/config | 1 + tools/testing/selftests/verification/settings | 1 + .../selftests/verification/test.d/functions | 39 ++++++++++ .../test.d/rv_monitor_enable_disable.tc | 75 +++++++++++++++++++ .../verification/test.d/rv_monitor_reactor.tc | 68 +++++++++++++++++ .../test.d/rv_monitors_available.tc | 18 +++++ .../verification/test.d/rv_wwnr_printk.tc | 30 ++++++++ .../verification/verificationtest-ktap | 8 ++ 11 files changed, 251 insertions(+) create mode 100644 tools/testing/selftests/verification/.gitignore create mode 100644 tools/testing/selftests/verification/Makefile create mode 100644 tools/testing/selftests/verification/config create mode 100644 tools/testing/selftests/verification/settings create mode 100644 tools/testing/selftests/verification/test.d/functions create mode 100644 tools/testing/selftests/verification/test.d/rv_monitor_= enable_disable.tc create mode 100644 tools/testing/selftests/verification/test.d/rv_monitor_= reactor.tc create mode 100644 tools/testing/selftests/verification/test.d/rv_monitors= _available.tc create mode 100644 tools/testing/selftests/verification/test.d/rv_wwnr_pri= ntk.tc create mode 100755 tools/testing/selftests/verification/verificationtest-k= tap diff --git a/MAINTAINERS b/MAINTAINERS index ddecf1ef3bed..95c32cd3b524 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22498,6 +22498,7 @@ F: Documentation/trace/rv/ F: include/linux/rv.h F: include/rv/ F: kernel/trace/rv/ +F: tools/testing/selftests/verification/ F: tools/verification/ =20 RUST diff --git a/tools/testing/selftests/verification/.gitignore b/tools/testin= g/selftests/verification/.gitignore new file mode 100644 index 000000000000..2659417cb2c7 --- /dev/null +++ b/tools/testing/selftests/verification/.gitignore @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +logs diff --git a/tools/testing/selftests/verification/Makefile b/tools/testing/= selftests/verification/Makefile new file mode 100644 index 000000000000..aa8790c22a71 --- /dev/null +++ b/tools/testing/selftests/verification/Makefile @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +all: + +TEST_PROGS :=3D verificationtest-ktap +TEST_FILES :=3D test.d settings +EXTRA_CLEAN :=3D $(OUTPUT)/logs/* + +include ../lib.mk diff --git a/tools/testing/selftests/verification/config b/tools/testing/se= lftests/verification/config new file mode 100644 index 000000000000..43072c1c38f4 --- /dev/null +++ b/tools/testing/selftests/verification/config @@ -0,0 +1 @@ +CONFIG_RV=3Dy diff --git a/tools/testing/selftests/verification/settings b/tools/testing/= selftests/verification/settings new file mode 100644 index 000000000000..e7b9417537fb --- /dev/null +++ b/tools/testing/selftests/verification/settings @@ -0,0 +1 @@ +timeout=3D0 diff --git a/tools/testing/selftests/verification/test.d/functions b/tools/= testing/selftests/verification/test.d/functions new file mode 100644 index 000000000000..ec36a092f56e --- /dev/null +++ b/tools/testing/selftests/verification/test.d/functions @@ -0,0 +1,39 @@ +check_requires() { # Check required files, monitors and reactors + for i in "$@" ; do + p=3D${i%:program} + m=3D${i%:monitor} + r=3D${i%:reactor} + if [ $p !=3D $i ]; then + if ! which $p ; then + echo "Required program $p is not found." + exit_unresolved + fi + elif [ $m !=3D $i ]; then + if ! grep -wq $m available_monitors ; then + echo "Required monitor $m is not configured." + exit_unsupported + fi + elif [ $r !=3D $i ]; then + if ! grep -wq $r available_reactors ; then + echo "Required reactor $r is not configured." + exit_unsupported + fi + elif [ ! -e $i ]; then + echo "Required feature interface $i doesn't exist." + exit_unsupported + fi + done +} + +initialize_system() { # Reset RV to initial-state + echo > enabled_monitors + for m in monitors/*; do + echo nop > $m/reactors || true + done + echo 1 > monitoring_on + echo 1 > reacting_on || true +} + +finish_system() { + initialize_system +} diff --git a/tools/testing/selftests/verification/test.d/rv_monitor_enable_= disable.tc b/tools/testing/selftests/verification/test.d/rv_monitor_enable_= disable.tc new file mode 100644 index 000000000000..f29236defb5a --- /dev/null +++ b/tools/testing/selftests/verification/test.d/rv_monitor_enable_disable= .tc @@ -0,0 +1,75 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# description: Test monitor enable/disable + +test_simple_monitor() { + local monitor=3D"$1" + local prefix=3D"$2" # nested monitors + + echo 1 > "monitors/$prefix$monitor/enable" + grep -q "$monitor$" enabled_monitors + + echo 0 > "monitors/$prefix$monitor/enable" + ! grep -q "$monitor$" enabled_monitors + + echo "$monitor" >> enabled_monitors + grep -q 1 "monitors/$prefix$monitor/enable" + + echo "!$monitor" >> enabled_monitors + grep -q 0 "monitors/$prefix$monitor/enable" +} + +test_container_monitor() { + local monitor=3D"$1" + local nested + + echo 1 > "monitors/$monitor/enable" + grep -q "^$monitor$" enabled_monitors + + for nested_dir in "monitors/$monitor"/*; do + [ -d "$nested_dir" ] || continue + nested=3D$(basename "$nested_dir") + grep -q "^$monitor:$nested$" enabled_monitors + done + test -n "$nested" + + echo 0 > "monitors/$monitor/enable" + ! grep -q "^$monitor$" enabled_monitors + + for nested_dir in "monitors/$monitor"/*; do + [ -d "$nested_dir" ] || continue + nested=3D$(basename "$nested_dir") + ! grep -q "^$monitor:$nested$" enabled_monitors + done + + echo "$monitor" >> enabled_monitors + grep -q 1 "monitors/$monitor/enable" + + for nested_dir in "monitors/$monitor"/*; do + [ -d "$nested_dir" ] || continue + nested=3D$(basename "$nested_dir") + grep -q "^$monitor:$nested$" enabled_monitors + done + + echo "!$monitor" >> enabled_monitors + grep -q 0 "monitors/$monitor/enable" + + for nested_dir in "monitors/$monitor"/*; do + [ -d "$nested_dir" ] || continue + nested=3D$(basename "$nested_dir") + test_simple_monitor "$nested" "$monitor/" + done +} + +for monitor_dir in monitors/*; do + monitor=3D$(basename "$monitor_dir") + + if find "$monitor_dir" -mindepth 1 -type d | grep -q .; then + test_container_monitor "$monitor" + else + test_simple_monitor "$monitor" + fi +done + +! echo non_existent_monitor > enabled_monitors +! grep -q "^non_existent_monitor$" enabled_monitors diff --git a/tools/testing/selftests/verification/test.d/rv_monitor_reactor= .tc b/tools/testing/selftests/verification/test.d/rv_monitor_reactor.tc new file mode 100644 index 000000000000..2958bf849338 --- /dev/null +++ b/tools/testing/selftests/verification/test.d/rv_monitor_reactor.tc @@ -0,0 +1,68 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# description: Test monitor reactor setting +# requires: available_reactors + +test_monitor_reactor() { + local monitor=3D"$1" + local prefix=3D"$2" # nested monitors + + while read -r reactor; do + [ "$reactor" =3D nop ] && continue + + echo "$reactor" > "monitors/$prefix$monitor/reactors" + grep -q "\\[$reactor\\]" "monitors/$prefix$monitor/reactors" + done < available_reactors + + echo nop > "monitors/$prefix$monitor/reactors" + grep -q "\\[nop\\]" "monitors/$prefix$monitor/reactors" +} + +test_container_monitor() { + local monitor=3D"$1" + local nested + + while read -r reactor; do + [ "$reactor" =3D nop ] && continue + + echo "$reactor" > "monitors/$monitor/reactors" + grep -q "\\[$reactor\\]" "monitors/$monitor/reactors" + + for nested_dir in "monitors/$monitor"/*; do + [ -d "$nested_dir" ] || continue + nested=3D$(basename "$nested_dir") + grep -q "\\[$reactor\\]" "monitors/$monitor/$nested/reactors" + done + done < available_reactors + test -n "$nested" + + echo nop > "monitors/$monitor/reactors" + grep -q "\\[nop\\]" "monitors/$monitor/reactors" + + for nested_dir in "monitors/$monitor"/*; do + [ -d "$nested_dir" ] || continue + nested=3D$(basename "$nested_dir") + grep -q "\\[nop\\]" "monitors/$monitor/$nested/reactors" + done + + for nested_dir in "monitors/$monitor"/*; do + [ -d "$nested_dir" ] || continue + nested=3D$(basename "$nested_dir") + test_monitor_reactor "$nested" "$monitor/" + done +} + +for monitor_dir in monitors/*; do + monitor=3D$(basename "$monitor_dir") + + if find "$monitor_dir" -mindepth 1 -type d | grep -q .; then + test_container_monitor "$monitor" + else + test_monitor_reactor "$monitor" + fi +done + +monitor=3D$(ls /sys/kernel/tracing/rv/monitors -1 | head -n 1) +test -f "monitors/$monitor/reactors" +! echo non_existent_reactor > "monitors/$monitor/reactors" +! grep -q "\\[non_existent_reactor\\]" "monitors/$monitor/reactors" diff --git a/tools/testing/selftests/verification/test.d/rv_monitors_availa= ble.tc b/tools/testing/selftests/verification/test.d/rv_monitors_available.= tc new file mode 100644 index 000000000000..e6a4a1410690 --- /dev/null +++ b/tools/testing/selftests/verification/test.d/rv_monitors_available.tc @@ -0,0 +1,18 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# description: Check available monitors + +for monitor_dir in monitors/*; do + monitor=3D$(basename "$monitor_dir") + + grep -q "^$monitor$" available_monitors + grep -q . "$monitor_dir"/desc + + for nested_dir in "$monitor_dir"/*; do + [ -d "$nested_dir" ] || continue + nested=3D$(basename "$nested_dir") + + grep -q "^$monitor:$nested$" available_monitors + grep -q . "$nested_dir"/desc + done +done diff --git a/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc = b/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc new file mode 100644 index 000000000000..5a59432b1d93 --- /dev/null +++ b/tools/testing/selftests/verification/test.d/rv_wwnr_printk.tc @@ -0,0 +1,30 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# description: Test wwnr monitor with printk reactor +# requires: available_reactors wwnr:monitor printk:reactor stress-ng:progr= am + +load() { # returns true if there was a reaction + local lines_before num + num=3D$((($(nproc) + 1) / 2)) + lines_before=3D$(dmesg | wc -l) + stress-ng --cpu-sched "$num" --timer "$num" -t 5 -q + dmesg | tail -n $((lines_before + 1)) | grep -q "rv: monitor wwnr does no= t allow event" +} + +echo 1 > monitors/wwnr/enable +echo printk > monitors/wwnr/reactors + +load + +echo 0 > monitoring_on +! load +echo 1 > monitoring_on + +load + +echo 0 > reacting_on +! load +echo 1 > reacting_on + +echo nop > monitors/wwnr/reactors +echo 0 > monitors/wwnr/enable diff --git a/tools/testing/selftests/verification/verificationtest-ktap b/t= ools/testing/selftests/verification/verificationtest-ktap new file mode 100755 index 000000000000..18f7fe324e2f --- /dev/null +++ b/tools/testing/selftests/verification/verificationtest-ktap @@ -0,0 +1,8 @@ +#!/bin/sh -e +# SPDX-License-Identifier: GPL-2.0-only +# +# ftracetest-ktap: Wrapper to integrate ftracetest with the kselftest runn= er +# +# Copyright (C) Arm Ltd., 2023 + +../ftrace/ftracetest -K -v --rv ../verification --=20 2.51.0 From nobody Sat Feb 7 17:55:18 2026 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 6E51428C5AA for ; Wed, 12 Nov 2025 22:19:53 +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=1762985993; cv=none; b=skuiq32zDoa/Wvn9+LDL7fzgoiD0uPn2/jKmuVN273IUlTf8xg0ahCpxVyI0EcJlgk9fBpq4Easw+XYa32l2APWEPsVeePF2POgNfzvYmJJgWNQFGgs0VXr3Z6LfZrjK6NzEYkA1RJXgASLPUWUzVkEfJIzgd2phLzeRF3BO7RU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762985993; c=relaxed/simple; bh=POC3u7AnVbXu76ZsMfk8t9LhKEeVXOHlgPr7gXT5pAo=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=YB0bnpdlBKx8RPiscbSfu7P8/YMGIbithhlacHB6IDRBvOFgGNnOPc1HjWwFB4tgnUd/h7HI2TkH6gtCNAJhto1tDlGKQbVIcQzloKyNhZP5Uc7oPBnRY4/f64/FPzYOcbj+JiDeqFUH4Q0b0i+0DcVsbuZbR3Q3y5SQYPXrdC4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HcdTgyd1; 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="HcdTgyd1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07EFEC4CEF7; Wed, 12 Nov 2025 22:19:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762985993; bh=POC3u7AnVbXu76ZsMfk8t9LhKEeVXOHlgPr7gXT5pAo=; h=Date:From:To:Cc:Subject:References:From; b=HcdTgyd1NcLAWwZaXN4m82xXuDUY881z4V9p9TVNbhzqMOaBBbLqhwgF5jJOliDlV O2dfelbis4xeKmu22gfMqP31P1wsg+1TWc5SKM/Gj3bL99WbvkB+kATl/USOnWK6Kj Z6+RKJ+yuol88I5NcyVd0aMp6Eax4O8fl2l08fOiyxa5gmTltJ0Pba9CwBgYyyNUhM e2JKbcsYZ6XYFL2R/qsSk8EabdpdXtAh5kuzvsSra3LkUeqOlIvo1dqHF8yJhFARyn 3kkSNsmX5NfqQdYxBHCt1lpJiazGPmr9bX5wF9lj/zziVcLQ4h34cOvxHK6YUMuxsy nsNQ7D91oOTqg== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1vJJCB-00000001EWq-0Mar; Wed, 12 Nov 2025 17:20:07 -0500 Message-ID: <20251112222006.938247478@kernel.org> User-Agent: quilt/0.68 Date: Wed, 12 Nov 2025 17:19:49 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Gabriele Monaco , Nam Cao , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [for-next][PATCH 3/5] rv: Pass va_list to reactors References: <20251112221946.389142361@kernel.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" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Thomas=3D20Wei=3DC3=3D9Fschuh?=3D The only thing the reactors can do with the passed in varargs is to convert it into a va_list. Do that in a central helper instead. It simplifies the reactors, removes some hairy macro-generated code and introduces a convenient hook point to modify reactor behavior. Signed-off-by: Thomas Wei=C3=9Fschuh Link: https://lore.kernel.org/r/20251014-rv-lockdep-v1-1-0b9e51919ea8@linut= ronix.de Signed-off-by: Gabriele Monaco --- include/linux/rv.h | 11 ++++++++-- include/rv/da_monitor.h | 35 +++++++++----------------------- include/rv/ltl_monitor.h | 18 +++++----------- kernel/trace/rv/reactor_panic.c | 6 +----- kernel/trace/rv/reactor_printk.c | 6 +----- kernel/trace/rv/rv_reactors.c | 16 ++++++++++++++- 6 files changed, 41 insertions(+), 51 deletions(-) diff --git a/include/linux/rv.h b/include/linux/rv.h index 9520aab34bcb..b567b0191e67 100644 --- a/include/linux/rv.h +++ b/include/linux/rv.h @@ -88,7 +88,7 @@ union rv_task_monitor { struct rv_reactor { const char *name; const char *description; - __printf(1, 2) void (*react)(const char *msg, ...); + __printf(1, 0) void (*react)(const char *msg, va_list args); struct list_head list; }; #endif @@ -102,7 +102,7 @@ struct rv_monitor { void (*reset)(void); #ifdef CONFIG_RV_REACTORS struct rv_reactor *reactor; - __printf(1, 2) void (*react)(const char *msg, ...); + __printf(1, 0) void (*react)(const char *msg, va_list args); #endif struct list_head list; struct rv_monitor *parent; @@ -119,11 +119,18 @@ void rv_put_task_monitor_slot(int slot); bool rv_reacting_on(void); int rv_unregister_reactor(struct rv_reactor *reactor); int rv_register_reactor(struct rv_reactor *reactor); +__printf(2, 3) +void rv_react(struct rv_monitor *monitor, const char *msg, ...); #else static inline bool rv_reacting_on(void) { return false; } + +__printf(2, 3) +static inline void rv_react(struct rv_monitor *monitor, const char *msg, .= ..) +{ +} #endif /* CONFIG_RV_REACTORS */ =20 #endif /* CONFIG_RV */ diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index 17fa4f6e5ea6..0cef64366538 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -16,34 +16,19 @@ #include #include =20 -#ifdef CONFIG_RV_REACTORS - -#define DECLARE_RV_REACTING_HELPERS(name, type) \ -static void cond_react_##name(type curr_state, type event) \ -{ \ - if (!rv_reacting_on() || !rv_##name.react) \ - return; \ - rv_##name.react("rv: monitor %s does not allow event %s on state %s\n", = \ - #name, \ - model_get_event_name_##name(event), \ - model_get_state_name_##name(curr_state)); \ -} - -#else /* CONFIG_RV_REACTOR */ - -#define DECLARE_RV_REACTING_HELPERS(name, type) \ -static void cond_react_##name(type curr_state, type event) \ -{ \ - return; \ -} -#endif - /* * Generic helpers for all types of deterministic automata monitors. */ #define DECLARE_DA_MON_GENERIC_HELPERS(name, type) \ \ -DECLARE_RV_REACTING_HELPERS(name, type) \ +static void react_##name(type curr_state, type event) \ +{ \ + rv_react(&rv_##name, \ + "rv: monitor %s does not allow event %s on state %s\n", \ + #name, \ + model_get_event_name_##name(event), \ + model_get_state_name_##name(curr_state)); \ +} \ \ /* \ * da_monitor_reset_##name - reset a monitor and setting it to init state = \ @@ -126,7 +111,7 @@ da_event_##name(struct da_monitor *da_mon, enum events_= ##name event) \ for (int i =3D 0; i < MAX_DA_RETRY_RACING_EVENTS; i++) { \ next_state =3D model_get_next_state_##name(curr_state, event); \ if (next_state =3D=3D INVALID_STATE) { \ - cond_react_##name(curr_state, event); \ + react_##name(curr_state, event); \ trace_error_##name(model_get_state_name_##name(curr_state), \ model_get_event_name_##name(event)); \ return false; \ @@ -165,7 +150,7 @@ static inline bool da_event_##name(struct da_monitor *d= a_mon, struct task_struct for (int i =3D 0; i < MAX_DA_RETRY_RACING_EVENTS; i++) { \ next_state =3D model_get_next_state_##name(curr_state, event); \ if (next_state =3D=3D INVALID_STATE) { \ - cond_react_##name(curr_state, event); \ + react_##name(curr_state, event); \ trace_error_##name(tsk->pid, \ model_get_state_name_##name(curr_state), \ model_get_event_name_##name(event)); \ diff --git a/include/rv/ltl_monitor.h b/include/rv/ltl_monitor.h index 5368cf5fd623..00c42b36f961 100644 --- a/include/rv/ltl_monitor.h +++ b/include/rv/ltl_monitor.h @@ -16,21 +16,12 @@ #error "Please include $(MODEL_NAME).h generated by rvgen" #endif =20 -#ifdef CONFIG_RV_REACTORS #define RV_MONITOR_NAME CONCATENATE(rv_, MONITOR_NAME) -static struct rv_monitor RV_MONITOR_NAME; =20 -static void rv_cond_react(struct task_struct *task) -{ - if (!rv_reacting_on() || !RV_MONITOR_NAME.react) - return; - RV_MONITOR_NAME.react("rv: "__stringify(MONITOR_NAME)": %s[%d]: violation= detected\n", - task->comm, task->pid); -} +#ifdef CONFIG_RV_REACTORS +static struct rv_monitor RV_MONITOR_NAME; #else -static void rv_cond_react(struct task_struct *task) -{ -} +extern struct rv_monitor RV_MONITOR_NAME; #endif =20 static int ltl_monitor_slot =3D RV_PER_TASK_MONITOR_INIT; @@ -98,7 +89,8 @@ static void ltl_monitor_destroy(void) static void ltl_illegal_state(struct task_struct *task, struct ltl_monitor= *mon) { CONCATENATE(trace_error_, MONITOR_NAME)(task); - rv_cond_react(task); + rv_react(&RV_MONITOR_NAME, "rv: "__stringify(MONITOR_NAME)": %s[%d]: viol= ation detected\n", + task->comm, task->pid); } =20 static void ltl_attempt_start(struct task_struct *task, struct ltl_monitor= *mon) diff --git a/kernel/trace/rv/reactor_panic.c b/kernel/trace/rv/reactor_pani= c.c index 74c6bcc2c749..76537b8a4343 100644 --- a/kernel/trace/rv/reactor_panic.c +++ b/kernel/trace/rv/reactor_panic.c @@ -13,13 +13,9 @@ #include #include =20 -__printf(1, 2) static void rv_panic_reaction(const char *msg, ...) +__printf(1, 0) static void rv_panic_reaction(const char *msg, va_list args) { - va_list args; - - va_start(args, msg); vpanic(msg, args); - va_end(args); } =20 static struct rv_reactor rv_panic =3D { diff --git a/kernel/trace/rv/reactor_printk.c b/kernel/trace/rv/reactor_pri= ntk.c index 2dae2916c05f..48c934e315b3 100644 --- a/kernel/trace/rv/reactor_printk.c +++ b/kernel/trace/rv/reactor_printk.c @@ -12,13 +12,9 @@ #include #include =20 -__printf(1, 2) static void rv_printk_reaction(const char *msg, ...) +__printf(1, 0) static void rv_printk_reaction(const char *msg, va_list arg= s) { - va_list args; - - va_start(args, msg); vprintk_deferred(msg, args); - va_end(args); } =20 static struct rv_reactor rv_printk =3D { diff --git a/kernel/trace/rv/rv_reactors.c b/kernel/trace/rv/rv_reactors.c index d32859fec238..cb1a5968055a 100644 --- a/kernel/trace/rv/rv_reactors.c +++ b/kernel/trace/rv/rv_reactors.c @@ -438,7 +438,7 @@ int reactor_populate_monitor(struct rv_monitor *mon) /* * Nop reactor register */ -__printf(1, 2) static void rv_nop_reaction(const char *msg, ...) +__printf(1, 0) static void rv_nop_reaction(const char *msg, va_list args) { } =20 @@ -477,3 +477,17 @@ int init_rv_reactors(struct dentry *root_dir) out_err: return -ENOMEM; } + +void rv_react(struct rv_monitor *monitor, const char *msg, ...) +{ + va_list args; + + if (!rv_reacting_on() || !monitor->react) + return; + + va_start(args, msg); + + monitor->react(msg, args); + + va_end(args); +} --=20 2.51.0 From nobody Sat Feb 7 17:55:18 2026 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 707D729AB1D for ; Wed, 12 Nov 2025 22:19:53 +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=1762985993; cv=none; b=tJK/6lc3GIdzecTLlniWUrEzB2gFTldTGGJqbM5t0Ozh8zUYW52esOXIjDCChKsNVU+YFmJiR5vUqPZnhO/xtKOSe4pVQQq93Bi54XrHbc4OwiaOjkbg86TOW3nLAOs7YFyDcwzpX4yGZ8Fg3dXzvR1Ka2uD2msD5SSzZpoiB28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762985993; c=relaxed/simple; bh=wLQokJFz1wJt7wW+XrZdqXT92F4SQ3D4BM/d3+RYbOM=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=iAy6bxk3p/Mv15s3WnDJp406xf42xxeY66ypNXzDhg+9K46wSjg519pcoVOa9DBq0NxEGXJiOBIaIWA2FX/AVkK4zEBtdVchlOVjWgHYKEiFqaKjl11Mh/OHJpL+09bWkfaP80wpTK+gj4ejXcQAF/jd6vGbm45wcztL8lpJmt4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SPV+HWXm; 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="SPV+HWXm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 360E1C4CEF1; Wed, 12 Nov 2025 22:19:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762985993; bh=wLQokJFz1wJt7wW+XrZdqXT92F4SQ3D4BM/d3+RYbOM=; h=Date:From:To:Cc:Subject:References:From; b=SPV+HWXmrFaqCS7V3tDDaSxP2iIA5+3r1I2WLsa7qbwHQ6Bt5/ZnwGGaSvw4dfYeT w1OkO6W3m1jL2JPHq5nCo4UGmgewrMI59m4RVRpQz1tVDwsuiPJHBoX9dwJ/kDNWoM QGmjUTlZEPKJREAgcNWXZ0jsy6ESNHivz/5tGYG3UgLCABQcap2cCVv8/XJe5yyD26 ZQdwfeacnyn44S0RhKUI7DJ9tDV6TOH1NZMHPL8FbRylc8FGWHFHcupgq4gT3cXa1Y 07nWTBTI5RkTu22SHZgovDrsnsrJcasNoaqMgjoXYWKv8aWu6+BafoS78JLNJtq3Dl jDmf6N8+mLN3g== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1vJJCB-00000001EXL-13nG; Wed, 12 Nov 2025 17:20:07 -0500 Message-ID: <20251112222007.106173327@kernel.org> User-Agent: quilt/0.68 Date: Wed, 12 Nov 2025 17:19:50 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Gabriele Monaco , Nam Cao , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [for-next][PATCH 4/5] rv: Make rv_reacting_on() static References: <20251112221946.389142361@kernel.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" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Thomas=3D20Wei=3DC3=3D9Fschuh?=3D There are no external users left. Signed-off-by: Thomas Wei=C3=9Fschuh Link: https://lore.kernel.org/r/20251014-rv-lockdep-v1-2-0b9e51919ea8@linut= ronix.de Signed-off-by: Gabriele Monaco --- include/linux/rv.h | 6 ------ kernel/trace/rv/rv_reactors.c | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/include/linux/rv.h b/include/linux/rv.h index b567b0191e67..92fd467547e7 100644 --- a/include/linux/rv.h +++ b/include/linux/rv.h @@ -116,17 +116,11 @@ int rv_get_task_monitor_slot(void); void rv_put_task_monitor_slot(int slot); =20 #ifdef CONFIG_RV_REACTORS -bool rv_reacting_on(void); int rv_unregister_reactor(struct rv_reactor *reactor); int rv_register_reactor(struct rv_reactor *reactor); __printf(2, 3) void rv_react(struct rv_monitor *monitor, const char *msg, ...); #else -static inline bool rv_reacting_on(void) -{ - return false; -} - __printf(2, 3) static inline void rv_react(struct rv_monitor *monitor, const char *msg, .= ..) { diff --git a/kernel/trace/rv/rv_reactors.c b/kernel/trace/rv/rv_reactors.c index cb1a5968055a..8c02426bc3bd 100644 --- a/kernel/trace/rv/rv_reactors.c +++ b/kernel/trace/rv/rv_reactors.c @@ -347,7 +347,7 @@ static bool __read_mostly reacting_on; * * Returns 1 if on, 0 otherwise. */ -bool rv_reacting_on(void) +static bool rv_reacting_on(void) { /* Ensures that concurrent monitors read consistent reacting_on */ smp_rmb(); --=20 2.51.0 From nobody Sat Feb 7 17:55:18 2026 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 CFD662EA498 for ; Wed, 12 Nov 2025 22:19:53 +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=1762985993; cv=none; b=AjqtyIM7U9HttHQ6RKe8zkF21FzH5RqqWT2x+WH5jtvRBOZBguHE2yYKVBqEHmzKfQ7xGDFyTVzHsi0oy59x2Udexdkx+XoYEseTMUc4Ibjk9rqi1TZh9fwtQhp82+hcpxOxiyp9/xb5ghNOF3tYg4188SDiec2bmyKrH4PxKKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762985993; c=relaxed/simple; bh=dW7Y5ku/4jvaiMSFZjxle0SPJcMrxQH3HmYjz1L2a70=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=icQ4a59cs7dR0TOFxOBFEduV+c+mI9VuFSl7nQBIsts5cnfddqoHgckUa9EYRTYIo4N7CavOxP+6JsYp99lkoYS9aCtAdo6jn3T+4gBiFkP+EHYusTvL1Q1JE/gq659z2OW3Gf11DezzWT/G4ZMEYSJecI7PYCnsWmfBcFHcK6U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GOW56R3O; 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="GOW56R3O" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63C97C2BCB1; Wed, 12 Nov 2025 22:19:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762985993; bh=dW7Y5ku/4jvaiMSFZjxle0SPJcMrxQH3HmYjz1L2a70=; h=Date:From:To:Cc:Subject:References:From; b=GOW56R3OW8o8rp1k5xD2HyLg1ZKRXOlaKihWNdJgin7YX7B+0s/gPjTMfNKZcm1PE WDbXulZWx3142M4W7yXLz82DCdHG5w3iJbki86xbpLQfFIOioH3LhuzElG2FvFo7q8 zDNosMpptjB5rqqOTigdKQCUFLm2M4xzN1mtzAKzuofOthB2Icy1J5dlAF8bnJoZ6H Zzx/fq3MPLhbvdPv1B2EzCqVLX8Bhpj+nRyVqpF5aUrDLjphGpqWAT34N4BsTGvNyo T6mbtl4iocW3ETUeotx+TuUKBQu/aTR5XGfWSfeMJlAchoONC7Ep/2+egDu+Q9TRBU /Cu8L90X4XsDA== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1vJJCB-00000001EXp-1lME; Wed, 12 Nov 2025 17:20:07 -0500 Message-ID: <20251112222007.272818255@kernel.org> User-Agent: quilt/0.68 Date: Wed, 12 Nov 2025 17:19:51 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Gabriele Monaco , Nam Cao , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [for-next][PATCH 5/5] rv: Add explicit lockdep context for reactors References: <20251112221946.389142361@kernel.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" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Thomas=3D20Wei=3DC3=3D9Fschuh?=3D Reactors can be called from any context through tracepoints. When developing reactors care needs to be taken to only call APIs which are safe. As the tracepoints used during testing may not actually be called from restrictive contexts lockdep may not be helpful. Add explicit overrides to help lockdep find invalid code patterns. The usage of LD_WAIT_FREE will trigger lockdep warnings in the panic reactor. These are indeed valid warnings but they are out of scope for RV and will instead be fixed by the printk subsystem. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Nam Cao Link: https://lore.kernel.org/r/20251014-rv-lockdep-v1-3-0b9e51919ea8@linut= ronix.de Signed-off-by: Gabriele Monaco --- kernel/trace/rv/rv_reactors.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/trace/rv/rv_reactors.c b/kernel/trace/rv/rv_reactors.c index 8c02426bc3bd..d9d335ae9bad 100644 --- a/kernel/trace/rv/rv_reactors.c +++ b/kernel/trace/rv/rv_reactors.c @@ -61,6 +61,7 @@ * printk */ =20 +#include #include =20 #include "rv.h" @@ -480,6 +481,7 @@ int init_rv_reactors(struct dentry *root_dir) =20 void rv_react(struct rv_monitor *monitor, const char *msg, ...) { + static DEFINE_WAIT_OVERRIDE_MAP(rv_react_map, LD_WAIT_FREE); va_list args; =20 if (!rv_reacting_on() || !monitor->react) @@ -487,7 +489,9 @@ void rv_react(struct rv_monitor *monitor, const char *m= sg, ...) =20 va_start(args, msg); =20 + lock_map_acquire_try(&rv_react_map); monitor->react(msg, args); + lock_map_release(&rv_react_map); =20 va_end(args); } --=20 2.51.0