From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC60E3B95E7 for ; Tue, 21 Jul 2026 20:57:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784667443; cv=none; b=h/2Bj8y/41o45NXLs2AVVOFM2tBoRhM4jfmI+ygNm5X+qF7JrYXuWZ5/iKJ9fqFRAQPTLtKuhtUszjKCkILNCQXKNmQj5p7C9AxZx1jveKg9rfn48pTn/6iae8z7wNhqh1R4mlyXtUiPZryqoifXgrY01JQbZWl/kCTzeEOlE1w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784667443; c=relaxed/simple; bh=IFmT1K0aYsBk0y1wHZTyA/TzgN5RNbWFj8VGiyVMTHE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KR8DpkCCPKiJl6zEC0+SjfvYKQ4s0btgoQIgvA/knkAqGUgCBbPDkvN9u5TCjexl8VYj+4Oi1Qyd4y/qSqTld30NXivi+7wU3Z7ZxR8vt9cclMaHxshUZUDL/trRyv+hoDc2/6TlJZCVqrAaiQmeFBg/f2kr+HVrFqEyUkNR2gE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZXLWsfWV; arc=none smtp.client-ip=209.85.210.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZXLWsfWV" Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-7e6b554044fso9243400a34.0 for ; Tue, 21 Jul 2026 13:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784667434; x=1785272234; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xkhsq9NkC/hHTDIK98lXqvKIn9Pks2kt3Kgfo8nEUZk=; b=ZXLWsfWVcV0q7vSE3BsQgf7OpHatSbL25AMqCOwlTU+Vp4sXe5uvgLoHjHyjQnWUKp 3vp69eD2o/oT1XmWKfjaLwOKMYeJB2rJ2kLLvA8SFJ5TA+q3V/mTbxnfWxmvO2ybJ7j3 EtSJM72Ib6wsWIT8NVwQxj0PX0ENhqQb9pH8TRB0JDfew4dHSG1QwZ0JXwdlq6spUE4p IpIulcawwHJz1/iUo4CJu6JYfFASLnogeKRgyY8/ztGg7gPiwb1eX7SC+4rdcwQJGAlm 8LA2R6uY2d+/NO/nApe1HkDbL/XwzbLQryyeErBZQaCjEujopraG9fYdD/GReEDwBVQs 8t/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784667434; x=1785272234; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=xkhsq9NkC/hHTDIK98lXqvKIn9Pks2kt3Kgfo8nEUZk=; b=ZvMI+xXgfQfJRPZhHWl8srsDm+McutJdRhBAWwa9BF+ehCmPXiVDcrCHiDNagW8IyM BWz5Dmhrm+zRq+u/AFi5QXuM66YpFzRrlGmRsAKqnCnRwqdpB4I4RsKdz/CyhOIUofL9 BkHE9sT7z4ssoOSAiVyRYid9vEbBJPdsN9dGsRynyJgH0+91GkuxPQhnGawm9uD7LcN6 5zRfgfNwZ/HySi9YlglfbvtEuWyqOYof3UR+q3Ay24kYQFkI0z3U4oZvz3dWd0ML8afH +M31LZiZTf7tfFz2gNRkwEOto+g1b5OQSV3EiXwu4weXRkx06pZRRJSlwv5bHjUiil4c ZBSQ== X-Forwarded-Encrypted: i=1; AHgh+RpSfJnlBqeZ3y955EoYWqu14pNV9ZjT3mtI61+5diDo/LRvJTbL5oNwkaf2DGz+sBWPSml8nu0QMdgr2CCz@vger.kernel.org X-Gm-Message-State: AOJu0YyXcNRdQTUG/m0BqpRODldOUDq6tZ0AJ8aSRRfTBlY+euQQ2luX 4SHXsyjpvsiVOuenBWEmD1HsLhFdHNaDi+x2H9Ud1NJWMZBeO0PXSigq6EEkYA== X-Gm-Gg: AfdE7cn6L6rM95QEmZs1F7oNXG9jPI+KFGKJtF/XGRzMDX6MImmPPTGiRQUlbSPOo6f 8aL566YkOByivLDMpwCJlL1cGoGikCV5bhWNnqxiElvasNVViih4X2KB9vsihYVn8spwol0KZdN /VkLrRYV3/G0YoKc4MjOBM8EHuqXaXSCprOzd1L5+K8KsxdD3FU8F/bmKguZCEth+ZodR3ff8ok FRC5HqBYaIhvfuflhzfFWCoyI0s+JRx0uV47SM/nNyGNiW89yXw6unz+xByb6IFc50/giTvQBfL Y+8XZGrNIQFKgxLzqjSPSbIjEGugFlfpjTIUkoHWFRI93agvrnhcaCJYn2tIQ42TuNvCV6cH5ME 1KHmLMIJ1ir1x1WdkGsHxIxzBLn6PfR91krmdz2IT8S1TMhVnPz66ZihMNLrRK6XJtZNasUj2XL bZQVQuV517C92GWRs+ZfafNS/JKD7elq4TgLXnV6jHVlFA7x0iXT8YWtbkhldNxS6dkZw/KVW/h nj9lQoXljY+JmzE76ez8Jz9dVbHzvzG3cLI X-Received: by 2002:a05:6830:2693:b0:7e9:db7f:49a2 with SMTP id 46e09a7af769-7eda0963d14mr10863781a34.19.1784667433697; Tue, 21 Jul 2026 13:57:13 -0700 (PDT) Received: from [192.168.0.245] (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 46e09a7af769-7edaf94a494sm11134501a34.13.2026.07.21.13.57.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 13:57:13 -0700 (PDT) From: Jim Cromie Date: Tue, 21 Jul 2026 14:56:51 -0600 Subject: [PATCH v7 02/29] selftests/dyndbg: Add kselftest script to verify dynamic-debug Precedence: bulk X-Mailing-List: linux-modules@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: <20260721-dd-maint-2-v7-2-010fbe73b311@gmail.com> References: <20260721-dd-maint-2-v7-0-010fbe73b311@gmail.com> In-Reply-To: <20260721-dd-maint-2-v7-0-010fbe73b311@gmail.com> To: Andrew Morton , Jason Baron , Greg Kroah-Hartman , Shuah Khan , Simona Vetter , Luis Chamberlain , Petr Pavlu Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784667429; l=63443; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=IFmT1K0aYsBk0y1wHZTyA/TzgN5RNbWFj8VGiyVMTHE=; b=EFRP2g251a2qXHAmkTOFMC13PptqqE/CILNDwa1erpy3rNiCVwomri9lOyhIS2Lfn2UB98Ikp 7dzpJrX/iQACv3q9Q/v1cv7zs+fDNpiZklDbNgPpdWIjMl5H+etmcjh X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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 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 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. * FT_comma_terminators: Verifies dynamic-debug's comma-to-space query tokenization and multi-query splitting on '@' delimiters. 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(