From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (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 67CE5415F10 for ; Tue, 21 Jul 2026 20:57:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784667441; cv=none; b=F/xWsp49rEA/aVk44IqBrNhOfn/K0hgjrBNH7pUGv6Gltwxpr1Xky9Tlkg8OaDYChFcxZnxPdbsKj6Ftc/8Yic52AuQdxRZanFQZKJBvy/0VQO/iwVvl420qbdALDolo8AUGUFYnDkKp3U1c1e4C/CuHSFuOBqOISo7sNpGzeQ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784667441; c=relaxed/simple; bh=IFmT1K0aYsBk0y1wHZTyA/TzgN5RNbWFj8VGiyVMTHE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AsOQ+KykKXvLBdcpFahYUzFzfEXVTOHzhAhC2EmkM1AskTgnez2pqgUSY0E1n3DbdsmjhKVfrtlqZdaWJqxodi9UVi4qP186LZmD1WpShRXgVvYP+4xzboMMYTti5zxtF7O+uikMznB2KCHC/YAFxRZmRipbWo3ZZTiQzsVlgEE= 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.52 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-f52.google.com with SMTP id 46e09a7af769-7e6b5737bb2so9194626a34.1 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=qI4LGWkeaEtFvOb46LVa3rE1Bk49zZzvxw0Bd7oHJHLZNdQfL/DyKYwVLqCw67N3aS 95s97WgRTEqitihjstjQmE3wXPxdZ9wW/UgUbxIXUDvKNlUO+6jJKczj1hFfcip/8YPb xkDPTn3yqI3b7yzcGnOwTgm3dfEJ8YPztufs6an84D3hrgUn8z4p/EFVT5cYPmlaLOwM 3+/P04jnv0yGB9SN4UwEk6/RBQgXIKVzO8A8xmfgOxIBT5b5uZHVqHVOqGIvlWaj9v3O be1IUiNehSpIH4Im1v8PWk3bVY2tfuUEjn2blLdUCWnvPbU6BvrWCrUYirVufZkmirQQ Q1+A== X-Forwarded-Encrypted: i=1; AHgh+Rq4xQGyeOr9FaCX4jRvjjoOyeiThAjaQmSdTYQMP/Znw9VZYXS6FaXhvkG6ISL/x+lH56YJwBMb9+rR@vger.kernel.org X-Gm-Message-State: AOJu0YyO/Mk9uTf5ikJeGqm8HwcW5ypXUU7bgOj30zsoyiEa19uVDaYo hBjs1tpRya4z7bdvR2FPSztxwMmBVbp4IVgVxOF10xV+7L2y+ws39hNe X-Gm-Gg: AfdE7cknvwgvEPA6wOT5o51DSWoeHNgGc8MqnVWm66mHeIb0NE8e4Ab4GmOjn2guwua 5WojJLKIlWS+IAHxnM5oB9xrvnN/2IcR8NdYQoHJ20hatXIuSAusoVxdk1iN5brxb4D7fjVseTf 5hHUzWI8d7P58/kA1kK9iHTYFcADaRiFZT4Zr928EZloD3s57JrWSia44ZnJ2BVQbEDcsI0QGKd w+3zY381s1w18AB78BBCjcurmRzsUibXKqEHWB4EbR6hMnFhkmlS3kuTP0cyWiTQrR1mmaAfuUB kpFA5AlRJvIHMuuDX7S7+eLmrGKDD+EMQG/mhn+FnYYAEImJdiGI/5Zd7cLVLcO+l+udEF/FY25 8iCeo26gl+WkGR65e1gCYhuwM7rhH2fHyQW8uZXV4BQoyxit9ZJ4OkSnigTRT2WKrbeF1w3LuRG KjMylD1GQ145cmJLV2Sr5/AsXen86iE1tYJRupg9PM6NEkK7JYMXoNlfrK+kTgUtu+jjueQo6O4 aK7/PgrUwLOn3xOAOtWaWhYQ9sqP5tqZpp/ 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-arch@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(