From mboxrd@z Thu Jan 1 00:00:00 1970 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 BFC76346FC8; Sat, 5 Sep 2026 18:13:39 +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=1788632019; cv=none; b=Fda8oN2VsRe3gk0ungOxJlci2vSUxcp+nfr9Ulv4yRbNxhEaTwKOnr4HEGvHknmcB+eYkeyE2VqOY/fCGs2fCidOxQ0JuRZWK+tCOc9u0soREaqcGJBFyci8wKdptX5uc+W5c1iRfg3J8k5rsxzxvw+BD6H5TYSfplQlkc2hdiw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788632019; c=relaxed/simple; bh=k7SlDvjDqFWXDNg6cCg/KyFZmoBK5LXzPPtQl5wFVWU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iz4jumSKTdfG18ZWw7WWKdePhwJrL2mg3UGpn8ul08krDZ0lA9cLbNlRACML+ogDJF25mHP0HHs+X6lH3hDfy9pZUK+9SFY5+WYIuyTsHVErEEUX1BiLaqD4wr37ptq6ozhk6V+6JRXlREEXtXlRVd4c2hLaTc+1Gx1isYpPXvU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mk3Sln7m; 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="Mk3Sln7m" Received: by smtp.kernel.org (Postfix) with ESMTPS id 72684C2BCF7; Sat, 5 Sep 2026 18:13:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788632019; bh=k7SlDvjDqFWXDNg6cCg/KyFZmoBK5LXzPPtQl5wFVWU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Mk3Sln7m06hwoU4F3z1BOfy0sefgnY8H6VfDHlHYiyzQEs/A8sZbfICv9ZyyHUyxm vNdqm3nG4Rit3+GcdGfJYisA3vvkvrlzNzp1v2JPSV2p3gz8iRI17N2sUdXGGWr7tm SmqPa6aG1f/RxZC4UPXEBBlALLEjORIvuUVnBl3Wpkj0lsOB/WwIeu9CARk7XNJ6x9 hdInfccPrfYfa5ZWmZExTKFYyfF+MM1UKRGy1Xe0/btixDiuy3umfxTvBOZFYPPeYG xZXboGSsOBfXp05pm0DRBz4HEbCxii5b9CLckml5HDUGshjbgTttQH7rUc8Ylt2Yvn LvawrTW26lnsg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55A33C624DB; Sat, 5 Sep 2026 18:13:39 +0000 (UTC) From: Jim Cromie via B4 Relay Date: Sat, 05 Sep 2026 12:13:15 -0600 Subject: [PATCH v8 01/43] selftests/dyndbg: Add kselftest script to verify dynamic-debug Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260905-dd-cmap-part2-clean-v8-1-a4cc0674f6fd@gmail.com> References: <20260905-dd-cmap-part2-clean-v8-0-a4cc0674f6fd@gmail.com> In-Reply-To: <20260905-dd-cmap-part2-clean-v8-0-a4cc0674f6fd@gmail.com> To: Jason Baron , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Arnd Bergmann , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Jonathan Corbet , Shuah Khan , Greg Kroah-Hartman , Nathan Chancellor , Nicolas Schier Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788632017; l=61836; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=op4rWxqZAWoh6lVj+L/ADc29HYdB+dd27befe49UtFE=; b=tQv5BFYb42H/B0zpdKD4wFpwdMnxch7r9PjXsYG26jdegfwPbozkS1k5v3dl6hq8B9iwIqSrR 9Kqj4LCh2rDB5xSicy2lWKlbm3Loi+k6b3ArAs7uIM9lMEzX1urNwrG X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= X-Endpoint-Received: by B4 Relay for jim.cromie@gmail.com/20260203 with auth_id=958 X-Original-From: Jim Cromie Reply-To: jim.cromie@gmail.com From: Jim Cromie Add a kselftest script to attempt full validation of dynamic-debug behavior. The script tests query grammar as documented, responses to bad input, and proper/expected effects on both the control-file display of current state, and on pr_debug logging behavior. NOTE: This script was finished last, then rebased to front; It gives an easy functional test thru the series, not just a does-it-boot. It preserves but disables some tests to pass as a baseline; there are 3 Basics: FT_grammar_ok(), FT_grammar_errs(), FT_basic_queries(). The Canonical Test: A naive dyndbg test might look like: echo "module main +mfp" > /proc/dynamic_debug/control local ct=$(grep -c " =pmf " /proc/dynamic_debug/control) (( $ct == $expected)) || FAIL But you'll find that you've changed 4 different modules, and your count is off. Ad-hoc testing is hard, and fundamentally trades test clarity against thoroughness, precision and brittleness. Here, the canonical test tries harder: 1. Observe the prior dyndbg state-of-interest. 2. Send $cmd to change state-of-interest. a: echo $cmd > control b: echo 1 > "/sys/module/test_dynamic_debug/parameters/do_classes" 3. Observe the results, in control-file or dmesg The key here is 'observe' means `md5sum $state-of-interest`. This gives us total "checksum" precision, and with a little care, $state-of-interest mostly solves the brittleness. If a test should cause logging: 1. Sends a unique 'START_of_label' message directly to syslog/dmesg. 2. Sends the command or parameter configuration, as in b: above. 3. Sends a unique 'END_of_label' message directly to syslog/dmesg. 4. read dmesg, extract START..END This bookended logging allows the script to isolate and reliably extract the precise dmesg/syslog slice between the markers, and fingerprint the state-of-interest cryptographically. Its not truly isolated from busy-kernel messages, unless its a test-vm. Comprehensive Feature Test (FT_*) Script Mapping: The Feature Test (FT_*) functions test major aspects of dynamic-debug, they're in 3 categories: 1: Zero-Dependency Grammar & Core Parser Tests These tests throw legal & illegal commands at the >control file, but don't attempt to select any real pr_debug callsite. * FT_grammar_ok: Verifies successful query grammar parses (exact line, open line range, closed line range, and colon-delimited file:line/file:func syntax) using side-effect-free empty placeholder flags ('+_'). * FT_grammar_errs: Verifies core query parser error-handling and EINVAL paths across multiple verbosity levels (0..3), catching even minor message drift. 2: Built-in Feature & Name Equivalence Tests (Kernel Core) These tests verify the core features compiled directly into the kernel image. They validate "[main]" vs "[init/main]" resolution added recently. * FT_basic_queries: Verifies basic, direct queries (module, func, format, and clear flags '=_') targeting the builtin kernel/params engine. These tests are disabled until KBUILD_MODFILE: * FT_path_module_queries: Verifies path-based and wildcard module query controls (such as module 'init/main', module '*/main') targeting builtin startup callsites. This specifically validates the back-compat resolution of the old 'module main' ambiguity (which selects 5-6 different built-in modules). * FT_hyphen_underscore: Verifies literal name versus kbasename hyphen/underscore equivalence (e.g., kvm_intel vs. kvm-intel), proving that both queries select identical ranges-of-interest. This validates recent kernel fixes establishing name-normalization equivalence inside the query engine, ensuring that character substitutions work as they do in modprobe. 3: Tests which require test_dynamic_debug These tests verify complex classmap configurations, multi-module setups, and load-time/runtime parameter callback equivalence. * FT_test_classes: Verifies classmap-based query enablers and class configurations on a modular target, proving dynamic runtime class configurations via /proc/dynamic_debug/control. * FT_classmap_inheritance: Verifies multi-module classmap propagation and class inheritance checks between a parent and submodule sharing a classmap. This actively demonstrates a key systems distinction: one-time bare class queries (dyndbg=class...) do NOT inherit at load-time, whereas classmap module parameters (p_disjoint_bits, p_level_num) are persistent and successfully propagate state to submodules upon loading. These tests recapitulate the scenario where classmaps-v1 [1] hit regressions and was marked BROKEN. * FT_modprobe_w_param: Verifies load-time parameter callback initialization (via modprobe $param=$val) and subsequent runtime sysfs-write unsetting callbacks sequentially, by looping over verbose levels, and varying (p_disjoint_bits, p_level_num) and (do_classes, do_bulk). NB: within each FT_, tests are numbered and cataloged. This isolates each FT_* test's sequence numbers from each other. Main Test Runner (dyndbg_selftest.sh) Support Functions: * ddcmd("$query", ["$range"], ["$action"]): The core test primitive. Writes a query string to the control file. - ["$range"]: Optional slice filter pattern (triggers transition verification R1 on non-empty values). - ["$action"]: Expected outcome action ('pass' default, 'fail' asserts return code 1 and logs dmesg, 'log' asserts 0 and logs dmesg). * ddcmd_err("$query"): Semantic error query wrapper. Invokes ddcmd expected to fail. * ddcmd_load("$query", "$range", "$param_path", "$val"): Workload-driven syslog verification helper. - "$param_path": Sysfs parameter path of workload trigger. - "$val": Integer trigger value written to workload param. * verify_modprobe_param_logging("$param", "$val", "$tag"): Dynamic parameter test primitive. Coordinates load-time modprobe and runtime sysfs unsetting in a single sequence. - "$param": Module parameter name to configure at load-time. - "$val": Initial value or composite bitmask/level integer. - "$tag": Suffix used to construct the dmesg golden record label. * slice_and_hash_ddctrl("$grep_pattern"): Local control-file wrapper. * ifrmmod("$module"): Defensive module unloader. * handle_exit_code("$lineno", "$func", "$exit_code", ["$expected_code"]): Core exit code verifier. - "$lineno": Caller line number ($BASH_LINENO). - "$func": Caller function name ($FUNCNAME). - ["$expected_code"]: Expected exit code, default 0. Verification Library (syslog_hash_validation.sh) Support Functions: * log_start() / log_stop(): Slicing syslog capture bookends. Marks the start and end of a stimulus-triggered test execution by writing tags to /dev/kmsg. * rdi_resolve_label(): Active sequence resolver. Leverages Bash call-stack reflection (FUNCNAME) to determine active FT_ test functions and automatically re-index sequence numbers. * slice_by_grep("$pattern", ["$file"]): Text slice extractor. Narrows the scope of a captured log or file. - : Regex pattern to narrow the capture scope. - [file_path]: Target file path to slice (defaults to dmesg). * verify_file_slice(, [file_path], [extra_args]): Standard file transition verifier. Captures a state slice, auto- resolves the label, and verifies its cryptographic hash. - : Regex pattern defining the capture scope. - [file_path]: Target file to slice, defaulting to control-file. - [extra_args]: Optional tag appended to the golden record. * verify_dmesg_slice(