From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (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 B61D32FFF83 for ; Tue, 18 Nov 2025 20:19:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497146; cv=none; b=YGFdIsQ6cVRaG0Mlsu6gwX+k9FX1THkyiMx/Kf4kVMBh8tJayKWAXP5B+Cy/v0SjlcpDG/DikDbuNNK/jhBPsBlEQLulEvB1ePGVi8hFPKyGmq6MbcOkGYb4PVbLaec8e/9UqMj2Kym2aAIdpWjeG/Y93fGNxigCrA6dOJoMf/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497146; c=relaxed/simple; bh=GFEM8+QcfUKEnXIFJm2ldTy6hWoLsDr1RT45XZuDT5o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K0B4fMcs9NETnIV6GKY4GpzeF5fQAAo1V8CHdAFL+DXbiCWCbE8NygX6VDdcJ4kFLvrNQB4YiNHOZywaYj2byuaw64Q3O7qe9m5tZLB2/qreTsdMPA93D3YahqG7Pgtj6KlKxzxJfxW3vaKjAZLqn/y0RvuPUEZrYvbscD03Dy8= 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=ZgHO7wmo; arc=none smtp.client-ip=209.85.166.42 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="ZgHO7wmo" Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-948da744f87so207743539f.1 for ; Tue, 18 Nov 2025 12:19:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497142; x=1764101942; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Yf7HPZBJKJHruC1KEyryViKNbg7OZO+TlBUJ1MAjLuY=; b=ZgHO7wmocRYInqdJXeR+KZVlaf0DxSR+0IPw/worYNpR7PziAMWizMHWlbjH5tkwH2 SjcREKR6FQhC2EKmq8b8LXiKG741uy8vh4GTsf8Kkssc6hJH7jSColMXhaR1Y4/WxGS1 LGCjAuBghWp1TXMjawh0xOuiXtlgD5UVI6fadnvLAwTAxy+LuH5J+ihcdjaMYipYfmpn AkUyCf9tdGEeszcPEruys6XJ/OcnGyEJBzt2H7Kjg/b1OJsmkqdqlA6DN2L0yMQhkR3u xkbAjsztVdlG/WhwZvV0tv7W4MVOIhpT4Sdd7ltvNUW/aw8rggzmezbrp8MzDzkiG2/9 hDiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497142; x=1764101942; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Yf7HPZBJKJHruC1KEyryViKNbg7OZO+TlBUJ1MAjLuY=; b=MrikqY69zOzO1J5jwcaEQW5GI5AMaKGnuHBKM7zGqD62ykwzwyIcfUHOY42r6k/dVz 5G8rC2cds7rtlcqPzsoUCC6pARBrRnQXDwb3GnxQ32clOHFBiS15LPDhkx9W84QY2FyI NvTd1irEuL85rvTXvc+B0VzMbyonCTjpyRLS2EXRUbIUr2wDAx7sOk6EtiUeQW5pRtBC eYXTX4nO9ne5Y7ySlB9gymHQa/AUlnJnIOO/6OlSEqnn9XgasXq2SYe8TAS8xlYREPM8 8ugKuDG0nFye+5QE/EsFp6PG/INCWdGMaczEjLYPPLFA8W0zWGyHmiczAZZ2pwxjeOUX MrPw== X-Gm-Message-State: AOJu0YwC4FtUPl3OFCbWvRiPuoeldLl7lS8yyYGcAYaERkkDZNmhXNV0 YcvXIoFgsG2t4Ar+lBarhmFOd9rXLPgohuchzoUGFhIoq8w68KEmewxxf5fZ2mjJ X-Gm-Gg: ASbGncsy3Bk1CrrQVqGNy22qIN9vY9ruvaku0CHt/iCBbFfgwsVKEUaX611FmskYLr+ cccG3hQ7K+G1gGrKQjUDrOhP0z9i4Fn1h/+LgIYk8IQnFZFNQCpUC17nr7ocCNLUOf64mv3bf3J EuauBWyLBL8K9iWvwbZq1B/VLp0uB49OtwWpxBGgaYS0X0h0m2RhrTJ2hbkUnmHPUWxpm6Uw1F/ 20HYDg72CsfqaVwGDfPHsuY9Cd/m8ZnM1eWXx06xQox4jf/TMphQSHqHh3sEdkaEBEkN56IDjv6 G3CS5PI3CaQ6LcBIDzMmd7vX6JQuDs6YE7sCA9e2jILTusF/i/ho8IAn6WzqiTyCrxYsorZq7uj Ow2JydcYyyUa6VsAetY891YShBxnusJWCsaK32GxgPowfPt5cGgF+YkVUuSN2uH2Ud5JBGMYB1q klV3qpyx37eZ1JPKAeulkoS4ix66E2ZwqHhXirpwqCh+rlnS5hraN+Uc29/d2stVGxMvk= X-Google-Smtp-Source: AGHT+IFyy6Jrx9tl9L5mqbYqFHfaDNvQOzCPxl+EKL0q8oHuHQE3Af4yD/v7Nfkkp9FTpOmIpMo3lg== X-Received: by 2002:a05:6602:1344:b0:945:a27d:d4a6 with SMTP id ca18e2360f4ac-948e0d640d6mr1903420639f.12.1763497141733; Tue, 18 Nov 2025 12:19:01 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:01 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 01/31] dyndbg: factor ddebug_match_desc out from ddebug_change Date: Tue, 18 Nov 2025 13:18:11 -0700 Message-ID: <20251118201842.1447666-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" ddebug_change() is a big (~100 lines) function with a nested for loop. The outer loop walks the per-module ddebug_tables list, and does module stuff: it filters on a query's "module FOO*" and "class BAR", failures here skip the entire inner loop. The inner loop (60 lines) scans a module's descriptors. It starts with a long block of filters on function, line, format, and the validated "BAR" class (or the legacy/_DPRINTK_CLASS_DFLT). These filters "continue" past pr_debugs that don't match the query criteria, before it falls through the code below that counts matches, then adjusts the flags and static-keys. This is unnecessarily hard to think about. So move the per-descriptor filter-block into a boolean function: ddebug_match_desc(desc), and change each "continue" to "return false". This puts a clear interface in place, so any future changes are either inside, outside, or across this interface. also fix checkpatch complaints about spaces and braces. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 83 +++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 5a007952f7f2..eb5146bcfaca 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -171,6 +171,52 @@ static struct ddebug_class_map *ddebug_find_valid_clas= s(struct ddebug_table cons * callsites, normally the same as number of changes. If verbose, * logs the changes. Takes ddebug_lock. */ +static bool ddebug_match_desc(const struct ddebug_query *query, + struct _ddebug *dp, + int valid_class) +{ + /* match site against query-class */ + if (dp->class_id !=3D valid_class) + return false; + + /* match against the source filename */ + if (query->filename && + !match_wildcard(query->filename, dp->filename) && + !match_wildcard(query->filename, + kbasename(dp->filename)) && + !match_wildcard(query->filename, + trim_prefix(dp->filename))) + return false; + + /* match against the function */ + if (query->function && + !match_wildcard(query->function, dp->function)) + return false; + + /* match against the format */ + if (query->format) { + if (*query->format =3D=3D '^') { + char *p; + /* anchored search. match must be at beginning */ + p =3D strstr(dp->format, query->format + 1); + if (p !=3D dp->format) + return false; + } else if (!strstr(dp->format, query->format)) { + return false; + } + } + + /* match against the line number range */ + if (query->first_lineno && + dp->lineno < query->first_lineno) + return false; + if (query->last_lineno && + dp->lineno > query->last_lineno) + return false; + + return true; +} + static int ddebug_change(const struct ddebug_query *query, struct flag_settings *modifiers) { @@ -203,42 +249,7 @@ static int ddebug_change(const struct ddebug_query *qu= ery, for (i =3D 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp =3D &dt->ddebugs[i]; =20 - /* match site against query-class */ - if (dp->class_id !=3D valid_class) - continue; - - /* match against the source filename */ - if (query->filename && - !match_wildcard(query->filename, dp->filename) && - !match_wildcard(query->filename, - kbasename(dp->filename)) && - !match_wildcard(query->filename, - trim_prefix(dp->filename))) - continue; - - /* match against the function */ - if (query->function && - !match_wildcard(query->function, dp->function)) - continue; - - /* match against the format */ - if (query->format) { - if (*query->format =3D=3D '^') { - char *p; - /* anchored search. match must be at beginning */ - p =3D strstr(dp->format, query->format+1); - if (p !=3D dp->format) - continue; - } else if (!strstr(dp->format, query->format)) - continue; - } - - /* match against the line number range */ - if (query->first_lineno && - dp->lineno < query->first_lineno) - continue; - if (query->last_lineno && - dp->lineno > query->last_lineno) + if (!ddebug_match_desc(query, dp, valid_class)) continue; =20 nfound++; --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) (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 D93102FB0B7 for ; Tue, 18 Nov 2025 20:19:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497147; cv=none; b=MODnut+7zIj2EOOSVt+GlrwhKXgz69xMkS+vUOZDjZKoCbbQ226y+PWwgD34CIZB8qT+mIoPuro3hmRoXaIbr+j+0PGp1MBykn5BZwQfCsMT2vkkI5Eyg8jJXgGTum3UgCof++Zl+43Gyikn4sscEMCWj6EHiv2y45lbBMBveB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497147; c=relaxed/simple; bh=WJsL5+b64qEVbgIRF4xWFN8U/So/eEztAdwAUgt7q84=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PqGQggoCY0alHJf6mhttmMe7vlMx/VoM3/thlUtYzpJAfE5PdoRz7JHu9uBC3w9g+C6rwkvemEuJ5Gf/NbCCSHo0mqe1zIZznk789kQLiIv56dlDNX7HxFDnoG9keOzQ5OKHOIOdB7C0SyX3BNqHUb+WiPeGL/Gq7hnVOH7e/BE= 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=F1+ahNZY; arc=none smtp.client-ip=209.85.166.44 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="F1+ahNZY" Received: by mail-io1-f44.google.com with SMTP id ca18e2360f4ac-9486adc1aa9so235642739f.1 for ; Tue, 18 Nov 2025 12:19:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497143; x=1764101943; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gTxYU8h026vco97neRjwIFFgL6q6uUevMqp7p18zgTA=; b=F1+ahNZYNpR0PIPKskn5ZJHHP4RQpHI29wF/wXfP3Y5uAqDYwkP8z9pmouKPptOFZV TxMBl2K1JRm2HGNMJis32IZjF+5yBZ1nDS2tfZjIxL1emDXagdneHBJTmd9Mmx4xHJoz qi4iezbmZuBAvZjt9Y/EZqBBBEQ9NiTzRwuNqvfB7uO9pGzLkycYl96b13RMC1u89BoN 43pY5GD+kqGv+W9dn9reySY4x6reBF0a+ISDY6fMpV/FJ4AfXFwqNxdsrJmC87kvnRQl vGxjaBsm3k1ohEJUV7coMOGjGzgZ1qCv12s4gtph09WR35tNao7ytTSFF7oT4ThpjAJV ONKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497143; x=1764101943; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gTxYU8h026vco97neRjwIFFgL6q6uUevMqp7p18zgTA=; b=Vlxkw9qu88H7NRySrNq15e47aNOU1RVLUDT3utK3WOQ+sZJbSsiGbGqmKY/o3G9O6p WxO1LT7YJAlNir7Ph3Vj2APijSwxNkqNwkSN+MKH/21vc2roRG/tYn6CW3dbBAP4gbPf sahCC6MKAT6zx8qcaZwHgRgGKZll/U02X477ShR3SGkj5S9PporKG1l1PrH/bKi+iu6G jh3GQck9iWkXeFX4i/d+F0SfcwGOa7fxtUScbwtqjehNU5Q9A09FZ43dLroQ8uWyVcXx 7ohnWND9Ov2ZTxML9phrgjRAtP6ccGYwyLGEfBNU4xs5u2wmT/CCb1jac3YaR52rDMuN jZbg== X-Gm-Message-State: AOJu0YzFu1t/XTK4oUTozXIC2TncfHuzcs4aXEmHebXDHe3irlanmY59 hkIO1fcOHOerBecQEvUXPnd2rNCNF1juGphjfMPtHFZXD3t9y1okdiAS0g0sEjJo X-Gm-Gg: ASbGnct8JqX0guRqJqUcI9t/lrhQhHGK3dAun0TWUGjLnIHG0UCSvszXueZJI5fsITP mCuOuQKkl/lV2Me/CBgYv8esFJ/lu0d855vHdglJCE/SGEmxmT13LVKZf8+1gPOh3JKB1NhyjvE Es49kwYwCWGdom+bmkhfunrEavZsdnqMXf2vx6Ydlw44LNsXjaILVbznHCDRbwzQ5aUxi7eeMSl uiCP45MlXs0Czw7MseoG6lWFLIPM/1/cDhtQvmco6IVq8BRyBg+JnQXSuFR2X1PfiiJmRpHToUM +b2Z9Bd79vXLy61UZOQ2Q72lq3ElT8FChJCo4MsmcHE4swY/W67+pDNjPBf4flnVqhoJ0oy+SzH oLkpztDg4x/Ajb7zq9TgV/sT4G0ql/7cROwRNzXD4zlryxm10nB9R8NfiggLuj6fUn1dqil297D XviM9x7fCJgPKRCOWUiBi1HcBrPY8hQ/HMXMiW7gkPcrtxivLuLV5so6sWZNuwrFJ6L8oHlDuTl PxTPQ== X-Google-Smtp-Source: AGHT+IFcrc3OLX2ZNqj1CE9FhAt/HqPB6Gasnh7zL31ocPGJeEjq5Y3rUTCiF6HLBv1+x43fWEAwEQ== X-Received: by 2002:a05:6602:1547:b0:949:f8f:eb1d with SMTP id ca18e2360f4ac-9490f900d7cmr916184239f.7.1763497142850; Tue, 18 Nov 2025 12:19:02 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:02 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 02/31] dyndbg: add stub macro for DECLARE_DYNDBG_CLASSMAP Date: Tue, 18 Nov 2025 13:18:12 -0700 Message-ID: <20251118201842.1447666-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" Add the stub macro for !DYNAMIC_DEBUG builds, after moving the original macro-defn down under the big ifdef. Do it now so future changes have a cleaner starting point. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 43 ++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index ff44ec346162..98a36e2f94b6 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -92,27 +92,6 @@ struct ddebug_class_map { enum class_map_type map_type; }; =20 -/** - * DECLARE_DYNDBG_CLASSMAP - declare classnames known by a module - * @_var: a struct ddebug_class_map, passed to module_param_cb - * @_type: enum class_map_type, chooses bits/verbose, numeric/symbolic - * @_base: offset of 1st class-name. splits .class_id space - * @classes: class-names used to control class'd prdbgs - */ -#define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ - static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ - static struct ddebug_class_map __aligned(8) __used \ - __section("__dyndbg_classes") _var =3D { \ - .mod =3D THIS_MODULE, \ - .mod_name =3D KBUILD_MODNAME, \ - .base =3D _base, \ - .map_type =3D _maptype, \ - .length =3D NUM_TYPE_ARGS(char*, __VA_ARGS__), \ - .class_names =3D _var##_classnames, \ - } -#define NUM_TYPE_ARGS(eltype, ...) \ - (sizeof((eltype[]){__VA_ARGS__}) / sizeof(eltype)) - /* encapsulate linker provided built-in (or module) dyndbg data */ struct _ddebug_info { struct _ddebug *descs; @@ -137,6 +116,27 @@ struct ddebug_class_param { #if defined(CONFIG_DYNAMIC_DEBUG) || \ (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) =20 +/** + * DECLARE_DYNDBG_CLASSMAP - declare classnames known by a module + * @_var: a struct ddebug_class_map, passed to module_param_cb + * @_type: enum class_map_type, chooses bits/verbose, numeric/symbolic + * @_base: offset of 1st class-name. splits .class_id space + * @classes: class-names used to control class'd prdbgs + */ +#define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ + static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ + static struct ddebug_class_map __aligned(8) __used \ + __section("__dyndbg_classes") _var =3D { \ + .mod =3D THIS_MODULE, \ + .mod_name =3D KBUILD_MODNAME, \ + .base =3D _base, \ + .map_type =3D _maptype, \ + .length =3D NUM_TYPE_ARGS(char*, __VA_ARGS__), \ + .class_names =3D _var##_classnames, \ + } +#define NUM_TYPE_ARGS(eltype, ...) \ + (sizeof((eltype[]) {__VA_ARGS__}) / sizeof(eltype)) + extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); =20 @@ -303,6 +303,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, =20 #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) #define DYNAMIC_DEBUG_BRANCH(descriptor) false +#define DECLARE_DYNDBG_CLASSMAP(...) =20 #define dynamic_pr_debug(fmt, ...) \ no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.181]) (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 334D93002C5 for ; Tue, 18 Nov 2025 20:19:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497148; cv=none; b=GaO/R/ba0guuD9HvfpT74EQgGXPTviMiKkNR8sVSb/bXuH0fvfAGQKnS/4XxwhH0z5+X6/+xrb36UpZD+8Eanzafvv9W04BHH3pmTtmq3E9SgtF8AycG38eO1V11Sne67YcK4OB3ECWwUAgPJoq1TMYBLgkZGjrUlRfytxlOGWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497148; c=relaxed/simple; bh=kuUNF3eSvEmfrVRBhmQ0Md6werzhD/0OpluF0lVdCR8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M5smuAyJU9UQMW4ytFngtKMRaZObyHZpSYuDX5qhu8wxbBpocvhWQCQ/iY3bfNprGJ9OlvaVAwfjUTKtLhDQU7lcTL0ZCGCxIu9Ybhi81K1yMIeEjU9PPqPnKbvGcBF1RdK5KsGLtzVCK23GcmCqw8eYZJLQ5CFmBm/RA4B1Zao= 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=URyfLIu7; arc=none smtp.client-ip=209.85.166.181 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="URyfLIu7" Received: by mail-il1-f181.google.com with SMTP id e9e14a558f8ab-434a80e5463so9057965ab.3 for ; Tue, 18 Nov 2025 12:19:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497144; x=1764101944; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2RkJ/qsTnmYtiv2riH5BfVtIzUZjxXWOsaDgvgU+8z8=; b=URyfLIu7dFhQFDMprvjycx+nefhP72p2WcjRE9RH74BiHHEiW7RIph6BywZd0zUQ3E cNSaF5+iHM90SRKtOIwZ0kUtIes9bLdbic14l1IRgnHdwHf1pTUS3GQayli4lgox6kyL AtXgk3UFPRmniygiJoroyBHRiUaoExTO39POWCaGJ1II55g1v1bixL74ny69opCZW6Ne Zp1+6zlHmJe3P9gV7IBkU2v7PaX9HBB0qrX+Tk00o1nx2cW43WrhVvpUhzUz2BEyGXw4 B+IFt1XMdBNwxbs7XKrCOqwVRjwq05o8zYRytLcZ0gP33b5Nwsp1X0XAedpaqregnu6Z pkEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497144; x=1764101944; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2RkJ/qsTnmYtiv2riH5BfVtIzUZjxXWOsaDgvgU+8z8=; b=Nd1UioooKZVpPmijRgiZKmSAcylYwDPO8EBMzx7pBXPgg4nDYVe9Zp6qsb/VTXstRu ZTIZgQ/SA2utSFsfUrXzYcOeKLYuzJwUK7+J6WEPnnHQ+GEVhzcXkOppZfEl2zDtrDoT CBMgxf7sVtq5aOU82+1YnSEXAi8i4jVBjxATs/WrTXe6/kJ5i+DGXfoojylU8TGrd68v 24AaPpYApWwnyUbgdvmK64mUryc4vzDpTBeO4fKofwAqCp1TufL4n+Z2ChB9gN9pV5aj cF5nwGWBe5TOWgFs0me0gRPpPXr9r3w1BqXtIoWxb1ATwYvqeNd0SHuqqJHJCikNeppN ktKQ== X-Gm-Message-State: AOJu0YwbRPTynesB4wMFI297wGU8y1NPKwOf62BHD9cVLcjENjCYCe6q Z7/5df8KnqQHo72SS+0HSSGS2b5iCdlGHRlBUiNkndSuHsS9pw8CNxCRkdgQTBC8 X-Gm-Gg: ASbGnctQWEdMk0zwjYRRJx4A7YMAD/OuTzwBsqn+6qyLWEBnK00DJKsPz68j7eVorX5 EWoc7FsjM1d9dKev67Fnzfb/ecL6BHjJke10/2ldIQZfDthmfFSXs3AZouH9ubQbrMIxe4c6BhS X89dqg5wW31m14BUNQZrJW4nFhpEZWkKYn8l/qzJPKOG9Brs1wpcS+CH768USxbuPmHJ84mPjmF yL81frACtVLqTQHEgNQO1hi+3lY85xUfw51aZ8ft4++o5vo3Sh2h7VCvFbyO2h4UU+M1v/IkBzu 90RUrfTB1xIcXgxQNrNQwgEJREwfkT3az67FDvBMVs5c7y5WBciEuxfUOfxgzPkfpzRiVRihmMK fMm94623wPvIfyUcgQ1cHqRrHpFu5flUvPLMyD2YDTEChApZCNP7m+2sIanbqsNt3BOo+X/kiEq 2/Gz2hUTu1ytYLIj6cl45DMncEGk6WErxRKD9KhrUstDDLRfdf80GL/YWYTfBU9xANHVQ= X-Google-Smtp-Source: AGHT+IF9PJHPJJT08kehAt07KlJOkieQ3SWDnT+Okbr84dGUYH7BFIPznagaSGfH8TubAKv/krhMFw== X-Received: by 2002:a05:6e02:16c9:b0:433:4fa4:912e with SMTP id e9e14a558f8ab-4348c87b4b6mr178059635ab.4.1763497143803; Tue, 18 Nov 2025 12:19:03 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:03 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 03/31] docs/dyndbg: update examples \012 to \n Date: Tue, 18 Nov 2025 13:18:13 -0700 Message-ID: <20251118201842.1447666-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" commit 47ea6f99d06e ("dyndbg: use ESCAPE_SPACE for cat control") changed the control-file to display format strings with "\n" rather than "\012". Update the docs to match the new reality. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet Tested-by: Louis Chauvet --- -v2 fix missed \012's --- .../admin-guide/dynamic-debug-howto.rst | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index 7c036590cd07..4ac18c0a1d95 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -38,12 +38,12 @@ You can view the currently configured behaviour in the = *prdbg* catalog:: =20 :#> head -n7 /proc/dynamic_debug/control # filename:lineno [module]function flags format - init/main.c:1179 [main]initcall_blacklist =3D_ "blacklisting initcall %s= \012 - init/main.c:1218 [main]initcall_blacklisted =3D_ "initcall %s blackliste= d\012" - init/main.c:1424 [main]run_init_process =3D_ " with arguments:\012" - init/main.c:1426 [main]run_init_process =3D_ " %s\012" - init/main.c:1427 [main]run_init_process =3D_ " with environment:\012" - init/main.c:1429 [main]run_init_process =3D_ " %s\012" + init/main.c:1179 [main]initcall_blacklist =3D_ "blacklisting initcall %s= \n" + init/main.c:1218 [main]initcall_blacklisted =3D_ "initcall %s blackliste= d\n" + init/main.c:1424 [main]run_init_process =3D_ " with arguments:\n" + init/main.c:1426 [main]run_init_process =3D_ " %s\n" + init/main.c:1427 [main]run_init_process =3D_ " with environment:\n" + init/main.c:1429 [main]run_init_process =3D_ " %s\n" =20 The 3rd space-delimited column shows the current flags, preceded by a ``=3D`` for easy use with grep/cut. ``=3Dp`` shows enabled callsites. @@ -59,10 +59,10 @@ query/commands to the control file. Example:: =20 :#> ddcmd '-p; module main func run* +p' :#> grep =3Dp /proc/dynamic_debug/control - init/main.c:1424 [main]run_init_process =3Dp " with arguments:\012" - init/main.c:1426 [main]run_init_process =3Dp " %s\012" - init/main.c:1427 [main]run_init_process =3Dp " with environment:\012" - init/main.c:1429 [main]run_init_process =3Dp " %s\012" + init/main.c:1424 [main]run_init_process =3Dp " with arguments:\n" + init/main.c:1426 [main]run_init_process =3Dp " %s\n" + init/main.c:1427 [main]run_init_process =3Dp " with environment:\n" + init/main.c:1429 [main]run_init_process =3Dp " %s\n" =20 Error messages go to console/syslog:: =20 --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (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 EAC8D3002C6 for ; Tue, 18 Nov 2025 20:19:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497151; cv=none; b=t3zdSarzsniqYiAXp2LOapN3VLHzyl0gUn/ixtrLHmcJSkFW/Kj1CE8Y+z98syeauz+z031W47avUYSNvl9LSfIESCcscvUKvuNA8D+5L0ED2SHpVww1/T55SVBFlCKsn+anT2Nb/g7+rClm1adJFXevbuYVAi8PkkKEdBgQwXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497151; c=relaxed/simple; bh=YiavUBFlby9+q7R3jVOye6yVNiX9SzeQZ+DB+RZTe/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iagHsrBTlTMuja8VBY0WotoduOLeLH945gPvlrwuWb9pmmksl9gBWY6P3lqcjJZiJpOxLCerHpmgf0waeHM3eVcWL7bUKbMRqg/KFcTikHHlH/VLuNJDFcQTObt5w8JpQg9+/4x84CsUNa/dVzo0/pRsVwnEEGFSOr5U0BJbhKM= 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=iKW4jfDa; arc=none smtp.client-ip=209.85.166.45 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="iKW4jfDa" Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-88703c873d5so216686539f.3 for ; Tue, 18 Nov 2025 12:19:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497145; x=1764101945; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LLlQvuuD9MiSXKGka7d4IYEwieMdPmkGOdzcDHTOiMk=; b=iKW4jfDaJowZKfuyuNxHJ4us1Cwfy+9jnmit3sOgYDqRdlKlILwGQNBmgy7vJDLEd/ y/Id8FL8VtuBvth+7BpyXX9vaNms4+xPRG2ubFFA34bdiYyWYt/v79bMAqGEau3172NU 1TpAhpJjc7Kxl0u/5PJk1VQLH9dUPrr/FH3FAVllw4V5YIugHXjJ5/zWmUKDC8hnDJyQ zWtAfDOtn+zsjU2zNej1mFNqb1TZcDpCXN35MjECtJqyT1Xma+xzvENkQU1Ur39tDbZL tLtzywLnxHF+O3hoyhmU2fVcW7v6nX5Lev+hC6mr+tqtNnE4+bIZJmXnM64hq42qpHqj GnEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497145; x=1764101945; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=LLlQvuuD9MiSXKGka7d4IYEwieMdPmkGOdzcDHTOiMk=; b=vpSYuAtcH1d+hUysazKepKU+ZTsS3NnWxEn5VVVaAfzXwFOIrHz/ynyNJwGUZgK26z zkyaYmeIfG6RMAzE2yW7oDyUcx/xzfVLq90L3uP9uEQqE/YVv6J35TRNsumQxo/7fKfi cZ0w+jPlfwRR9uQm7TXnGsfy/9BxfpGL4xnHR17nyRv06KZzMX39YwwitAol13PgbWgq zajlIfdyJ2gtG6ptqhukOKf867sFM3xWSE4pymtmeOxe4bIvAh14JD3PjWjjspm8RSjb zXd9e3qzQIyYCs6Q3JV+qFxL20eiZ1HEjNdIJHwCVMDx6idm4yXekWOAbZVbcGJgw9ky t5jw== X-Gm-Message-State: AOJu0YzqwO4V0CFQlIc3GcUBo1drl4Ij6eJtqeQ1UCRaKXXqJgDs9ZVb JcyXx37FWbvhz6galTfjNidpCjGHmEJjntx3akf9tTd2OJozNq1+Wx5lYdco6tfz X-Gm-Gg: ASbGncvWPxhlwGA++55aGl10rKmOhPs6oXA/b6OQWmQ3IqmqyDxY/ZYvpbeU0xHK0j4 adoqk9sMQ7hi4qwIx+OZRyI2zfoavuhUxoBZIwUpEGhCE7JhWGQ0FzPDSzTHwPXkJLhrF60icB/ RJEGFCaGZN5NBt0lRKn3+wIAc+qaklnwLxn6Jbk1RZsEcAXtibu7q9K4jm1kgV5N4LVnxqu5jT7 kaEEjyz4kScq2Ews+jPglgMk5kUzcknhOmmUDSXS5p0ZvcfCgFCseWI2qtrgLdMiuN//Kg4F64Z n5nYab5OEGxDd5pf5bMnb/lvTwc0sfzwxfOJwcxe5IlKx7+KsDDc6ZD1MnkehFmvY9vaJznD0S5 Rz71zyH1zRKzYgr86GAa9UvtOKszsXRQOylBDP3TpPFK5fDopLwHSVsOi5I2U29ZyFot2eEq8tT AvKnaTGMpHgpbXIzt6eXXEHmgo2Mdie8dpm0uqCHPljMlrrlyGcgMShH/GNcg57kfABxs= X-Google-Smtp-Source: AGHT+IEIscdoyaRBlf+VL0JUqG2kMnrPA8EkFzQ/Jz5eax8vm0Cs6+BH6q+0DbWPfuhn3YzO7H5xxQ== X-Received: by 2002:a05:6602:1587:b0:92f:20b8:7e22 with SMTP id ca18e2360f4ac-948e0de1a6bmr2212655939f.18.1763497144913; Tue, 18 Nov 2025 12:19:04 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:04 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v6 04/31] docs/dyndbg: explain flags parse 1st Date: Tue, 18 Nov 2025 13:18:14 -0700 Message-ID: <20251118201842.1447666-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" When writing queries to >control, flags are parsed 1st, since they are the only required field, and they require specific compositions. So if the flags draw an error (on those specifics), then keyword errors aren't reported. This can be mildly confusing/annoying, so explain it instead. cc: linux-doc@vger.kernel.org Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- Documentation/admin-guide/dynamic-debug-howto.rst | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index 4ac18c0a1d95..63a511f2337b 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -109,9 +109,18 @@ The match-spec's select *prdbgs* from the catalog, upo= n which to apply the flags-spec, all constraints are ANDed together. An absent keyword is the same as keyword "*". =20 - -A match specification is a keyword, which selects the attribute of -the callsite to be compared, and a value to compare against. Possible +Note: because the match-spec can be empty, the flags are checked 1st, +then the pairs of keyword values. Flag errs will hide keyword errs: + + bash-5.2# ddcmd mod bar +foo + dyndbg: read 13 bytes from userspace + dyndbg: query 0: "mod bar +foo" mod:* + dyndbg: unknown flag 'o' + dyndbg: flags parse failed + dyndbg: processed 1 queries, with 0 matches, 1 errs + +So a match-spec is a keyword, which selects the attribute of the +callsite to be compared, and a value to compare against. Possible keywords are::: =20 match-spec ::=3D 'func' string | --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) (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 2AC902FF675 for ; Tue, 18 Nov 2025 20:19:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497149; cv=none; b=VgR89ipFEY2iRSNLdFpxvyh/aQtyGuzUoKc0zkrBC3sBdnkfMVnFicUrPgpo3TNb29IiKXNYGMlWK4NEdXZ0CWEwDAVXHBiMTcCn6hrhmeXwnqkBetQUpQjs/JXJeQeyh2yOz9J0dOX02HBCxuGtrsMLw0gt68Hv3QiRFhOZynE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497149; c=relaxed/simple; bh=I86IN0R0mlJk8zC86TVE9uRMJ2CixdfNS0QU5IAyqts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gT6gUDSdZB8SJTl0XXbaT/Ooh4wNBAg8PjS/ZxqyJTfrfZNWB6AQEkGZPeOuMfBLkj/ncppb+LlkeRKjME2c0QuOurj2FDxXGIXLmo1WZ3p4wsCpTIVabKhOHxXwdYU185wEP/31QhVzxbjNRDQ1tSeB/q6pTdPtOL5yc8t69Ck= 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=V6AL6ChW; arc=none smtp.client-ip=209.85.166.41 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="V6AL6ChW" Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-9490c862fcbso97024239f.2 for ; Tue, 18 Nov 2025 12:19:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497146; x=1764101946; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f30WX50HH1DSukzL5DV01QGs8uLxWoJEOO6kqzlIEss=; b=V6AL6ChWJxSX1sADwAENKVK0zWaJZ+fyP0n0bWu2XLK/+jfruMq9WJCn5t6wxKieR/ OgXPKLhuIfJqjxWLkiCHFuYn+0wQRmu7RmPH0xd/Ap82IJRmk7nrgFJwvGTm2PQzNAYV pD18Dx0QafsA7QkYSHh8EqyyOSXBJPGehFschyLOHYSirTOhIHoPWVm30udxf+cVN+CU ROtCqQGiH//QTkSpQeIHkQ2KI5WLtS2vxRPJ7rCFKQYUgiwAh+jscp/MzaKLyh7++TRp 1c9cpV6FSB89qGv+48g5DMUkykID9CKyxMGHTLMJnsZMx3EDJ8r49gSvaDBLd1275KIi nw/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497146; x=1764101946; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=f30WX50HH1DSukzL5DV01QGs8uLxWoJEOO6kqzlIEss=; b=kF4yFJnyx8E6M+XLCK8EzkK4Ytq9uUGxbiewwx8yh0d9rrB4K+GjJxuLZFhoUlRSRP zVuUQrAk4Zsm6WL4l35+GvqKc0nLZWLwcZD+WRi0DYt2TX2VkZmAFD914Ywh2bwd94b4 4ygG9euvM4hH3n/DfVO7z0H4m4ixalz9xblg+evsr81E0YxD+uAhQQPeamJtoldrZx5k UrsBy49JBotq3Vxiqp4LhCRmgdDB/CmOZQEX3Z1o8P84pQQm4DTBmT89CBdR3tpk0U6T hKxrALSfvaUSpHv4X9brTnjCBpFtqt3u9Vy8qJlvDwSIReOQ0WU1TAec5QkNNU/x5S4N xwNw== X-Gm-Message-State: AOJu0Yy6fU2+Ls29k7QcEEVn/WwB8sJOLm6cKwMMCV4rbkrLLqg7EX/k Kn+OJXaIuf2uLCoCzN8Kj6YJmeFsDfHqxXrLfMtcUP0+g1VEobK7oKRjpXN+olYQ X-Gm-Gg: ASbGncsvBUOAp04+WeceAf1APA/8Nd3lV35CtOpuP5gQ0wVGcxUYDcWETxUvg60JSV3 cqeGc1qunEiwn/ZYY5W8y7j5gXY4Lxxmjy0GYKfJKyFVcLNqV9YCeBV247JUkXYZufHYB2Xkyjr um7mOxssjII6eYATYOGoWZN2QuHM2YzD5VpbF2EYDBviOCkoC9dXe9m3Iz11dFOZholuF3ohxqN xSR3EPYwWUuQYrknu9X9qFRHMpxrHBka3QHYa/bVFhjpwkeRWDH5ePARGJUxbVozcMzJTtdUK0M kn42kq6G0UJwdeqW0aGYBaE4azP4cUyH0RdVsUOJDkwSQWva4+Ivt8mkrKcDo721qXSScxHKQxc MHVBMvIGPwNhUh7ItTaqMqFKR1Cdi5blvjXrXGCd6KjUB5AmZmfBMovVENOBjW1gNRV1C/0B6KI dnufdlZOfr2UmmU+a0OGQ5xHw6b55r15zOSOfQyPysSQdIZBr7OVLEysnvW5l4Ufb1LDtgNfrlp VXW6w== X-Google-Smtp-Source: AGHT+IGCDomvmAK1QHEuZDft8S0sX/cmV3Cl8PE9rGTZLGnk4HKbc66rQv+BZepXiLczY7V4uTD7vA== X-Received: by 2002:a05:6602:3fcd:b0:948:89f2:ea34 with SMTP id ca18e2360f4ac-948e0cff685mr2159542539f.5.1763497145967; Tue, 18 Nov 2025 12:19:05 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:05 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 05/31] test-dyndbg: fixup CLASSMAP usage error Date: Tue, 18 Nov 2025 13:18:15 -0700 Message-ID: <20251118201842.1447666-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" commit 6ea3bf466ac6 ("dyndbg: test DECLARE_DYNDBG_CLASSMAP, sysfs nodes") A closer look at test_dynamic_debug.ko logging output reveals a macro usage error: lib/test_dynamic_debug.c:105 [test_dynamic_debug]do_cats =3Dp "LOW msg\n" c= lass:MID lib/test_dynamic_debug.c:106 [test_dynamic_debug]do_cats =3Dp "MID msg\n" c= lass:HI lib/test_dynamic_debug.c:107 [test_dynamic_debug]do_cats =3D_ "HI msg\n" cl= ass unknown, _id:13 107 says: HI is unknown, and 105,106 have a LOW/MID and MID/HI skew. DECLARE_DYNDBG_CLASSMAP() _base arg must equal the enum's 1st value, in this case it was _base + 1. This leaves HI class un-selectable. NB: the macro could better validate its arguments. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet Tested-by: Louis Chauvet --- lib/test_dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 77c2a669b6af..396144cf351b 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -75,7 +75,7 @@ DD_SYS_WRAP(disjoint_bits, p); DD_SYS_WRAP(disjoint_bits, T); =20 /* symbolic input, independent bits */ -enum cat_disjoint_names { LOW =3D 11, MID, HI }; +enum cat_disjoint_names { LOW =3D 10, MID, HI }; DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, = 10, "LOW", "MID", "HI"); DD_SYS_WRAP(disjoint_names, p); --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) (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 953632FC029 for ; Tue, 18 Nov 2025 20:19:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497151; cv=none; b=HDYPGlJAGRRcDkrBBvCwBgi1mcQ9s19wQR6/zHo5ORbZrqZjpaywmFOrA1Bf5Oy/AhSt8BM6CvS8OQmm55WtHlluQwNcYfZP40wW7nTsWyG75wO4w90ZdxYWznboqs/p8QJDaeu5fynZEZpdf7hc6CMIdQUhSa10BcexvL6j6ck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497151; c=relaxed/simple; bh=r3LliYmjOXBXLS44PuDMjOXq9WlJVufcK9lPXeSn/xw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YBCd80NFcp94IilCH9LMhxG3pJkqK4WbZyOiuj9UDIVEDcsgltxgxhMr+fl39gG2SaP8Cmc77oU706bRurttrfk9lI/c7fr2QUFI4AcM+Br/RIyV1Y1fWNS+l5pN/2m+WHBAcgcftXhV4RBH1EwShjBDHh1TP+wB63dxtrXmDiI= 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=XpaEjdfN; arc=none smtp.client-ip=209.85.166.47 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="XpaEjdfN" Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-949033fb2a9so118085839f.2 for ; Tue, 18 Nov 2025 12:19:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497147; x=1764101947; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X8Z5E1c4xW6f3MIhZNpeEMkA/pwyFDqpSOaofHjCxO0=; b=XpaEjdfN5P4xopE+TmGuDeSebIvvTll5R+zTOh6qT0uQu4aHwS0oCy+lKOH11XMl/1 UZXXZ1YMJcBC+y5RxRS925UpVcLlt0fIcVPOyb8iGynl0TTP+2JTkVvyonwf+2CSiOdH kwd2WDeHzlk6Rx+i3CoAjGIj49TSGwRk7iUKqYvTTfLoVoL3bWZCJMZ+uGn1rcbB7BFM tATHWm0thfYBaF+SdT9rTnSUZP+KxCeScssEkdcGkZi/7ZEQ2lAehXf9xJ7DdVUVM93N H5I+fI6gaKwWxeNpSjmfyH56zjDcVaOh8sCLeL6IuQMAO719pOcoHFMOCg07VLzEMRhC 04ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497147; x=1764101947; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=X8Z5E1c4xW6f3MIhZNpeEMkA/pwyFDqpSOaofHjCxO0=; b=orGSvGrj5FWUKFfKm8TWc1jDz4X6pRz8EEEMfC6pzAx74XaATmqa999/W2oMj7Dkpd p/PP6JJuD6HBl3VmxoQ84v8XabA/Eb0LUJBDMgztOjhw7WEyMMNLfghJIN5q892RgwuI +w1hvYg/v1bMRTq//+Z2QeAvdRI+FTcumxYqJenlzfB0n257g0/3yUs8JDyBGWhZdebY JkrnEyJ2h8CiSipLPOIor97kUPWWcgFgnAqXtnrZq9YXK4RA8Zvpbf4wBTSemnUwMZ/P KGDcjgkx4Fod6AfR9nX8SV1IfFYDp+5U0AFU6qJBffwnas921c74kkJ9tuF11eeStdtD 9Q/w== X-Gm-Message-State: AOJu0YwCMk7q491IGeX6UXzOy1qAKGnfgs90j4KrNubD+wBo0XRpaQiS CSbDFYwkxKCYLH8L++9ZuVODk34RLeiOfMp3BD1VS2PoUiHKZuJiI0ZO2bLJhOUy X-Gm-Gg: ASbGncuti8cGwZiGw2qaKZ8jPOs2lcNaEegqeW0x7zhqegCN1WrCBHkcCHKtP6cfj2O beb8ro+JDAlJ4rS6JxBpcxm829r+RKyrKamvf3n2GeFsAVinOcaCNGGk4+tb18nRgE8sChF88hU Iex4lHq8paTTw6fSuAaKWywHutq7rsEPAAYDpIihWwrMe8vYG12yywphnN4x7FgTwc1COh9a6LQ dGOKC906xMmnTBrKJHS59uwoJvaEyYewcwoUabuNQGlDSpnNi/FC8sgtFAsmyDRfUtFQFRnoQjQ 9iK4/Wxmx7QV0pBWDtz2uKOuhlmPBs0hIDbvd4nYjszzolYv0oMhTLakC0eTdXCP6sNULM/WJwv IUtW5a2P2DQweVdbK17Sw8EHSLmRtaIp+b1/hArC2nnzEt6RRep+apzazOnrI8ZFPeFjlSGb1UI LWycvUApKtGq26rwQhAU+oXWkMeKeZRZ37p4uh1zunTu5gt9AfiYl3LvICKDMQ2Mzn6uhYvEVvj YiXBw== X-Google-Smtp-Source: AGHT+IGK4KGIUTf4W77J7sq9n5vXqukmUNoZUaDS2Y7hGtS6m3I1J/vwD+lcc8EF3iCZoSjToqUTEA== X-Received: by 2002:a05:6602:600f:b0:948:c594:9a06 with SMTP id ca18e2360f4ac-948e0d782a7mr1965215039f.12.1763497147373; Tue, 18 Nov 2025 12:19:07 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:06 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 06/31] dyndbg: reword "class unknown," to "class:_UNKNOWN_" Date: Tue, 18 Nov 2025 13:18:16 -0700 Message-ID: <20251118201842.1447666-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" When a dyndbg classname is unknown to a kernel module (as before previous patch), the callsite is un-addressable via >control queries. The control-file displays this condition as "class unknown," currently. That spelling is sub-optimal/too-generic, so change it to "class:_UNKNOWN_" to loudly announce the erroneous situation, and to make it uniquely greppable. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index eb5146bcfaca..cb171088850c 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1165,7 +1165,7 @@ static int ddebug_proc_show(struct seq_file *m, void = *p) if (class) seq_printf(m, " class:%s", class); else - seq_printf(m, " class unknown, _id:%d", dp->class_id); + seq_printf(m, " class:_UNKNOWN_ _id:%d", dp->class_id); } seq_putc(m, '\n'); =20 --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) (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 9513532ED2C for ; Tue, 18 Nov 2025 20:19:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497152; cv=none; b=iXWjgClI/dosOwH4ivZgxXKSVzNFQv7IgpogQb7wuNqh8Z9nvX5UQpuWGeyd9/sglBG6irYwB9srE0ATVBqT35dGH8PvOBGxTtaTf/nj7gRuHK7OaBCs5TBDQKgOAysGzlmbtIouKLB558QSstkrWcH4rWwr9q+avmczFCOIZ/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497152; c=relaxed/simple; bh=GxSXQ2amDOG4FkT5XNtoxuLSkWQE6mQ+WPifrmssYic=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EQ7LmY6CEiqWFeVO7ZlnPqEvwHxYNejU5W1Idkly2HpsM0LN26cptT3V25nvE+u6NGCWjpl/Y6HtHgVq2oqt4wLilLdC/duRUz4PZyv/hnGDk1NQ47PZLVxn2r8lzLnpu71DyMaMD4Ar53vBOzsz6VQsCxjX8JF0AaBY+ueVx7A= 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=VAfUwXq5; arc=none smtp.client-ip=209.85.166.47 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="VAfUwXq5" Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-949031532f9so8518339f.0 for ; Tue, 18 Nov 2025 12:19:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497148; x=1764101948; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M25T8tvP10BpQGqTu5Zj5kHgkTLLNAK2ADT59hdkhbg=; b=VAfUwXq5B/VTdLI1ZPVRcSFBfIUnYKvpSeNpdbn4Ug9vvPdVkZFiSM0OayYmuStUSr UjvoWFNWpmvxxStJxUarOeZ23eHIfoa+lnNp65Z6ZG/b7eliXZmZsHW0AnBLvoterLmh JCUBdIZWfBsOKXabMLv68FXEGyaFquU4Xhzn+1O3rusJihWPbJ6OPWGFRkVN7ARDfb4z wzYPzqpm3JKvnBn94PkEPg9ErrQ3hko80gntkO0xfst06Q+0W4AfDoHN34HJq0peJXbd 7qo/u84QLei2yccYeDWuv+ebnaNvc8RgfynZ78YT5D4B/EBUr9/DvJkjkQa34n+IwJiL //OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497148; x=1764101948; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=M25T8tvP10BpQGqTu5Zj5kHgkTLLNAK2ADT59hdkhbg=; b=DbBwOOPengbvqFLogwDBOEjIqUMvJCSvlbE6aG0hqyx7DLl6SAaMqXvSL6bcmdy32b Y432vxVGUo20sWhq0uAyM7IFy1/mF3IvWH0CuV69fvj9Zec6ryb8y0gsUSp3pDmxCkeh Qo1mruihrSzJYIx1m4bL9g328CzTjk+sEH77U1G4EHSYm4k6bFKtAhTSkqFwOW+0kbJ8 GamUl1giGcO4OiQ9VZODAORr/v41Q1fSd3g5AkstbYm/80y3Xj6TZ0hZob9yNqiEbQwq J/vfkSZX0XVs5IZ9f68bQPgu28+Tt9GTeZWM+3RW5azxYD/V7GS3lG2AlXMAPTIJZFsU Xq7Q== X-Gm-Message-State: AOJu0YzJekJMD/RoAwMy22jQBLQ/8i0Y+b840Yvfy5mtmd6IctKBWTpu IMNdWm9sMdhwtb8wnu07GMGD2KAt0zf5Li90EOWrhRyP+bnkWjAU2pESJJM63Gri X-Gm-Gg: ASbGncs6vnraJkTLEDqvUMGksspAQGLPm6aDXsGFAm8x7gLrOhe8ztVnsTRP1JPY+GS cqQWG+f0Oa+2K6vu51cSGK35NJOXMcB5uQi+y4cXv/nve7I6V/ZdwsYuIT3OMwzAlSgmZCzNLcw I/eDQHfD6tb+XJNqjstgh74uhYCvwzLFyOXDJmpgZhAKcNhfHcQ6f5oP8V8mGaWE3HEXLK4XcH4 7BjUiwU/ZrjZNMtTB+WWwk/SuLP9pmzyaIUny7ybQZTPzOvQLmQ6er0x3JDxF2aoYbaOQ99+rDi 69MRJduhYXzyBqJEfH5k3sWiGNLZEttoGfSPzeProIzZ4QyOtIgMQ7Ew9HR2LgfnqeCL8KSebAC TdAp4bFzPlzjH3Ov+rw0SOCTDO6h9yKOpnlEmEwQAjVDuDESrG+/+poi93qKOps32kOzJCiT4m/ HTzWAohM93NVG5zQy8pbRzz+gaaX3/nyrn7AJtdC+wlesVc3W5pSK0Aev/b6MshQw5C24= X-Google-Smtp-Source: AGHT+IGW4D0lXSlWs3TmDsGRLwaEvoluKtRmCX47T4Nwd4L5+oUFwNMTUyue7S+to7ix3wowc8R8jQ== X-Received: by 2002:a05:6602:2ccb:b0:948:7255:e2b5 with SMTP id ca18e2360f4ac-9492b85c431mr17183639f.4.1763497148452; Tue, 18 Nov 2025 12:19:08 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:07 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 07/31] dyndbg: make ddebug_class_param union members same size Date: Tue, 18 Nov 2025 13:18:17 -0700 Message-ID: <20251118201842.1447666-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" struct ddebug_class_param keeps a ref to the state-storage of the param; make both class-types use the same unsigned long storage type. ISTM this is simpler and safer; it avoids an irrelevant difference, and if 2 users somehow get class-type mixed up (or refer to the wrong union member), at least they will both see the same value. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- include/linux/dynamic_debug.h | 2 +- lib/dynamic_debug.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 98a36e2f94b6..4b7c3b997657 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -103,7 +103,7 @@ struct _ddebug_info { struct ddebug_class_param { union { unsigned long *bits; - unsigned int *lvl; + unsigned long *lvl; }; char flags[8]; const struct ddebug_class_map *map; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index cb171088850c..d2ff203d0873 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -810,7 +810,7 @@ int param_get_dyndbg_classes(char *buffer, const struct= kernel_param *kp) =20 case DD_CLASS_TYPE_LEVEL_NAMES: case DD_CLASS_TYPE_LEVEL_NUM: - return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl); + return scnprintf(buffer, PAGE_SIZE, "%ld\n", *dcp->lvl); default: return -1; } --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (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 CD00F2FD68D for ; Tue, 18 Nov 2025 20:19:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497153; cv=none; b=ElOSK7jO3yEi84hSL16oixmwYvW1ZrAxNfmNNjyNCa1qPDVHruAd8oMFEGGT8PORG5x2UK5L1gLXZjFgui0icNCOkZOTySwoGH+8GJhPcEJXEekPZMMqVDwXbr0Ug1ixTsqsDB6p5i+/K3m64RZPHWe9cP0dooUCJRIb+6/e0tE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497153; c=relaxed/simple; bh=wp81AmDHzf+j9BrJN+H6daClfnYHY62n1mDBpARp7xA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VUJ5RguQxqvDAXaSuAx0vwgBDO6H+5BdEi33f7G6VFM7kPcsjM06dajxkkLRk0/7MoJ54n39MV1sF/VdIR6WRX4SB15Fh3C4TqcQhiX4ocLfJhTC8jyQPr4ydmslCkZ1S8F0JrtmJ5CmuYbM8e22jLk5v8T9rggPfwM5Gc1EKTg= 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=QdvbzHaK; arc=none smtp.client-ip=209.85.166.45 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="QdvbzHaK" Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-9490c3ac6ebso74890939f.2 for ; Tue, 18 Nov 2025 12:19:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497149; x=1764101949; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q0LcLub/aNYx45CBVmAA9eCl59aPuMQxX3ceh0vpFBA=; b=QdvbzHaKqaYZ5OIljRlVs+puybFW3S0S2EIvFMRhKe6iQbVWUha0nJlC4U6txjL62p zGBVQibKobDNqDLFNSd3iFubZAXGJxSSMc2k08I7VRVpdDKI5XVscGg+K7k4l8YRiI1q HXN/Ifcqe18VOFWnXi473zS5pYqy6S3oCMk5j3xj9AYPrZhBE1t74e59xP4XHr+1vWkq Fs1RBUchP//WciMffISR4IE9yvFAHy+sJ1YtjOPaWdusZmMbvZ4akQv1crcAIP752jQA 4gHUOl78A1t8tTibCA852wQ9RefB4RMPKsaInhpqSaB2GTCMh1QDV7RZ08lw2oQRzRjK 3HCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497149; x=1764101949; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=q0LcLub/aNYx45CBVmAA9eCl59aPuMQxX3ceh0vpFBA=; b=HwlIOdCds4RW0NFErywd0mUYau2/1I10SClxmbucs9hXwShtO+7L0tZVLPET1sFfGM rYMyn5zrJNpJI0TqVkqF158kc25iwlog7bMvpz/CnMjNmcBb12ZGead6ojkd5OUOaqFI R5Xx1SYovRb/BskRCrlG03OLYsXbgjMSN/W7TdjyKIlchhLgpY+wVkQUbluahVCqzGAg nBq7gfCU2mgD6aOZ94kREd25Np3+sDEzKO1qw7cVgthbkJOG4etJzaDDXPhClY9CUVWM oQxqyxqHhLQactzgV60l6K5075nEMWyoEMKR7ypx1+VMWM1A+NA3aWCOsG6oPDkmGnm4 bJxA== X-Gm-Message-State: AOJu0YzZvQ0o/sfq7fKQLm+Hhnsf54Nkz/zKj0nxVKvSs/xnPAbdw6l+ A5J40HsP8SWv4XsbmVV5mUd6B1iW7dEloqRLMi63civkCq9WTA+EoBqbkv83wSM8 X-Gm-Gg: ASbGncvHiM7iW3OcO1MOa/4yQYPwR2D3rjWBDNsQdxDfiM1J+LBAwqiEGLgqq2xX0tv 6ZefsaO+kN8ePU5RngS0dOiH50xRC99mIH9HBWBBvSzauwTjOTIbEuUvxSbrZAzKVsX3tsHAB+2 OmtgnA1XzI5Ewlf0KD0OtM83hhC4kwR8ebjxg8Glla8dE2VO8tGs/HjP9bywY/xrRptFXIux4ZQ qryD0zoHbG+vCAegHfgwXhuXwVmM6G407GHrfrs2mfZFMfBuSmi8Fu+r3VTulAJfVIHs7xl2Cqc DOQGnKkY2zVvUtxsMh3O2yD0cknlKsLEy8dm8lKnizNLgN+L1N64D27Vpt+/RWiuhhpP1M13cSC RKGGMBTwmpashKmXlaaGb9Ime0Ej/J3CM/MnUJvJGI/yS0P7dCvsM2gkglkxW7IFrvrJd8GYoBC 95i2WfYCucT5ri0aSMYv49bAbbQsq00tiu09lqG0Tk8Avrbhfn/DEhCQMOnr03vSPbWyU= X-Google-Smtp-Source: AGHT+IEdSCO1+n7RvJ1rZQQI1aUqPH/UMwfsqXn2Qmo68hCkIP4iTRfzfxbS0/RNj2ZoOT86zHegZg== X-Received: by 2002:a05:6602:2d8c:b0:948:a2aa:edc8 with SMTP id ca18e2360f4ac-948e0d43f0cmr2217407739f.4.1763497149524; Tue, 18 Nov 2025 12:19:09 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:09 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 08/31] dyndbg: drop NUM_TYPE_ARRAY Date: Tue, 18 Nov 2025 13:18:18 -0700 Message-ID: <20251118201842.1447666-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" ARRAY_SIZE works here, since array decl is complete. no functional change Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- include/linux/dynamic_debug.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 4b7c3b997657..c4ae79f934d9 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -131,11 +131,9 @@ struct ddebug_class_param { .mod_name =3D KBUILD_MODNAME, \ .base =3D _base, \ .map_type =3D _maptype, \ - .length =3D NUM_TYPE_ARGS(char*, __VA_ARGS__), \ + .length =3D ARRAY_SIZE(_var##_classnames), \ .class_names =3D _var##_classnames, \ } -#define NUM_TYPE_ARGS(eltype, ...) \ - (sizeof((eltype[]) {__VA_ARGS__}) / sizeof(eltype)) =20 extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) (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 A78393587D5 for ; Tue, 18 Nov 2025 20:19:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497155; cv=none; b=AnHy0XwWTukm1Pzx7z6Gnvd0mmhCHjrl1ga2INsLkjM22W9qIFTWiYQLDhgD7scGZ5YTd6F2w7M6DPEWxvur4j6VwozZjrk3bBVdsDSX/1ElklpS/AVn5Hm3NdLS3z1fE3MrZMuQlCJxOiViYUrrRsQOMS5yHjwsquM1fn2drn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497155; c=relaxed/simple; bh=mz27m/YIyyCsxhsIjPqOgljQYQvrBT/0evzQVypZoWc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bAv94dKij2wWpR4DDpj1JWfpf7In/EAkKfkvClqF2ecNkkKuFOFhBlDGccH0V+lqgIl5jakDoRlVb5bbB4gqY4TTsqekmEVlHGfrCMfLQADp6pMkHz8u2bd0GiUHuFqxSGjbn+HPsR4rKLwTKvtLiIhyUvDpcQoSlgg9aBJauMM= 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=gxSsZUft; arc=none smtp.client-ip=209.85.166.44 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="gxSsZUft" Received: by mail-io1-f44.google.com with SMTP id ca18e2360f4ac-94880a46f3fso190305239f.2 for ; Tue, 18 Nov 2025 12:19:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497150; x=1764101950; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4afc/l7ZL2LBNmErPEN2OigdP0Sw4I667Xea7+C9EDA=; b=gxSsZUftx+2TxL8A+I63x42wVibCcc4/e1UXCRL2gk0W+iTgNMjxmUA4SQk/aiMehV 32l7QmG/Yyp2gz3owGBXAQlRjB/GkOdQDBFULObw3EidDzxnXbARRtsB8cRt3ZR4hG+S /f8zk7u03GQEpW0IQx3Xt84pU1LkfzmrAAAgmfHjWXD2O3V9vAR58bUG1joDADJWQbAw s3EzVYfBZnqwpaOcLn5hP2owMyE0nJnLNKjwAWMmH33VGbuTAwppJKa6+0h8zHQT7nDI ktQNVKIkPI0hb48Y+10ikQu7BbE/C4T9FxU9GGDN3rZnIFfSW+YKSYveJ1SU7aY+Hkcs u3lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497150; x=1764101950; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=4afc/l7ZL2LBNmErPEN2OigdP0Sw4I667Xea7+C9EDA=; b=blXRt8xlZadOlVQ6jHWWypY+F6Nj+TSgdVQS6BA2SiPmnnhUV/GbYyJ2tsPaTRtsjt OkvdlrGHLLlK0fSKQrf514gTaDFqsD3zpUroqz1EBqJbI2PqgY0u2MsYTH7ujuce2LpN MC9wmvUiXchEHZObHzjXjnbRVThT1TiWPJRw/n4gPg16nGSQIhcAYjLyvbOLKfKRS43D lQzKLFHQ6OpHW8uW91BBUAGSKs0CybvvtjJouG1HS6sk1HOnZ4ZrOjyXGwE7kENXT76C EyDytu+ELdfuWGJGBuip9BXit+yntDMgG8f0vpwtRz92AAp2CQ5RodlPwxoKmDGmeoOQ J0tA== X-Gm-Message-State: AOJu0Yyhd8Ib07M7YHZqvJxRgnX4oxai7MRAWytOSGAUghQ6os1g+iWa UdQBKqY3byKmiearXB2UqfgxabuXPO75S7+4IklpDWpFjILfkWf8fYgIuYwSsuMQ X-Gm-Gg: ASbGncu9yb2WoO7OVQp+9NuKI3d/JB/RaPCf5bCykI6hO0yBk9W91rM0YDgR46ATR9i hHpjFnSCutnyb7EyY1W+6V0CRRslx3DxY+dwHZ/B6sKgApiQSfYuVUM2Sqc5PcH5aG3RCmmh8Z4 V0+m9Uf38aYjRrKMn0SioXsZlyqmZa4s4d8OIC7BmZtaw9pu+UwLlLm015sx2KqWiMbSq80YZBI okZOeSMkfDD36xuxpSwZHVg24NEWJxAwSLp+NsjVbJ84I09a29z8xP8LwzuinSVI0WRYhviwWeJ UVedFLfFQMb92fs5Th7FlNbfeLdyQBCDr+hHvZzo1ROM8R9dWBiVlOq8WJzHTjiw8Oyaa/JpYZm e9H/sTUj2Haf/pSFXn8+nuUz4tKb9NOubPBko8jnB4A5xIqksRR7DgdbGRvB77k1XxMmI+N/BYt pE4ZkP2gP/Mec/i7UisYNMURN3XI2tU86qEgj609e7uvRH2sa8mkDr2KxrPgq078dXSAQ= X-Google-Smtp-Source: AGHT+IH3Ve8rrcRMGDLE8gCfe7PvQeNj002rNmbx8Fly9yuAypwNlp2pxF2aoKhPM6TjRphQeqgWdA== X-Received: by 2002:a05:6602:486:b0:945:a7ce:646c with SMTP id ca18e2360f4ac-948e0d640camr1939043639f.10.1763497150587; Tue, 18 Nov 2025 12:19:10 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:10 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 09/31] dyndbg: tweak pr_fmt to avoid expansion conflicts Date: Tue, 18 Nov 2025 13:18:19 -0700 Message-ID: <20251118201842.1447666-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" Disambiguate pr_fmt(fmt) arg, by changing it to _FMT_, to avoid naming confusion with many later macros also using that argname. no functional change Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index d2ff203d0873..21c1db7e8705 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -11,7 +11,7 @@ * Copyright (C) 2013 Du, Changbin */ =20 -#define pr_fmt(fmt) "dyndbg: " fmt +#define pr_fmt(_FMT_) "dyndbg: " _FMT_ =20 #include #include --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) (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 C9054354ADB for ; Tue, 18 Nov 2025 20:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497154; cv=none; b=e8Rt3dHYSgybwvYGNjlpeoSiZZJ0bGybEiYQnbWqS/LPWtN72AoMOAJ2Fk5d82R3jpW/D16NYOz4dkniObZ1uN+QlrDvgJjptMH2mVIJVpNX31M4qjje52+Jd+zm3CmQXJlBHCPfAP3gIqFwWQ/kT2+3PRD8ZsfQEphthEHKN6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497154; c=relaxed/simple; bh=IKKkKAyatfB9M+fl1u2RpSwZxVl5vqsyH+by9N75zYw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LuPHOcHkiREg3rxUFxwQ03HAm7xwVSFQrfBjnhML9HxTptJpKJBRSyWJKjIUHrcN7QPjTHdZKl/svDxN7Y7JY2g7IA2fPNjyZXiRm4WZH7nNtrxxGuE76EUqPyOj3Wp/Zc69Cg7WjUFkhEu/vQEuWgbgU7JJHALZkpVcsgJi8yw= 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=Q78W13Cr; arc=none smtp.client-ip=209.85.166.47 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="Q78W13Cr" Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-88703c873d5so216691339f.3 for ; Tue, 18 Nov 2025 12:19:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497152; x=1764101952; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HugTGWvRZIP85YVvSycVedsiX938Xu07Q7rlJ5dV9Ug=; b=Q78W13Cr50rCrztaXnbX2ZC63rq9pD8te7QzYdp5AK+eAWeAZyc/HAfhcE3VtKVyjd GdUaIw2y4oCM0qPy3U9EHC2jLHaoNSNU054wThguu0uEfN3C0koGIesMWORQLvRx/rz7 a4cAZ8+VeLik0d13HYkvbXTMnTff3Mb6roqddqTe7LCp4xjURScXkslykheOeWGUaD8w A9mz/+fm76sRNBcCwVUJTUbKMCnjpumg2gxKAY1cDUxbyMyyameWWxVaaJZuh1y9alTD 4zqGqVEuPgfsAPCnH4g9hnsiuQdN0fMDNqAdtH2UuUww7C7BvyecnnOGq75zdRUDS+Pn kv+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497152; x=1764101952; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HugTGWvRZIP85YVvSycVedsiX938Xu07Q7rlJ5dV9Ug=; b=azp1ulD61iebRDO0wnG/FOzn8Mukt84VVaAXrT0J9x1ReezRoU9NvGAIJ/h6qrhv+/ twkDFAohDMPceAQHPgOArh2ppzmDMFSjIn6nf+kqNsGukF6XI5BhZa1oCkydttPy5qgu +hyirYPBebtEDlkpk9sQ3rrD/uy7nqHiWG8C7/ckTKYBOZoA6BUngsy/Z57RYXNOBk/B h5eliWx9zF47tu8MRcAe+RHqrPh6qup6y8tBiuENTylABhJ3FAIRpYIaO/9+Tw4AtwGT xMp9p/3hSWTYDDzkPJew3KoINIhAbyTiyoALODVvPt1z71ouee94PHYfGFs0nwipdJWE v2Xg== X-Gm-Message-State: AOJu0YyB3Kx09pHVOdblM3Gozjp5K5neuS63C9ApDoHKk6HIl3vqStb6 R1f5YEp0kinBaSZELlx0oWbYrMTCUhVAn4UXwmRhEuKv5vm9vMY8RZmvn8qgpMek X-Gm-Gg: ASbGncu8LFqo0aCubRBK8BAq2pr+hx/Fewq0IpJZ4cxi8LS6NYareIUp5Xj1IJWO0nN eLjTlq2Io6whobky/0GDwqM9Ku129KXgU0ediIbc7fOA41iBcFp02n1a0sVh4QeJVqSjfh/3f2p UZSv6faBVqRwXHHpPdhe1WKIcgNlkrIp/E17exHNeOZXfnS2A2+D1hewmusHctWHKHR3+lp5Pa2 1GrCBX2KaSTTEjybKaSj37Td5Zx2FLrx7cjbU+Grkh3wNCC0nnorVCugoXubkDjqAoqLVI7j0gX pgf5Ao3sH8zvriLWQKg7vn7nz9CunLfEv/UXXIMFt9b381WzsQPK21SMLyA4hC1jg3ejy6QBiVZ //kyHFsVSV0npgFDb1o18sIY/luIq+b67ZlmsnKlZpm67rG2quYP8TdkwAuaPe3zt6eo1shSlMC 4vo3JHWAOv8Dm99vgYV941GqZ0jtvqKLO9opS5a5vRkHFeqLwg7iaR7KYmOA1sO/mLS8nNPGWGA iHryUZYYewbBHWE X-Google-Smtp-Source: AGHT+IECWQbKajGsqhe9QxBChIn5TDnSeh/Y4LdT/nK7CygIVpJSPa9upZN/tzTEvHgyVA3Qskpj5w== X-Received: by 2002:a05:6602:6406:b0:949:d7:734b with SMTP id ca18e2360f4ac-94900d77599mr1197783939f.13.1763497151646; Tue, 18 Nov 2025 12:19:11 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:11 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 10/31] dyndbg: reduce verbose/debug clutter Date: Tue, 18 Nov 2025 13:18:20 -0700 Message-ID: <20251118201842.1447666-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" currently, for verbose=3D3, these are logged (blank lines for clarity): dyndbg: query 0: "class DRM_UT_CORE +p" mod:* dyndbg: split into words: "class" "DRM_UT_CORE" "+p" dyndbg: op=3D'+' dyndbg: flags=3D0x1 dyndbg: *flagsp=3D0x1 *maskp=3D0xffffffff dyndbg: parsed: func=3D"" file=3D"" module=3D"" format=3D"" lineno=3D0-0 c= lass=3D... dyndbg: no matches for query dyndbg: no-match: func=3D"" file=3D"" module=3D"" format=3D"" lineno=3D0-0= class=3D... dyndbg: processed 1 queries, with 0 matches, 0 errs That is excessive, so this patch: - shrinks 3 lines of 2nd stanza to single line - drops 1st 2 lines of 3rd stanza 3rd line is like 1st, with result, not procedure. 2nd line is just status, retold in 4th, with more info. New output: dyndbg: query 0: "class DRM_UT_CORE +p" mod:* dyndbg: split into words: "class" "DRM_UT_CORE" "+p" dyndbg: op=3D'+' flags=3D0x1 *flagsp=3D0x1 *maskp=3D0xffffffff dyndbg: no-match: func=3D"" file=3D"" module=3D"" format=3D"" lineno=3D0-0= class=3D... dyndbg: processed 1 queries, with 0 matches, 0 errs Also reduce verbose=3D3 messages in ddebug_add_module When modprobing a module, dyndbg currently logs/says "add-module", and then "skipping" if the module has no prdbgs. Instead just check 1st and return quietly. no functional change Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- -v2 squash several verbose cleanups together --- lib/dynamic_debug.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 21c1db7e8705..1db2f627237a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -275,9 +275,6 @@ static int ddebug_change(const struct ddebug_query *que= ry, } mutex_unlock(&ddebug_lock); =20 - if (!nfound && verbose) - pr_info("no matches for query\n"); - return nfound; } =20 @@ -510,7 +507,6 @@ static int ddebug_parse_flags(const char *str, struct f= lag_settings *modifiers) pr_err("bad flag-op %c, at start of %s\n", *str, str); return -EINVAL; } - v3pr_info("op=3D'%c'\n", op); =20 for (; *str ; ++str) { for (i =3D ARRAY_SIZE(opt_array) - 1; i >=3D 0; i--) { @@ -524,7 +520,6 @@ static int ddebug_parse_flags(const char *str, struct f= lag_settings *modifiers) return -EINVAL; } } - v3pr_info("flags=3D0x%x\n", modifiers->flags); =20 /* calculate final flags, mask based upon op */ switch (op) { @@ -540,7 +535,7 @@ static int ddebug_parse_flags(const char *str, struct f= lag_settings *modifiers) modifiers->flags =3D 0; break; } - v3pr_info("*flagsp=3D0x%x *maskp=3D0x%x\n", modifiers->flags, modifiers->= mask); + v3pr_info("op=3D'%c' flags=3D0x%x maskp=3D0x%x\n", op, modifiers->flags, = modifiers->mask); =20 return 0; } @@ -550,7 +545,7 @@ static int ddebug_exec_query(char *query_string, const = char *modname) struct flag_settings modifiers =3D {}; struct ddebug_query query =3D {}; #define MAXWORDS 9 - int nwords, nfound; + int nwords; char *words[MAXWORDS]; =20 nwords =3D ddebug_tokenize(query_string, words, MAXWORDS); @@ -568,10 +563,7 @@ static int ddebug_exec_query(char *query_string, const= char *modname) return -EINVAL; } /* actually go and implement the change */ - nfound =3D ddebug_change(&query, &modifiers); - vpr_info_dq(&query, nfound ? "applied" : "no-match"); - - return nfound; + return ddebug_change(&query, &modifiers); } =20 /* handle multiple queries in query string, continue on error, return @@ -1245,11 +1237,10 @@ static int ddebug_add_module(struct _ddebug_info *d= i, const char *modname) { struct ddebug_table *dt; =20 - v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs); - if (!di->num_descs) { - v3pr_info(" skip %s\n", modname); + if (!di->num_descs) return 0; - } + + v3pr_info("add-module: %s %d sites\n", modname, di->num_descs); =20 dt =3D kzalloc(sizeof(*dt), GFP_KERNEL); if (dt =3D=3D NULL) { --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) (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 41E013002C5 for ; Tue, 18 Nov 2025 20:19:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497156; cv=none; b=TvEr9eBHVNkCYPxW77Xs30a7P9zV4wZdZPQ1d2KphC6JTwDyVGfyInVDPywmzINLuXgrPPjcgn6Cxkv5k8c0IAhfdbr4p00wDrAhp+uG1pcCpPlwXcQKljF4Cc0GAg0aoUovaiootALLqOPZS7/2MI5Ov0qWlnQAtsTiae5I1QM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497156; c=relaxed/simple; bh=7mJiWoGmK0R4UXpo8WdCygyp32bwIoCu2s+Xmqg2nUQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UCnaT6pM9ag+luO5QDhugdZxtbQHKys8tD20XBzND4XpgBzHHRTsu4O8lPoCJ9Txx2dONd48gRWedqtgQchjy19fE3f5N2RI0qFgKTEKfEHNPn/JVfT9AHUmzG8Ka/R2XUs7KWT5ySEkwwBNV7EM2Q1v5aawm5d1wx8qFgvB90o= 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=HNZ8PjqR; arc=none smtp.client-ip=209.85.166.41 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="HNZ8PjqR" Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-9486248f01bso211570539f.0 for ; Tue, 18 Nov 2025 12:19:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497153; x=1764101953; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d0qqYdkZB9wZ4ghzz/46EdWtqxOuJ8xP/Sv3TkdVu1c=; b=HNZ8PjqRKwJd8HG9UV9wR1aaip9EU5+VyjdsaO8A3a8clT8x8glrxzWtpQaiWIiuGv T01kSkeeAeudnPkJqmfBnuBEXwkEWxMjgA6jyXf3L5jf224CPdVdX7DyEgxyhLqAqS5k jaqf/Qd3ZJ5aV+v5GEMrkVS7bxMDKDYyT7tej0r6sOmvAuh5GE32WWrrlrCJYmfEWFLH 0T3+9YF9Gf6L9m1rD132XJX+hBV6cY6HJaGcwMgTEvIEbNNyy9V5tjodYIWPI5KwMSaE 7hCescgcuPn1M3jpjnXWwttUxTe9Nw3/47bnEBL8ex8JrGOl+ttxZjVZhoPc2wSPkuVy 1PDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497153; x=1764101953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=d0qqYdkZB9wZ4ghzz/46EdWtqxOuJ8xP/Sv3TkdVu1c=; b=PO7mXb9f+oOEfAY+ba63ZWXClUrpScgJHfiKy4Ho7aAVAXUtxRY46rIj89Gu1kLkVU GPvMC9D+NeYch/6p5w8XFDpLpcru26kfVXIUdrrjFXO71ihjBJDhy47UyA6BJgOpWWBk l0i6Wgz7IyoGwZvGue8mkFdg3RGcP0BnU6IyCgGRKddZIMVy/E9n/UVgru551x2Ped/M mdF0bVeRj2B92ICoGhlZX3OHY/mqxKoVB+yWRy3EkdzfLG+19w0eCiSEYettHcWjEEIS MpjUy8RDT2Iyu85OhzV3I9UpH+S1p7bPWlOmujREAtQGN2QjmUMB2H8GxzfiNDh/8Yn4 ch9g== X-Gm-Message-State: AOJu0YyOtYy2a5jvMmEnvzjxTuVeXloRQNfnmhrYfOK0rbc6lELuqRuC PZXtb8cbCaR7mcGIOOMpjjalLn2a4m6XK1FgARIebHZp6qUE0x/MKoK3T1zEu697 X-Gm-Gg: ASbGnctPz+r6rQBg/j7Ua6OXRVy4CumceOghbfsd1BySlqw/MlEV9EkzRaoaBmFtZf7 Iq4vfw865kxUTpVj4YQi5aQM/WZaqLbF3pfTJXOFl9yBrEn7km1x9ehouRjaiiluwRgN49X8Gr/ pdVo4tXM6W2iIEIozPb9cPdvumJqPoYu0oa0uzbxMzUniKdHwX0HxGXwqBMJ/0xuOaL5lnQrxDC 5E26lKDqAaG3EuEC20MP4PcOm2H6znSswVuVWQ4tWGKjNZCfra261gMNq+N2RE+j1udZgU4BaCO TrjzyJact/K+Z2oAlZzm4m2fAycK+LXQwnqSuPvom2McbeIZM6boNzxJg6wXCiAyvb189jCf5S0 Zjt66rkuWpxymGjJYRMBKrmBFsSxbPuQMVAU9TUfIzwWqGBy79qUOBltjJadx0DNaVMjNdAOHy3 /oFFUxm/vh1dwEBZ0xy8V5s16pfiYWcvcaAcatXdgDYu5DHtMZwKTrTqDNev6ELi9FP2ZPJQIvB NFiJA== X-Google-Smtp-Source: AGHT+IFTEGi1y6IuJVSQs/d8QnQHjbnNxjQ193vFOfgNUHQ9r/krOkNKWiS5MQFDaYbiiwFQugK9wg== X-Received: by 2002:a05:6602:6b07:b0:948:a762:d83c with SMTP id ca18e2360f4ac-948e0cc2c64mr1880924439f.3.1763497152725; Tue, 18 Nov 2025 12:19:12 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:12 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 11/31] dyndbg: refactor param_set_dyndbg_classes and below Date: Tue, 18 Nov 2025 13:18:21 -0700 Message-ID: <20251118201842.1447666-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" Refactor callchain below param_set_dyndbg_classes(1) to allow mod-name specific settings. Split (1) into upper/lower fns, adding modname param to lower, and passing NULL in from upper. Below that, add the same param to ddebug_apply_class_bitmap(), and pass it thru to _ddebug_queries(), replacing NULL with the param. This allows the callchain to update the classmap in just one module, vs just all as currently done. While the sysfs param is unlikely to ever update just one module, the callchain will be used for modprobe handling, which should update only that just-probed module. In ddebug_apply_class_bitmap(), also check for actual changes to the bits before announcing them, to declutter logs. No functional change. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v3 s/modnm/mod_name/g --- lib/dynamic_debug.c | 65 ++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 1db2f627237a..64d69f5cba1b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -604,9 +604,10 @@ static int ddebug_exec_queries(char *query, const char= *modname) return nfound; } =20 -/* apply a new bitmap to the sys-knob's current bit-state */ +/* apply a new class-param setting */ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, - unsigned long *new_bits, unsigned long *old_bits) + unsigned long *new_bits, unsigned long *old_bits, + const char *query_modname) { #define QUERY_SIZE 128 char query[QUERY_SIZE]; @@ -614,7 +615,9 @@ static int ddebug_apply_class_bitmap(const struct ddebu= g_class_param *dcp, int matches =3D 0; int bi, ct; =20 - v2pr_info("apply: 0x%lx to: 0x%lx\n", *new_bits, *old_bits); + if (*new_bits !=3D *old_bits) + v2pr_info("apply bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, + *old_bits, query_modname ?: "'*'"); =20 for (bi =3D 0; bi < map->length; bi++) { if (test_bit(bi, new_bits) =3D=3D test_bit(bi, old_bits)) @@ -623,12 +626,16 @@ static int ddebug_apply_class_bitmap(const struct dde= bug_class_param *dcp, snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi], test_bit(bi, new_bits) ? '+' : '-', dcp->flags); =20 - ct =3D ddebug_exec_queries(query, NULL); + ct =3D ddebug_exec_queries(query, query_modname); matches +=3D ct; =20 v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi, ct, map->class_names[bi], *new_bits); } + if (*new_bits !=3D *old_bits) + v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, + *old_bits, query_modname ?: "'*'"); + return matches; } =20 @@ -683,7 +690,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa continue; } curr_bits ^=3D BIT(cls_id); - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits, NULL); *dcp->bits =3D curr_bits; v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, map->class_names[cls_id]); @@ -693,7 +700,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); curr_bits =3D CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); =20 - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits, NULL); *dcp->lvl =3D (cls_id + (wanted ? 1 : 0)); v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, map->class_names[cls_id], old_bits, curr_bits); @@ -707,18 +714,9 @@ static int param_set_dyndbg_classnames(const char *ins= tr, const struct kernel_pa return 0; } =20 -/** - * param_set_dyndbg_classes - class FOO >control - * @instr: string echo>d to sysfs, input depends on map_type - * @kp: kp->arg has state: bits/lvl, map, map_type - * - * Enable/disable prdbgs by their class, as given in the arguments to - * DECLARE_DYNDBG_CLASSMAP. For LEVEL map-types, enforce relative - * levels by bitpos. - * - * Returns: 0 or <0 if error. - */ -int param_set_dyndbg_classes(const char *instr, const struct kernel_param = *kp) +static int param_set_dyndbg_module_classes(const char *instr, + const struct kernel_param *kp, + const char *mod_name) { const struct ddebug_class_param *dcp =3D kp->arg; const struct ddebug_class_map *map =3D dcp->map; @@ -755,8 +753,8 @@ int param_set_dyndbg_classes(const char *instr, const s= truct kernel_param *kp) KP_NAME(kp), inrep, CLASSMAP_BITMASK(map->length)); inrep &=3D CLASSMAP_BITMASK(map->length); } - v2pr_info("bits:%lx > %s\n", inrep, KP_NAME(kp)); - totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits); + v2pr_info("bits:0x%lx > %s.%s\n", inrep, mod_name ?: "*", KP_NAME(kp)); + totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, mod_name); *dcp->bits =3D inrep; break; case DD_CLASS_TYPE_LEVEL_NUM: @@ -769,7 +767,7 @@ int param_set_dyndbg_classes(const char *instr, const s= truct kernel_param *kp) old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); new_bits =3D CLASSMAP_BITMASK(inrep); v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp)); - totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits); + totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits, mod_name= ); *dcp->lvl =3D inrep; break; default: @@ -778,16 +776,33 @@ int param_set_dyndbg_classes(const char *instr, const= struct kernel_param *kp) vpr_info("%s: total matches: %d\n", KP_NAME(kp), totct); return 0; } + +/** + * param_set_dyndbg_classes - classmap kparam setter + * @instr: string echo>d to sysfs, input depends on map_type + * @kp: kp->arg has state: bits/lvl, map, map_type + * + * enable/disable all class'd pr_debugs in the classmap. For LEVEL + * map-types, enforce * relative levels by bitpos. + * + * Returns: 0 or <0 if error. + */ +int param_set_dyndbg_classes(const char *instr, const struct kernel_param = *kp) +{ + return param_set_dyndbg_module_classes(instr, kp, NULL); +} EXPORT_SYMBOL(param_set_dyndbg_classes); =20 /** - * param_get_dyndbg_classes - classes reader + * param_get_dyndbg_classes - classmap kparam getter * @buffer: string description of controlled bits -> classes * @kp: kp->arg has state: bits, map * - * Reads last written state, underlying prdbg state may have been - * altered by direct >control. Displays 0x for DISJOINT, 0-N for - * LEVEL Returns: #chars written or <0 on error + * Reads last written state, underlying pr_debug states may have been + * altered by direct >control. Displays 0x for DISJOINT classmap + * types, 0-N for LEVEL types. + * + * Returns: ct of chars written or <0 on error */ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) { --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (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 0B94E3612CB for ; Tue, 18 Nov 2025 20:19:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497157; cv=none; b=CgrGSvPZF+K7nhPCv+kfGPtm7OxJZoaeCQkiUDnDKw/vhh5Kbzy9R5mtIH3wiwhLG1TCKuR5WciYLqbnVUYeDSR5igfQJL7HnbEDi65fvsSBytL2sG85BVSnRleEvLEWfSUleHVBQaHhFNx7TUEAHGIEQzfBh+FY6+mLsmS1KsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497157; c=relaxed/simple; bh=2eyFX9887pWvaNAvh0yNMg76uj1PYDsonSKdRoubYQA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YmYK0n940+t/qKIUUZ4k4ZBiJFnILflDqlhw3gUXuQuYGM0frNx7+NbCXTONpcQo//gfyZosyVQARtiMU5B7j8iRJssmKjhZfsp0tTIJJFZ42rrDACQxQKCzn5oquHZsU4ObLNjwJAdJ7q9yC6+K2gWgb2c+NFXaNzTMmrIYMnk= 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=fvDMtrBm; arc=none smtp.client-ip=209.85.166.42 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="fvDMtrBm" Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-94861514a5cso392874939f.1 for ; Tue, 18 Nov 2025 12:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497154; x=1764101954; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SOP7OLuL6Rs+m1spO13O+MWJO5WNRZEJe8z7hAFLE38=; b=fvDMtrBmeGE07O6qyWMuK3vnRLx8oMLNFONYU5GpicnQJyUGNU2gkDtkwnFsCBHffA JOx+vSvfQ9N70X5Xrg5xwgC2uA/TCujICsYgAHsk2VG80Hok1IjiwvtxpYORobgYfBuh Bik4kMS2R0o43RLov8Zr0Z+IwFJp2zDrgze08O+gJVpH7SjHebFpPzWtPG0UIDooyxMq MJJKcVzG81m9roZ8ZxNfXnKSAnLb2J7EVa5nFLYsuy/Z6vDaqA+Txu7CopgBRGadcyno 0LVUFxmBG6FzQaUL9fUhQ2u7PQfrsnseMdjfinH30zHIr0voFUyXJLo2RjLn2YTg4pmX 6Bpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497154; x=1764101954; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SOP7OLuL6Rs+m1spO13O+MWJO5WNRZEJe8z7hAFLE38=; b=gnLE5PIKZXUUAPTqvF+c8iLNfpMrp60Y2Co0moPKU47wE1SN71M90ysjDDpgPpOeAt bm4fNRUzOn+nAljEt1KzmyOvKIxxdYfjzXlAyVVvYHAD0AiDluntKuo4wDmtY4or9MN5 cmPM8OpZCV4DsKtoeceyGkt6fP3/b1YDss/RSfCLPzS737qvRiUw8fh/QWKrCWCIH+Yu R9KKYXfgzpKlRND81aXjkfUSwgjamXzHekBCUcJdq3KhRYhswKDYJVD73Sej3XEUmEfe O0uUsZqQtI+29QjE2THWenDhOKZEBvI2dYy1GO0QWvqy5OcxqQgFdKbdl9Aec6ZD637f Axig== X-Gm-Message-State: AOJu0YxBrjlQyfuJO5jOoZkL8iPyzQ6eq1ldtqDrI3O6WiZF/C8owPm+ 6o0BIggrSN9iDb/fXPixECT5aNPfUYWvLgCPgjZq6JHWRlWHX1uUQPRJwa8oWnGM X-Gm-Gg: ASbGncugkxmZHytv7aufP2QxvMOut0id4ZUCNoJZRLfVVz2h5nhUcZ+JvD+Tubi7Xhn doXwFu9vHk+s3be9gxB5RpWzzRoOhL6AQOKgYe9MRJ9bTYLjqSshViaWsMRV4KW0eFW80dL4n1X ivisoaJr2ZooNj9PgESeyEAhpUqBdv0+v4dv/Tw9A16fXT+cw+tpPfHhYMR2zGCI2m64m0M0iJ7 s1XwagRb1+feeBQ7rhRPbm3+5acZnVyAl/5gV3CbtTPV5+tsfXFF0F6DccOpBLrpXKzzJIDR4DM AKQ0DgmjIYBCunnRWXBt5ZYbHGTXZB5AmhJ97zey+2x66doh6uGQfcEJQ7kM4Aqui7nD9N6tgwl kPYNu4d7xKU5G54kSDWyG79rV5BlZ39cjHqEkOR+AtWerGHVrby59Stkj1/rS6WMrBam6J/2PHb rB5AfUzekAYY6QpW57MVfIgBNG/Ey512sVtHhpgtTnBiCzLpAbpkJhCdaoc7ao6KMLUf45xg14B zaktg== X-Google-Smtp-Source: AGHT+IEJ6iPTY53CeotOpkSdm3SjFRuFfAtmkE5eXc2Bbumw5jt44yQqagO0uBDeBTwAt0IceTrVsA== X-Received: by 2002:a05:6602:1249:b0:948:701c:86da with SMTP id ca18e2360f4ac-948e0db338bmr1851494239f.13.1763497153807; Tue, 18 Nov 2025 12:19:13 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:13 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 12/31] dyndbg: tighten fn-sig of ddebug_apply_class_bitmap Date: Tue, 18 Nov 2025 13:18:22 -0700 Message-ID: <20251118201842.1447666-13-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" old_bits arg is currently a pointer to the input bits, but this could allow inadvertent changes to the input by the fn. Disallow this. And constify new_bits while here. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- lib/dynamic_debug.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 64d69f5cba1b..db0559763e60 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -606,7 +606,8 @@ static int ddebug_exec_queries(char *query, const char = *modname) =20 /* apply a new class-param setting */ static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, - unsigned long *new_bits, unsigned long *old_bits, + const unsigned long *new_bits, + const unsigned long old_bits, const char *query_modname) { #define QUERY_SIZE 128 @@ -615,12 +616,12 @@ static int ddebug_apply_class_bitmap(const struct dde= bug_class_param *dcp, int matches =3D 0; int bi, ct; =20 - if (*new_bits !=3D *old_bits) + if (*new_bits !=3D old_bits) v2pr_info("apply bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, - *old_bits, query_modname ?: "'*'"); + old_bits, query_modname ?: "'*'"); =20 for (bi =3D 0; bi < map->length; bi++) { - if (test_bit(bi, new_bits) =3D=3D test_bit(bi, old_bits)) + if (test_bit(bi, new_bits) =3D=3D test_bit(bi, &old_bits)) continue; =20 snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi], @@ -632,9 +633,9 @@ static int ddebug_apply_class_bitmap(const struct ddebu= g_class_param *dcp, v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi, ct, map->class_names[bi], *new_bits); } - if (*new_bits !=3D *old_bits) + if (*new_bits !=3D old_bits) v2pr_info("applied bitmap: 0x%lx to: 0x%lx for %s\n", *new_bits, - *old_bits, query_modname ?: "'*'"); + old_bits, query_modname ?: "'*'"); =20 return matches; } @@ -690,7 +691,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa continue; } curr_bits ^=3D BIT(cls_id); - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits, NULL); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, *dcp->bits, NULL); *dcp->bits =3D curr_bits; v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, map->class_names[cls_id]); @@ -700,7 +701,7 @@ static int param_set_dyndbg_classnames(const char *inst= r, const struct kernel_pa old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); curr_bits =3D CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); =20 - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits, NULL); + totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, old_bits, NULL); *dcp->lvl =3D (cls_id + (wanted ? 1 : 0)); v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, map->class_names[cls_id], old_bits, curr_bits); @@ -754,7 +755,7 @@ static int param_set_dyndbg_module_classes(const char *= instr, inrep &=3D CLASSMAP_BITMASK(map->length); } v2pr_info("bits:0x%lx > %s.%s\n", inrep, mod_name ?: "*", KP_NAME(kp)); - totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits, mod_name); + totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, *dcp->bits, mod_name); *dcp->bits =3D inrep; break; case DD_CLASS_TYPE_LEVEL_NUM: @@ -767,7 +768,7 @@ static int param_set_dyndbg_module_classes(const char *= instr, old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); new_bits =3D CLASSMAP_BITMASK(inrep); v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp)); - totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits, mod_name= ); + totct +=3D ddebug_apply_class_bitmap(dcp, &new_bits, old_bits, mod_name); *dcp->lvl =3D inrep; break; default: --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) (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 3366B2FF64E for ; Tue, 18 Nov 2025 20:19:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497158; cv=none; b=aysd5KfJ3Ep/sMek5vSCy1mEWwBs/mHVBwYCkhZTSx8qynqd5VyWkhW2v/Nb7RAhwqDZr+qAT04+GjIyugyU8fB4abOsuh2yWL+nEjzaBG5NNpD+uA7Z7iURUcKExe2oVEcRIOIymTV4+04zO7xz7TmSXX7CQeDEHwKlMBO4T1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497158; c=relaxed/simple; bh=bL4ibxMMbvG1UAfybh2imUq82eqkvgfowHH3kNvv034=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q73Y0IBaV9K456AHSuBSbGPEarQr3ipTZLezs/Hwf9m3ES3W0YKigzMhjvnkI0k5+oZJYVEX8A1jNaLTRg9hl40AS9OgdM7wDQ6rO/CFC4nunJLv5oXyrIpKBmSJAKzeV5afIHLVR3vVyfuj8C70YsAM5nX2rPa+1Cj60OupXqQ= 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=QpV7FXnu; arc=none smtp.client-ip=209.85.166.46 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="QpV7FXnu" Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-948733e7810so226467439f.0 for ; Tue, 18 Nov 2025 12:19:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497155; x=1764101955; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sinG7VNY3wU1UNNZMH5t/yVFvlHMG8pS2a7wiUGdlB8=; b=QpV7FXnuckxW6SndB/qJNmUjx8PQ2h35lbbjr90TFfRznzoP8n3Iq6Tgvrhl6jaI5g /CoU3fbUu4i8QJjgSyj6D1si2Aihakq0AAI/IMYVPOCp10eG85A4xUMAGAWvPQbfEwBq Wnj7YBfaaEm4uWtBKjP0AU3cjmxealV2Dh3fBeZTvCzjoDwW3wgcm3TO8dYXYbhf4G+w Y+2cQZuZucc2MLnhBB/GiYHIbz2NPq9bPaIoa51yZsKn+5UZ6Av9qnE1VAU/yyWTNbxu M1elVB7gknpSX2Ze2e/0AA29mjC/B5TQvRsUEvYO5eZkZC4a8o1mLmLoDqBD8akzaf6v O1mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497155; x=1764101955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=sinG7VNY3wU1UNNZMH5t/yVFvlHMG8pS2a7wiUGdlB8=; b=gOWRyok+MO7xF54wXvyCGEHb5z+wXwkfo4snS8M53Qi9YtBkr7+E+15N/y6/b1bXHU 6RVuli9zmk3IblebtI4O+wNpgZjVZGZ4ZJZqSRoZ3CvN9/KLqAq8dQCDkIddRZ4DWGTg NlqeRXhHRzYmSsQBeR3MgPUdhg1TgmKCTfATWX5y6eMWYsPeP7IdTcjSutqgEKxfLhap gb2iSu7UG1wxKqnO4tCc4QjWiLe40ipPynUPavX/QXTiId9++2/9JnCmeyNyVQP3gZwR 696vPrZNPm6G0HhrnDeNCIXXVwiy+hZfnt9oILubDAGbeRQt9JBAr7petm+sPeB740HR KoDQ== X-Gm-Message-State: AOJu0Yw6H9sTGvoyEz3X7Vo7GTY6ZGMmql149oq+5AwwPo8a6zM9sF1t NnWANbBNTzpAwAYqI9JcXl6pVPlz5Cyn29zt8GXIYclKr59X/j8r5ZjFiyNRxDHE X-Gm-Gg: ASbGncv07bcasyly6WZr6Jm1fNn6zCRVbBccF/zGhZdyGoekFPGrr9aPMZ+WX8tpp95 5dZOz2SUlNcqCrP55xHBoTSLv7dHa4kYMU4ZSTFAifI+ufh0SfwXy2hvn9NuSz3ySCR4Ka6gKci hDrluDZIjB5Q3fbuoHM3s8akCLfOosits759b1YcZKGzB4lL/76AozJlt+JE9+4o4kB6xKoLedI QzBthndcdnsUPXKkHdRYdSOGwoDmQIiSkYD3w5SKsU66ZaZFGwI9Zq2UkJ2cBoc7wH7t9Rp25y9 e5slOhdosXJB6Nm5BnyUSVS7YAx3AueU+Jvhln3i6B2qMzyZpfsFzP0D96y21RLvuU4GkJ0L+iJ z2YFRoVzsM9oZVkILwDfLnwVY6VoYVyfbaxTLqPa+bpYvp56nwQAMmA8KQLq6kDOCe5uoJEFlXd tJ0uhgUJ8kF7ClIU9plBDcaOvEPPsjipcytXM/5Ig6irw+fNcaO9q79X15AxzCVZ1untBzzCR+j wM5lg== X-Google-Smtp-Source: AGHT+IGLH8MW7sVNPOn75BPqpruphqjyrqoEjIYIdZ9n/nXMEfVigTO8hiXOfgareRNrHy3bHEKarw== X-Received: by 2002:a05:6602:1551:b0:949:f77:4231 with SMTP id ca18e2360f4ac-9490f7747a1mr751322939f.3.1763497154983; Tue, 18 Nov 2025 12:19:14 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:14 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 13/31] dyndbg: replace classmap list with a vector Date: Tue, 18 Nov 2025 13:18:23 -0700 Message-ID: <20251118201842.1447666-14-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" Classmaps are stored in an elf section/array, but currently are individually list-linked onto dyndbg's per-module ddebug_table for operation. This is unnecessary. Just like dyndbg's descriptors, classes are packed in compile order; so even with many builtin modules employing multiple classmaps, each modules' maps are packed contiguously, and can be treated as a array-start-address & array-length. So this drops the whole list building operation done in ddebug_attach_module_classes(), and removes the list-head members. The "select-by-modname" condition is reused to find the start,end of the subrange. NOTE: This "filter-by-modname" on classmaps should really be done in ddebug_add_module(1); ie at least one step closer to ddebug_init(2), which already splits up pr-debug descriptors into subranges by modname, then calls (1) on each. (2) knows nothing of classmaps currently, and doesn't need to. For now, just add comment. Signed-off-by: Jim Cromie --- v3- drop __outvar as promising magic it doesnt have --- include/linux/dynamic_debug.h | 1 - lib/dynamic_debug.c | 62 ++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index c4ae79f934d9..51ed26e42032 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -83,7 +83,6 @@ enum class_map_type { }; =20 struct ddebug_class_map { - struct list_head link; struct module *mod; const char *mod_name; /* needed for builtins */ const char **class_names; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index db0559763e60..e882e951d585 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -45,10 +45,11 @@ extern struct ddebug_class_map __start___dyndbg_classes= []; extern struct ddebug_class_map __stop___dyndbg_classes[]; =20 struct ddebug_table { - struct list_head link, maps; + struct list_head link; const char *mod_name; - unsigned int num_ddebugs; struct _ddebug *ddebugs; + struct ddebug_class_map *classes; + unsigned int num_ddebugs, num_classes; }; =20 struct ddebug_query { @@ -148,12 +149,13 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) } =20 static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_tabl= e const *dt, - const char *class_string, int *class_id) + const char *class_string, + int *class_id) { struct ddebug_class_map *map; - int idx; + int i, idx; =20 - list_for_each_entry(map, &dt->maps, link) { + for (map =3D dt->classes, i =3D 0; i < dt->num_classes; i++, map++) { idx =3D match_string(map->class_names, map->length, class_string); if (idx >=3D 0) { *class_id =3D idx + map->base; @@ -164,7 +166,6 @@ static struct ddebug_class_map *ddebug_find_valid_class= (struct ddebug_table cons return NULL; } =20 -#define __outvar /* filled by callee */ /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching @@ -226,7 +227,7 @@ static int ddebug_change(const struct ddebug_query *que= ry, unsigned int nfound =3D 0; struct flagsbuf fbuf, nbuf; struct ddebug_class_map *map =3D NULL; - int __outvar valid_class; + int valid_class; =20 /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -1133,9 +1134,10 @@ static void *ddebug_proc_next(struct seq_file *m, vo= id *p, loff_t *pos) =20 static const char *ddebug_class_name(struct ddebug_iter *iter, struct _dde= bug *dp) { - struct ddebug_class_map *map; + struct ddebug_class_map *map =3D iter->table->classes; + int i, nc =3D iter->table->num_classes; =20 - list_for_each_entry(map, &iter->table->maps, link) + for (i =3D 0; i < nc; i++, map++) if (class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 @@ -1219,30 +1221,31 @@ static const struct proc_ops proc_fops =3D { .proc_write =3D ddebug_proc_write }; =20 -static void ddebug_attach_module_classes(struct ddebug_table *dt, - struct ddebug_class_map *classes, - int num_classes) +static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) { struct ddebug_class_map *cm; - int i, j, ct =3D 0; + int i, nc =3D 0; =20 - for (cm =3D classes, i =3D 0; i < num_classes; i++, cm++) { + /* + * Find this module's classmaps in a subrange/wholerange of + * the builtin/modular classmap vector/section. Save the start + * and length of the subrange at its edges. + */ + for (cm =3D di->classes, i =3D 0; i < di->num_classes; i++, cm++) { =20 if (!strcmp(cm->mod_name, dt->mod_name)) { - - v2pr_info("class[%d]: module:%s base:%d len:%d ty:%d\n", i, - cm->mod_name, cm->base, cm->length, cm->map_type); - - for (j =3D 0; j < cm->length; j++) - v3pr_info(" %d: %d %s\n", j + cm->base, j, - cm->class_names[j]); - - list_add(&cm->link, &dt->maps); - ct++; + if (!nc) { + v2pr_info("start subrange, class[%d]: module:%s base:%d len:%d ty:%d\n= ", + i, cm->mod_name, cm->base, cm->length, cm->map_type); + dt->classes =3D cm; + } + nc++; } } - if (ct) - vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); + if (nc) { + dt->num_classes =3D nc; + vpr_info("module:%s attached %d classes\n", dt->mod_name, nc); + } } =20 /* @@ -1274,10 +1277,9 @@ static int ddebug_add_module(struct _ddebug_info *di= , const char *modname) dt->num_ddebugs =3D di->num_descs; =20 INIT_LIST_HEAD(&dt->link); - INIT_LIST_HEAD(&dt->maps); =20 if (di->classes && di->num_classes) - ddebug_attach_module_classes(dt, di->classes, di->num_classes); + ddebug_attach_module_classes(dt, di); =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); @@ -1390,8 +1392,8 @@ static void ddebug_remove_all_tables(void) mutex_lock(&ddebug_lock); while (!list_empty(&ddebug_tables)) { struct ddebug_table *dt =3D list_entry(ddebug_tables.next, - struct ddebug_table, - link); + struct ddebug_table, + link); ddebug_table_free(dt); } mutex_unlock(&ddebug_lock); --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) (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 25665364E8C for ; Tue, 18 Nov 2025 20:19:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497159; cv=none; b=FZ+SFVZBLGp670x0L8cHmnZMN5gjxr+ZmzSBj4H0qKY9Tg+/KPbrTbccuSifve2YFMRS8kw/BP/vy3YdU3fgx8pQ6PUrNB7eCzFbuG5nlYcMUNudEzlFdlpvnewWL0ARmj01OsWThU/KHBDWKxviZQ7YeMw2cm66cXpuuxix/cA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497159; c=relaxed/simple; bh=OCKD5EV3sLHtsVsB9amTvKQ8ND5z1okePEOHBoF1W6k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DuY5/i5fR4Y25OBc9ZPYk0TBK1aJ8vqvjmJivfm4Tl6Ic+Fm9C/X9zBCYLF1Wf+O9zx80EmH45VHjDtzZnGQMEwiLHs3LrkYbswheoYVY3InSlhJOnUw/m57daGMWtz2GoNNL7x3+PyMniXQrPvqFKfdvTPozJm07kHFmm/trLY= 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=ZKU4uHoz; arc=none smtp.client-ip=209.85.166.47 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="ZKU4uHoz" Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-9490cbf951fso96551239f.1 for ; Tue, 18 Nov 2025 12:19:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497156; x=1764101956; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mom9p3QYL/HEnLm12XjQXHk1KtSfULxrp3u8JPNUlAU=; b=ZKU4uHozGH/SujWqU8jFpUF0EVF7l27+LeZfpvHHGRmqSnjiI5gGaq4KJehlr/uN3D hT4ZiKNkalmx1xZJ30VnliBt+ENE95zeitaSBZqaNR4pJ5YSYMDV5f8vqRoNHqHj//Rx gwSwTy8Akr9CU+gJKc9+1UOaqESMGtCVro1pMxyAz6BMdAjCKIhA9ulVGdgX2HkvtGVO 1banfJ9y63JUv+mFI5sPluO2A2MR6JOtvMJ2az9C9D1SFRU+MSgPSi/Ul1fp0wvOKuGY MOi55wmR3Plsge7RMNczeBmMIlhBqMZZfADV3BkRXxrY0TYjE0Ds6JMsgzcTGfIxfX0s zmXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497156; x=1764101956; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Mom9p3QYL/HEnLm12XjQXHk1KtSfULxrp3u8JPNUlAU=; b=PkQC8e26vomhH3TZYrBqyIRldmmI3HuqgIn9V5m5X1KW5RD2tMFqid0hvdppdtnF2t 2TQYE/iqPDPohX/LNtxS1azS4IFHosDuEnyyo44kGJMzeurl+TO3j/TveAQZIzIhLLAK ny2ts8aNPayt6qKQ3GwdCrM/C3KC9z3UpdlsGLjdvB2rpEIYx/S6l6gCKs6KrEoxnAHj BlW1c1lugP8uTBA41EP563kmC8oSYvthve1YtWDmpdWPJJhHxMB8ZXn+cqAUF2wbQb/k uWHhozou9ChRz1kBBWrKDF7QPEam8zqq8LbOkwJGsUVB/lmifR8XRvjXY52eOwzEgNsR sZ5g== X-Gm-Message-State: AOJu0YwxiFQOoZPmB2raHE5z9197Qygci2KnsHLnA9dep2V3HMtFO3Bo +Irt+j7Xi62tG6nlsvEBoKX2BLExo3xNgYBRrmppKCTkONdGRKbAk4kw+e6WTwju X-Gm-Gg: ASbGncsBhj2rQOhdCgBbjeus7oijgk2HZlJCzBZR1/EXrIr8RyXEaesIHnmua37jjF0 X1SyPMbPq2NCxg+b+A9uVGnvGUkQ92/1Ev8lkeXAAb3jGrYt2M7dLWD17PlWxT3kuyI+3eN4BBm plE5KPZz8wgzYhAIl3aDWsN7EcVNwE+c7TAj9M/nNGS42cenxY/idq7DaV/HnQeJnhE5vUAd6fo l5jV0500fD2DOJly8ZcjYfvfehP0zMorhEB05VhGQlPtGkioe476i1uRS9s1FrzbiEqvLjsCMun wuEaD163RQ2vIUMrRG23w8Xd+K8AwZkETeron+d2MyeBiPEVN90JcthbECHPEcQzVxQESa98KzX qZkwvwDXWRaqfkC8W3bH7dC+ovtntFSXcy+GnhIUOFbXOAWGp+ZjNKQ+woSQ3yK/3uf+isFvlsW 5vVDlkT3IlwGV2KomnkSo7h4KWmqJHVqHr/KPaFaZONKdRcq3hO/IGJhhFpH05dVXZGgo= X-Google-Smtp-Source: AGHT+IF9qxBwV/U/VSjF667XqOPS3S0CMKNPPtG91ifTzUkTzfrgNjJ7HC4VQQdW5SFo4/2/ImAGSw== X-Received: by 2002:a05:6602:1344:b0:945:a1fc:a7a5 with SMTP id ca18e2360f4ac-948e0defd6amr1887003939f.11.1763497156071; Tue, 18 Nov 2025 12:19:16 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:15 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 14/31] dyndbg: macrofy a 2-index for-loop pattern Date: Tue, 18 Nov 2025 13:18:24 -0700 Message-ID: <20251118201842.1447666-15-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" dynamic-debug currently has 2 __sections (__dyndbg, __dyndb_classes), struct _ddebug_info keeps track of them both, with 2 members each: _vec and _vec#_len. We need to loop over these sections, with index and record pointer, making ref to both _vec and _vec_len. This is already fiddly and error-prone, and will get worse as we add a 3rd section. Lets instead embed/abstract the fiddly-ness in the `for_subvec()` macro, and avoid repeating it going forward. This is a for-loop macro expander, so it syntactically expects to precede either a single statement or a { block } of them, and the usual typeof or do-while-0 tricks are unavailable to fix the multiple-expansion warning. The macro needs a lot from its caller: it needs 2 local vars, 1 of which is a ref to a contained struct with named members. To support these requirements, add: 1. __ASSERT_IS_LVALUE(_X): ie: ((void)sizeof((void)0, &(x))) 2. __ASSERT_HAS_VEC_MEMBERS(_X, _Y): compile-time check that the _Y "vector" exists ie: _X->_Y and _X->num##_Y are lvalues. The for_subvec() macro then invokes these before the for-loop itself; they disappear at runtime. They do cause a "complex macro" CHECK from checkpatch --strict. Signed-off-by: Jim Cromie --- -v5+ add __ASSERT_*() macros add then drop __chkp_no_side_effects() macro due to changes v5+ drop Reviewed-by: Louis Chauvet this patch evokes these complaints, the "reuses" are all lvalues, so not issues. (vec) is incompatible with ## paste-up do-while also wont work here. CHECK: Macro argument '_vec' may be better as '(_vec)' to avoid precedence = issues WARNING: Non-declarative macros with multiple statements should be enclosed= in a do - while loop CHECK: Macro argument reuse '_i' - possible side-effects? CHECK: Macro argument reuse '_sp' - possible side-effects? CHECK: Macro argument reuse '_box' - possible side-effects? CHECK: Macro argument reuse '_vec' - possible side-effects? --- lib/dynamic_debug.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index e882e951d585..94d05d09a128 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -128,6 +128,28 @@ do { \ #define v3pr_info(fmt, ...) vnpr_info(3, fmt, ##__VA_ARGS__) #define v4pr_info(fmt, ...) vnpr_info(4, fmt, ##__VA_ARGS__) =20 +/* + * simplify a repeated for-loop pattern walking N steps in a T _vec + * member inside a struct _box. It expects int i and T *_sp to be + * declared in the caller. + * @_i: caller provided counter. + * @_sp: cursor into _vec, to examine each item. + * @_box: ptr to a struct containing @_vec member + * @_vec: name of a member in @_box + */ +#define __ASSERT_IS_LVALUE(x) ((void)sizeof((void)0, &(x))) +#define __ASSERT_HAS_VEC_MEMBER(_box, _vec) ({ \ + (void)sizeof((_box)->_vec); \ + (void)sizeof((_box)->num_##_vec); \ +}) +#define for_subvec(_i, _sp, _box, _vec) \ + __ASSERT_IS_LVALUE(_i); \ + __ASSERT_IS_LVALUE(_sp); \ + __ASSERT_HAS_VEC_MEMBER(_box, _vec); \ + for ((_i) =3D 0, (_sp) =3D (_box)->_vec; \ + (_i) < (_box)->num_##_vec; \ + (_i)++, (_sp)++) + static void vpr_info_dq(const struct ddebug_query *query, const char *msg) { /* trim any trailing newlines */ @@ -155,7 +177,7 @@ static struct ddebug_class_map *ddebug_find_valid_class= (struct ddebug_table cons struct ddebug_class_map *map; int i, idx; =20 - for (map =3D dt->classes, i =3D 0; i < dt->num_classes; i++, map++) { + for_subvec(i, map, dt, classes) { idx =3D match_string(map->class_names, map->length, class_string); if (idx >=3D 0) { *class_id =3D idx + map->base; @@ -1231,8 +1253,7 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, struct _ddebug * the builtin/modular classmap vector/section. Save the start * and length of the subrange at its edges. */ - for (cm =3D di->classes, i =3D 0; i < di->num_classes; i++, cm++) { - + for_subvec(i, cm, di, classes) { if (!strcmp(cm->mod_name, dt->mod_name)) { if (!nc) { v2pr_info("start subrange, class[%d]: module:%s base:%d len:%d ty:%d\n= ", --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) (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 82651366DA5 for ; Tue, 18 Nov 2025 20:19:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497162; cv=none; b=ERTdaM2SuKYrDNCIqGBTWmHJK2/dGy5Wt01oPKEJK4atI8f3sl78WbvhuCxuo5lgCeRx/SWnS4iNFZvwPsaMuLgQRELmTItacT8YDeEDPyQ6iZreL+GoEJbiD9/UlDaDVNE6vOoyvvxfFQdhMjGCC02iRuE0uSIH1TIlZSeuU3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497162; c=relaxed/simple; bh=tkuC4+NSdrPQcgj/uUHyigI2Xkzx07TfRLUChhoeNJQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YXSyVsbntMu4aJ0MR1o7nd77SijQA3dL5XFfsVrPLVNLeu0fGtFRdgKELhXI6iEEahDLuaYEJL37OO4KP+uXTh4O3tcrgNGZtN7eaD9tbJC9mNtVN+lNoxgt325TWIVo8I3oOrOWkKIHcZ+0hjc5mGiukCAYg8QTaVn5JeVq4a8= 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=bcW7QQI4; arc=none smtp.client-ip=209.85.166.46 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="bcW7QQI4" Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-9487e2b9622so369004339f.2 for ; Tue, 18 Nov 2025 12:19:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497157; x=1764101957; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sn6anK20ECiY75J6+/wQbhcU+s79t+RA4Zd8tQWtzUk=; b=bcW7QQI4lRf7awIgBjLMTxpJtgiwUcrc9Ic9jFYVgM2vs3OJ1OHhVCgykMTzIIFBtm YjBx2WEQHs5xilyLea2d5XH9v3gWP/LogF75LOfP0s4+6d+wI23VMPBgqFKz4OTJ64qy ZObRHuXzItDmcYjjYBasbYwjstBHPe9q6qi7Tdg3XLMHQURkF9NLP/q6ZkyGrRQpUmeU D0H8ekwFWm+QVyBWumFaqIqkR6SeizFvQs7y/gVoEfa6hUPSQ3jsEmdTSD9ZNgTE3wT5 t/S+ozvXUCJplindZ7AYUAq+E7anS4GhmbAMQVvfUtpxbYj5xHCP27zDagdxfnuQkmDp aTEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497157; x=1764101957; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=sn6anK20ECiY75J6+/wQbhcU+s79t+RA4Zd8tQWtzUk=; b=wwDua0onfJALkF+oM44sv1MsN//+93OgGNbGGwlfqYThQc/T6apcAK7/eeMPQm/IB9 WHEUVnFzOJ2ZOc/s/fKSGPw1Cizlh/diEOe9qwYpBHp8apYkhS5nuFrwe/qXLSezQrR/ wYGP7uUQY9O0NPdfMDQOImiwGgRitHB3c9B8EQj+GFp/AYWFs6my6+x4H5oaFO6VujD7 bgIK9fG212VcA47SLSxV22s7n7pw4EQt9rzoh0xERyxhG+oubrQWOeZvwbT2BRplYexX rpEWbmFBjLo+KT2Ph2yZsl3VnKuwlq1wj8XIffVnZ6rb1LtxnJ7SJizBVuTu8Ax46UzH beRA== X-Gm-Message-State: AOJu0YwFMXRdNG7nXlV63Dsh0PhhigmWCUMJubfakC369KDNwP9ApKUs +NPybc6FXDALisHxPmQgmVmYCWBXkaontJqkk3sMNX/ibjlPH4SnmY1nJN6tPmD9 X-Gm-Gg: ASbGnct9c+5EKRLi3VaYB8G14XeVGkjmLw4peSVNlFJIJqC2l86TcD56h45IWMkrLt6 A1FRPCsIINu0NpF2Zp5JoSa/7zOGdqqQnlqHoVyKZYzWg4S2X8KJO4CeitL27fu2dZXrUEkK/4b 1HzVhg6ayBeWp4VCY9CY1LUwp6pCMpHV4SCHW/uffOf9kR1wMrgJ+4ZsL9GuZApcDnyPFXb69ZX 56sQgs3rp/rhOhTHmZXLDfUXeCkAewSlxTl7QNVH7PpPB5roq3ASTofqib1SpG1DsUDoGi6DN+9 cbixkeLAA7FkHJOmdfkicmpH37FlO+DyssSmrmFTgJ+KCiKvv5kHlm/V37E6L8gV27rpXtcTAKo Xg9A3wO9XJJF66SVhl2qgh7RI8us6P/bNwj6wYwrZw3vxHbHdBF5R4QWddZgkOzSWgWa4Rljyx/ nzEUah/Buk1v00c2cVkeqQ2ZBDq6qNDw2Nboi5oDRs3hp0QGrT8C7wCDRVP9sH/tL1mQkB8YsbN zjiGg== X-Google-Smtp-Source: AGHT+IGqy+Bd0waPS3z3QSl2V7+F7ZU600XzwejxFgMAWwar9tGK98/FktbC/B1ytDGJF+EzcJ038g== X-Received: by 2002:a05:6602:26d2:b0:940:d7bd:a850 with SMTP id ca18e2360f4ac-948e0dd49a1mr2003910939f.16.1763497157374; Tue, 18 Nov 2025 12:19:17 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:16 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 15/31] dyndbg,module: make proper substructs in _ddebug_info Date: Tue, 18 Nov 2025 13:18:25 -0700 Message-ID: <20251118201842.1447666-16-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" recompose struct _ddebug_info, inserting proper sub-structs. The struct _ddebug_info has 2 pairs of _vec, num##_vec fields, for descs and classes respectively. for_subvec() makes walking these vectors less cumbersome, now lets move those field pairs into their own "vec" structs: _ddebug_descs & _ddebug_class_maps, and re-compose struct _ddebug_info to contain them cleanly. This also lets us rid for_subvec() of its num##_vec paste-up. Also recompose struct ddebug_table to contain a _ddebug_info. This reinforces its use as a cursor into relevant data for a builtin module, and access to the full _ddebug state for modules. NOTES: Invariant: These vectors ref a contiguous subrange of __section memory in builtin/DATA or in loadable modules via mod->dyndbg_info; with guaranteed life-time for us. Fixup names: Normalize all struct names to "struct _ddebug_*" eliminating the minor/stupid variations created in classmaps-v1. Also normalize the __section names to "__dyndbg_*". struct module contains a _ddebug_info field and module/main.c sets it up, so that gets adjusted rather obviously. Signed-off-by: Jim Cromie --- -v2 rework towards front of series -v4 rework after stubs-macro -v6 adapt ASSERT_HAS_VEC_MEMBER drop __packed on/in _ddebug_info, etc Ive ignored these checkpatch --strict reports CHECK: Macro argument reuse '_vec' - possible side-effects? CHECK: Macro argument reuse '_vec' - possible side-effects? --- include/asm-generic/vmlinux.lds.h | 4 +- include/linux/dynamic_debug.h | 42 ++++++---- kernel/module/main.c | 12 +-- lib/dynamic_debug.c | 127 +++++++++++++++--------------- lib/test_dynamic_debug.c | 2 +- 5 files changed, 100 insertions(+), 87 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index ae2d2359b79e..866c79d8b2a5 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -365,8 +365,8 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELL= ER_CLANG) *(__tracepoints) \ /* implement dynamic printk debug */ \ . =3D ALIGN(8); \ - BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) \ - BOUNDED_SECTION_BY(__dyndbg, ___dyndbg) \ + BOUNDED_SECTION_BY(__dyndbg_class_maps, ___dyndbg_class_maps) \ + BOUNDED_SECTION_BY(__dyndbg_descriptors, ___dyndbg_descs) \ CODETAG_SECTIONS() \ LIKELY_PROFILE() \ BRANCH_PROFILE() \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 51ed26e42032..4775f66e96dd 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -82,30 +82,42 @@ enum class_map_type { */ }; =20 -struct ddebug_class_map { - struct module *mod; - const char *mod_name; /* needed for builtins */ +struct _ddebug_class_map { + struct module *mod; /* NULL for builtins */ + const char *mod_name; const char **class_names; const int length; const int base; /* index of 1st .class_id, allows split/shared space */ enum class_map_type map_type; }; =20 -/* encapsulate linker provided built-in (or module) dyndbg data */ +/* + * @_ddebug_info: gathers module/builtin dyndbg_* __sections together. + * For builtins, it is used as a cursor, with the inner structs + * marking sub-vectors of the builtin __sections in DATA. + */ +struct _ddebug_descs { + struct _ddebug *start; + int len; +}; + +struct _ddebug_class_maps { + struct _ddebug_class_map *start; + int len; +}; + struct _ddebug_info { - struct _ddebug *descs; - struct ddebug_class_map *classes; - unsigned int num_descs; - unsigned int num_classes; + struct _ddebug_descs descs; + struct _ddebug_class_maps maps; }; =20 -struct ddebug_class_param { +struct _ddebug_class_param { union { unsigned long *bits; unsigned long *lvl; }; char flags[8]; - const struct ddebug_class_map *map; + const struct _ddebug_class_map *map; }; =20 /* @@ -124,8 +136,8 @@ struct ddebug_class_param { */ #define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ - static struct ddebug_class_map __aligned(8) __used \ - __section("__dyndbg_classes") _var =3D { \ + static struct _ddebug_class_map __aligned(8) __used \ + __section("__dyndbg_class_maps") _var =3D { \ .mod =3D THIS_MODULE, \ .mod_name =3D KBUILD_MODNAME, \ .base =3D _base, \ @@ -159,7 +171,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, =20 #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ static struct _ddebug __aligned(8) \ - __section("__dyndbg") name =3D { \ + __section("__dyndbg_descriptors") name =3D { \ .modname =3D KBUILD_MODNAME, \ .function =3D __func__, \ .filename =3D __FILE__, \ @@ -242,7 +254,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, * macro. */ #define _dynamic_func_call_cls(cls, fmt, func, ...) \ - __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS_= _) + __dynamic_func_call_cls(__UNIQUE_ID(_ddebug), cls, fmt, func, ##__VA_ARGS= __) #define _dynamic_func_call(fmt, func, ...) \ _dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__) =20 @@ -252,7 +264,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, * with precisely the macro's varargs. */ #define _dynamic_func_call_cls_no_desc(cls, fmt, func, ...) \ - __dynamic_func_call_cls_no_desc(__UNIQUE_ID(ddebug), cls, fmt, \ + __dynamic_func_call_cls_no_desc(__UNIQUE_ID(_ddebug), cls, fmt, \ func, ##__VA_ARGS__) #define _dynamic_func_call_no_desc(fmt, func, ...) \ _dynamic_func_call_cls_no_desc(_DPRINTK_CLASS_DFLT, fmt, \ diff --git a/kernel/module/main.c b/kernel/module/main.c index c66b26184936..1ccc5d4399c3 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2710,12 +2710,12 @@ static int find_module_sections(struct module *mod,= struct load_info *info) pr_warn("%s: Ignoring obsolete parameters\n", mod->name); =20 #ifdef CONFIG_DYNAMIC_DEBUG_CORE - mod->dyndbg_info.descs =3D section_objs(info, "__dyndbg", - sizeof(*mod->dyndbg_info.descs), - &mod->dyndbg_info.num_descs); - mod->dyndbg_info.classes =3D section_objs(info, "__dyndbg_classes", - sizeof(*mod->dyndbg_info.classes), - &mod->dyndbg_info.num_classes); + mod->dyndbg_info.descs.start =3D section_objs(info, "__dyndbg_descriptors= ", + sizeof(*mod->dyndbg_info.descs.start), + &mod->dyndbg_info.descs.len); + mod->dyndbg_info.maps.start =3D section_objs(info, "__dyndbg_class_maps", + sizeof(*mod->dyndbg_info.maps.start), + &mod->dyndbg_info.maps.len); #endif =20 return 0; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 94d05d09a128..c9377a444fc8 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -39,17 +39,15 @@ =20 #include =20 -extern struct _ddebug __start___dyndbg[]; -extern struct _ddebug __stop___dyndbg[]; -extern struct ddebug_class_map __start___dyndbg_classes[]; -extern struct ddebug_class_map __stop___dyndbg_classes[]; +extern struct _ddebug __start___dyndbg_descs[]; +extern struct _ddebug __stop___dyndbg_descs[]; +extern struct _ddebug_class_map __start___dyndbg_class_maps[]; +extern struct _ddebug_class_map __stop___dyndbg_class_maps[]; =20 struct ddebug_table { struct list_head link; const char *mod_name; - struct _ddebug *ddebugs; - struct ddebug_class_map *classes; - unsigned int num_ddebugs, num_classes; + struct _ddebug_info info; }; =20 struct ddebug_query { @@ -135,20 +133,21 @@ do { \ * @_i: caller provided counter. * @_sp: cursor into _vec, to examine each item. * @_box: ptr to a struct containing @_vec member - * @_vec: name of a member in @_box + * @_vec: name of a a vector member in @_box */ + #define __ASSERT_IS_LVALUE(x) ((void)sizeof((void)0, &(x))) -#define __ASSERT_HAS_VEC_MEMBER(_box, _vec) ({ \ - (void)sizeof((_box)->_vec); \ - (void)sizeof((_box)->num_##_vec); \ +#define __ASSERT_HAS_VEC_MEMBER(_box, _vec) ({ \ + (void)sizeof((_box)->_vec.start); \ + (void)sizeof((_box)->_vec.len); \ }) #define for_subvec(_i, _sp, _box, _vec) \ __ASSERT_IS_LVALUE(_i); \ __ASSERT_IS_LVALUE(_sp); \ __ASSERT_HAS_VEC_MEMBER(_box, _vec); \ - for ((_i) =3D 0, (_sp) =3D (_box)->_vec; \ - (_i) < (_box)->num_##_vec; \ - (_i)++, (_sp)++) + for ((_i) =3D 0, (_sp) =3D (_box)->_vec.start; \ + (_i) < (_box)->_vec.len; \ + (_i)++, (_sp)++) /* { block } */ =20 static void vpr_info_dq(const struct ddebug_query *query, const char *msg) { @@ -170,14 +169,14 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) query->first_lineno, query->last_lineno, query->class_string); } =20 -static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_tabl= e const *dt, +static struct _ddebug_class_map *ddebug_find_valid_class(struct ddebug_tab= le const *dt, const char *class_string, int *class_id) { - struct ddebug_class_map *map; + struct _ddebug_class_map *map; int i, idx; =20 - for_subvec(i, map, dt, classes) { + for_subvec(i, map, &dt->info, maps) { idx =3D match_string(map->class_names, map->length, class_string); if (idx >=3D 0) { *class_id =3D idx + map->base; @@ -248,7 +247,7 @@ static int ddebug_change(const struct ddebug_query *que= ry, unsigned int newflags; unsigned int nfound =3D 0; struct flagsbuf fbuf, nbuf; - struct ddebug_class_map *map =3D NULL; + struct _ddebug_class_map *map =3D NULL; int valid_class; =20 /* search for matching ddebugs */ @@ -269,8 +268,8 @@ static int ddebug_change(const struct ddebug_query *que= ry, valid_class =3D _DPRINTK_CLASS_DFLT; } =20 - for (i =3D 0; i < dt->num_ddebugs; i++) { - struct _ddebug *dp =3D &dt->ddebugs[i]; + for (i =3D 0; i < dt->info.descs.len; i++) { + struct _ddebug *dp =3D &dt->info.descs.start[i]; =20 if (!ddebug_match_desc(query, dp, valid_class)) continue; @@ -628,14 +627,14 @@ static int ddebug_exec_queries(char *query, const cha= r *modname) } =20 /* apply a new class-param setting */ -static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, +static int ddebug_apply_class_bitmap(const struct _ddebug_class_param *dcp, const unsigned long *new_bits, const unsigned long old_bits, const char *query_modname) { #define QUERY_SIZE 128 char query[QUERY_SIZE]; - const struct ddebug_class_map *map =3D dcp->map; + const struct _ddebug_class_map *map =3D dcp->map; int matches =3D 0; int bi, ct; =20 @@ -671,8 +670,8 @@ static int ddebug_apply_class_bitmap(const struct ddebu= g_class_param *dcp, /* accept comma-separated-list of [+-] classnames */ static int param_set_dyndbg_classnames(const char *instr, const struct ker= nel_param *kp) { - const struct ddebug_class_param *dcp =3D kp->arg; - const struct ddebug_class_map *map =3D dcp->map; + const struct _ddebug_class_param *dcp =3D kp->arg; + const struct _ddebug_class_map *map =3D dcp->map; unsigned long curr_bits, old_bits; char *cl_str, *p, *tmp; int cls_id, totct =3D 0; @@ -742,8 +741,8 @@ static int param_set_dyndbg_module_classes(const char *= instr, const struct kernel_param *kp, const char *mod_name) { - const struct ddebug_class_param *dcp =3D kp->arg; - const struct ddebug_class_map *map =3D dcp->map; + const struct _ddebug_class_param *dcp =3D kp->arg; + const struct _ddebug_class_map *map =3D dcp->map; unsigned long inrep, new_bits, old_bits; int rc, totct =3D 0; =20 @@ -830,8 +829,8 @@ EXPORT_SYMBOL(param_set_dyndbg_classes); */ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) { - const struct ddebug_class_param *dcp =3D kp->arg; - const struct ddebug_class_map *map =3D dcp->map; + const struct _ddebug_class_param *dcp =3D kp->arg; + const struct _ddebug_class_map *map =3D dcp->map; =20 switch (map->map_type) { =20 @@ -1082,8 +1081,8 @@ static struct _ddebug *ddebug_iter_first(struct ddebu= g_iter *iter) } iter->table =3D list_entry(ddebug_tables.next, struct ddebug_table, link); - iter->idx =3D iter->table->num_ddebugs; - return &iter->table->ddebugs[--iter->idx]; + iter->idx =3D iter->table->info.descs.len; + return &iter->table->info.descs.start[--iter->idx]; } =20 /* @@ -1104,10 +1103,10 @@ static struct _ddebug *ddebug_iter_next(struct ddeb= ug_iter *iter) } iter->table =3D list_entry(iter->table->link.next, struct ddebug_table, link); - iter->idx =3D iter->table->num_ddebugs; + iter->idx =3D iter->table->info.descs.len; --iter->idx; } - return &iter->table->ddebugs[iter->idx]; + return &iter->table->info.descs.start[iter->idx]; } =20 /* @@ -1151,16 +1150,19 @@ static void *ddebug_proc_next(struct seq_file *m, v= oid *p, loff_t *pos) return dp; } =20 -#define class_in_range(class_id, map) \ - (class_id >=3D map->base && class_id < map->base + map->length) +static bool ddebug_class_in_range(const int class_id, const struct _ddebug= _class_map *map) +{ + return (class_id >=3D map->base && + class_id < map->base + map->length); +} =20 -static const char *ddebug_class_name(struct ddebug_iter *iter, struct _dde= bug *dp) +static const char *ddebug_class_name(struct ddebug_table *dt, struct _ddeb= ug *dp) { - struct ddebug_class_map *map =3D iter->table->classes; - int i, nc =3D iter->table->num_classes; + struct _ddebug_class_map *map; + int i; =20 - for (i =3D 0; i < nc; i++, map++) - if (class_in_range(dp->class_id, map)) + for_subvec(i, map, &dt->info, maps) + if (ddebug_class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 return NULL; @@ -1193,7 +1195,7 @@ static int ddebug_proc_show(struct seq_file *m, void = *p) seq_putc(m, '"'); =20 if (dp->class_id !=3D _DPRINTK_CLASS_DFLT) { - class =3D ddebug_class_name(iter, dp); + class =3D ddebug_class_name(iter->table, dp); if (class) seq_printf(m, " class:%s", class); else @@ -1245,7 +1247,7 @@ static const struct proc_ops proc_fops =3D { =20 static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) { - struct ddebug_class_map *cm; + struct _ddebug_class_map *cm; int i, nc =3D 0; =20 /* @@ -1253,18 +1255,18 @@ static void ddebug_attach_module_classes(struct dde= bug_table *dt, struct _ddebug * the builtin/modular classmap vector/section. Save the start * and length of the subrange at its edges. */ - for_subvec(i, cm, di, classes) { + for_subvec(i, cm, di, maps) { if (!strcmp(cm->mod_name, dt->mod_name)) { if (!nc) { v2pr_info("start subrange, class[%d]: module:%s base:%d len:%d ty:%d\n= ", i, cm->mod_name, cm->base, cm->length, cm->map_type); - dt->classes =3D cm; + dt->info.maps.start =3D cm; } nc++; } } if (nc) { - dt->num_classes =3D nc; + dt->info.maps.len =3D nc; vpr_info("module:%s attached %d classes\n", dt->mod_name, nc); } } @@ -1277,10 +1279,10 @@ static int ddebug_add_module(struct _ddebug_info *d= i, const char *modname) { struct ddebug_table *dt; =20 - if (!di->num_descs) + if (!di->descs.len) return 0; =20 - v3pr_info("add-module: %s %d sites\n", modname, di->num_descs); + v3pr_info("add-module: %s %d sites\n", modname, di->descs.len); =20 dt =3D kzalloc(sizeof(*dt), GFP_KERNEL); if (dt =3D=3D NULL) { @@ -1294,19 +1296,18 @@ static int ddebug_add_module(struct _ddebug_info *d= i, const char *modname) * this struct ddebug_table. */ dt->mod_name =3D modname; - dt->ddebugs =3D di->descs; - dt->num_ddebugs =3D di->num_descs; + dt->info =3D *di; =20 INIT_LIST_HEAD(&dt->link); =20 - if (di->classes && di->num_classes) + if (di->maps.len) ddebug_attach_module_classes(dt, di); =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); =20 - vpr_info("%3u debug prints in module %s\n", di->num_descs, modname); + vpr_info("%3u debug prints in module %s\n", di->descs.len, modname); return 0; } =20 @@ -1453,10 +1454,10 @@ static int __init dynamic_debug_init(void) char *cmdline; =20 struct _ddebug_info di =3D { - .descs =3D __start___dyndbg, - .classes =3D __start___dyndbg_classes, - .num_descs =3D __stop___dyndbg - __start___dyndbg, - .num_classes =3D __stop___dyndbg_classes - __start___dyndbg_classes, + .descs.start =3D __start___dyndbg_descs, + .maps.start =3D __start___dyndbg_class_maps, + .descs.len =3D __stop___dyndbg_descs - __start___dyndbg_descs, + .maps.len =3D __stop___dyndbg_class_maps - __start___dyndbg_class_maps, }; =20 #ifdef CONFIG_MODULES @@ -1467,7 +1468,7 @@ static int __init dynamic_debug_init(void) } #endif /* CONFIG_MODULES */ =20 - if (&__start___dyndbg =3D=3D &__stop___dyndbg) { + if (&__start___dyndbg_descs =3D=3D &__stop___dyndbg_descs) { if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n"); return 1; @@ -1477,16 +1478,16 @@ static int __init dynamic_debug_init(void) return 0; } =20 - iter =3D iter_mod_start =3D __start___dyndbg; + iter =3D iter_mod_start =3D __start___dyndbg_descs; modname =3D iter->modname; i =3D mod_sites =3D mod_ct =3D 0; =20 - for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { + for (; iter < __stop___dyndbg_descs; iter++, i++, mod_sites++) { =20 if (strcmp(modname, iter->modname)) { mod_ct++; - di.num_descs =3D mod_sites; - di.descs =3D iter_mod_start; + di.descs.len =3D mod_sites; + di.descs.start =3D iter_mod_start; ret =3D ddebug_add_module(&di, modname); if (ret) goto out_err; @@ -1496,8 +1497,8 @@ static int __init dynamic_debug_init(void) iter_mod_start =3D iter; } } - di.num_descs =3D mod_sites; - di.descs =3D iter_mod_start; + di.descs.len =3D mod_sites; + di.descs.start =3D iter_mod_start; ret =3D ddebug_add_module(&di, modname); if (ret) goto out_err; @@ -1507,8 +1508,8 @@ static int __init dynamic_debug_init(void) i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), (int)((i * sizeof(struct _ddebug)) >> 10)); =20 - if (di.num_classes) - v2pr_info(" %d builtin ddebug class-maps\n", di.num_classes); + if (di.maps.len) + v2pr_info(" %d builtin ddebug class-maps\n", di.maps.len); =20 /* now that ddebug tables are loaded, process all boot args * again to find and activate queries given in dyndbg params. diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 396144cf351b..8434f70b51bb 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -41,7 +41,7 @@ module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 06= 00); */ #define DD_SYS_WRAP(_model, _flags) \ static unsigned long bits_##_model; \ - static struct ddebug_class_param _flags##_model =3D { \ + static struct _ddebug_class_param _flags##_model =3D { \ .bits =3D &bits_##_model, \ .flags =3D #_flags, \ .map =3D &map_##_model, \ --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) (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 60D9E368263 for ; Tue, 18 Nov 2025 20:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497164; cv=none; b=EnBZ7DEkaazDJMziRdy8tifKaJv5N2DFv4fY+8DEDeCs4NRzHPHPPiTX+9SI21JIKncyuLDxWAhMIUILQBgYIyYhIp/YvkvyrqUK6+f22vwChzc9Wzp2VaUKzWeaTf0rn8kIaupBGtCEbRjetL+/ENEy/a68jhWpO40LzlbJo5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497164; c=relaxed/simple; bh=yb+YFqvhtiDI5igd/yCrKOrTyeTZhoGGv/vnhpqEfRc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mu2ews1wIWLyfasBqnbhLGYWVrogPYTIeXcKktnygPphwaSe6XumZCPDFBr4alAcw9eiQuOwVIZM62RwDG+wuCTkEM1vm+0wErtn2Cnx2tFOfEjMPY3i2neWHvj4ZCrdQVsK+Ctj2J+uvaJaLppKebk65uPBlBob5f8pSqdgLrU= 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=lAqjO6y6; arc=none smtp.client-ip=209.85.166.51 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="lAqjO6y6" Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-9490a482b7bso108349939f.1 for ; Tue, 18 Nov 2025 12:19:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497158; x=1764101958; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=57tC5fcXib20YlGSpjepRBmCcERyspoSOH53yUhNSS8=; b=lAqjO6y6U1BQpQDR2TKs2b1vsuZMIn4EDXVvtdf5G0AIajecXaS36ab6b7WHUSRWuo KiXkcYnx4PddZ0Cl8Gd9I7s3/cjvGS1jZfWjYqKEmUo0ZbVBlp3WvZ9FKp0lafK7mQV0 C/nEqG0nDA9byFp0oacgfgX+SkGb2KU3BlWB8t0Ax2UuKt3vfoL54+SaWuGbRT0/AbEF 69wYsiGFPl1vHEHCNkCN1PRrIFGYVRYcDzvnoYOSRNQfQTsEduL3bMpiSE3c4kirXBAd gjs3cnklCzaN70XCyPi9VGse0wW4VhV/kS6PYyijaRBHqQLXQVLHgxvU6PrHGYmIcdYu qC0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497158; x=1764101958; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=57tC5fcXib20YlGSpjepRBmCcERyspoSOH53yUhNSS8=; b=FJllny1zFxUIqff7Q+dRdZUk986EOWO5Nm/ZInNjmoOzrtBvT6cGLhAiOhuWgderjM UWoFlb6Pa/sV7dmHan9QLXxjwQhytETkOj4wkUbBh7l3qzNaYKfNk0hKWwTXTo9WNRyW sfhftbg8MH8wPwLb0cjKpApHIuu2oyC89El67TmRm80rYaiudUsnsy7Sm3BRF5xu+3BC PXQAbWgPpUBihbU8SSdMQnZwL27MMi3xFxI4PmW8oSrkuy05UhwWD4GWqruogVlQq+wG lVlUw4GXwoNYjUxsz2dmCJ6xTjBsFQ0TYcadXnXfAinRb0Fg8idn7NHJ1QAeVDWt5OPk nMFQ== X-Gm-Message-State: AOJu0YxsZ1yAh3tRVCjK1rnEspABby5S3JgivspQc1gzsl8fRJMOawfU QbaXBqeDuqDpt63iYVn0LkxU+IZsXHZ7VcaptRcL6fL5WadeXfgI6PHMclPQcI4M X-Gm-Gg: ASbGnctipOe3182YAlZ2fi4DIZUkDTYOicdzCNSpwf/gVrg3u1Jgsp5amJXkiF8Hg2A C8yPsAIH6XguE/IolObtTh8IVDAZOkdU3QCsaazTx8DQCaXYjHCN/VeIlSsnLbhwZNl3iG2JkD9 O9CIi/46KFflelJrVB5fl2+7CTNoeLVQ3vGAC4K1d/7ZcbEMljmqJcVSDVTLA5wiRg8NQRMfQyb SujGEJamwjSrd5lBYm6TKdTvqyXVsKXloNa/4+LniylbfhDB3mpuBNxlWp9qg7gUoWyIcNUy9QQ FImpdsHU9VeRNtS4l1i+dsg0AO4zGeBpmxqWv32qqzap/ei2EfDz4pE+N0T4yQuZLRJ1tMuWdhK maBAinlt5No5UjN0vC4Ziccovz0v3sZqAxMDjdTPSgueIU0u5uz5eKK0XBK2uHf3NviPjV/2Ho1 usLvfWQ//bOh+mVvfbIj0KZQCsuc5BfWCUbJC3fEr3erbEHlxxKS8nD+IoWxEYTwKxEKFmrxUs8 2XLd0c1p34JJF9h X-Google-Smtp-Source: AGHT+IHIJhkaq+ArqTWu43f/20jDi7p+m5ELZRQSWIDsTyPD3eZ+/5krpCWNcCzDlN6i90tbPAji5w== X-Received: by 2002:a05:6602:15cb:b0:949:93e:bc0 with SMTP id ca18e2360f4ac-949093e267amr992147039f.8.1763497158526; Tue, 18 Nov 2025 12:19:18 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:17 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 16/31] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module Date: Tue, 18 Nov 2025 13:18:26 -0700 Message-ID: <20251118201842.1447666-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" The body of ddebug_attach_module_classes() is dominated by a code-block that finds the contiguous subrange of classmaps matching on modname, and saves it into the ddebug_table's info record. Implement this block in a macro to accommodate different component vectors in the "box" (as named in the for_subvec macro). We will reuse this macro shortly. And hoist its invocation out of ddebug_attach_module_classes() up into ddebug_add_module(). This moves the filtering step up closer to dynamic_debug_init(), which already segments the builtin pr_debug descriptors on their mod_name boundaries. Signed-off-by: Jim Cromie --- Ive review checkpatch complaints: all are lvalues, and not issues. CHECK: Macro argument reuse '_dst' - possible side-effects? CHECK: Macro argument reuse '_sp' - possible side-effects? CHECK: Macro argument reuse '_vec' - possible side-effects? --- lib/dynamic_debug.c | 57 ++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c9377a444fc8..49de591f036a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -170,8 +170,8 @@ static void vpr_info_dq(const struct ddebug_query *quer= y, const char *msg) } =20 static struct _ddebug_class_map *ddebug_find_valid_class(struct ddebug_tab= le const *dt, - const char *class_string, - int *class_id) + const char *class_string, + int *class_id) { struct _ddebug_class_map *map; int i, idx; @@ -1247,30 +1247,35 @@ static const struct proc_ops proc_fops =3D { =20 static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) { - struct _ddebug_class_map *cm; - int i, nc =3D 0; - - /* - * Find this module's classmaps in a subrange/wholerange of - * the builtin/modular classmap vector/section. Save the start - * and length of the subrange at its edges. - */ - for_subvec(i, cm, di, maps) { - if (!strcmp(cm->mod_name, dt->mod_name)) { - if (!nc) { - v2pr_info("start subrange, class[%d]: module:%s base:%d len:%d ty:%d\n= ", - i, cm->mod_name, cm->base, cm->length, cm->map_type); - dt->info.maps.start =3D cm; - } - nc++; - } - } - if (nc) { - dt->info.maps.len =3D nc; - vpr_info("module:%s attached %d classes\n", dt->mod_name, nc); - } + vpr_info("module:%s attached %d classes\n", dt->mod_name, dt->info.maps.l= en); } =20 +/* + * Walk the @_box->@_vec member, over @_vec.start[0..len], and find + * the contiguous subrange of elements matching on ->mod_name. Copy + * the subrange into @_dst. This depends on vars defd by caller. + * + * @_i: caller provided counter var, init'd by macro + * @_sp: cursor into @_vec. + * @_box: contains member named @_vec + * @_vec: member-name of a type with: .start .len fields. + * @_dst: an array-ref: to remember the module's subrange + */ +#define dd_mark_vector_subrange(_i, _dst, _sp, _box, _vec) ({ \ + typeof(_dst) __dst =3D (_dst); \ + int __nc =3D 0; \ + for_subvec(_i, _sp, _box, _vec) { \ + if (!strcmp((_sp)->mod_name, (_dst)->mod_name)) { \ + if (!__nc++) \ + (__dst)->info._vec.start =3D (_sp); \ + } else { \ + if (__nc) \ + break; /* end of consecutive matches */ \ + } \ + } \ + (__dst)->info._vec.len =3D __nc; \ +}) + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1278,6 +1283,8 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, struct _ddebug static int ddebug_add_module(struct _ddebug_info *di, const char *modname) { struct ddebug_table *dt; + struct _ddebug_class_map *cm; + int i; =20 if (!di->descs.len) return 0; @@ -1300,6 +1307,8 @@ static int ddebug_add_module(struct _ddebug_info *di,= const char *modname) =20 INIT_LIST_HEAD(&dt->link); =20 + dd_mark_vector_subrange(i, dt, cm, di, maps); + if (di->maps.len) ddebug_attach_module_classes(dt, di); =20 --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (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 B43FC2E0402 for ; Tue, 18 Nov 2025 20:19:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497167; cv=none; b=Qk9fm+En4lG4PXD3RvAWcZv//estrjow5jcu4m+Lynlo2EYgN/jYFML4QhHej7BtVVIL7VhO2E3Liqr91Pcf67c8XHikeH8ZWgORTt4jo9uVvIMd+EvlIJ8l7yB8bgTvDhebAyDdOVFW76EZdO7+mzaM8Hin5U6TZvicpsBEx4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497167; c=relaxed/simple; bh=2hQ9JNXCdcoJrsjqRtLX+egssbwP0g8MkV2bxONACaA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ux8xO4+R+QCXNYm5tobIvd2HO+B+ZQbqd1ugrtxhlNkVKGMU0TvYqT6nZ09tyH37yZKGSBpg8d7Pp9U8rmaw+Dqms2YWkJJUM59F95OXtxBulFDWaDo83FfnJ2pnRayYVz3+/s7YeIe4Ghpy8VWS5YbMAe3RtF26s+zoLtRtFYs= 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=RKI6UeJS; arc=none smtp.client-ip=209.85.166.42 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="RKI6UeJS" Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-9491ba846b2so45938739f.2 for ; Tue, 18 Nov 2025 12:19:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497160; x=1764101960; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7a7yVeAfR1EVEVSwMX5+J7VwmlWrIPE44SjKvRUAilI=; b=RKI6UeJSBJmOJczLnKjJBGU1Hy0JFyljQMyb4NUt5nvEBc3yhbETy2t3QPhDeTLKXN jG+ng1XqS84qJ3w8mz+oaeRTi39fHDxsa0osOTnLaTjCGtxjNytdOovSQU8DSOBJO1/A VIrB+meVY4t3SIunpZfxU8WrsAsLsj6who4Bq3bDhHXK1uuocaoTDj6TPig+HzwzKJXw CtAsXzL8gIejyrvi1qeh3QVXhXkZ/ewHDRwFapvfIm+IOO4mz5Uhtc5UyLJx7q66KUAM 2ksvt7wTBtRVoRPV+mWtUGNTg3QYP851PnM/Gry/vE3sKeWB6Zt9IrSOuUxMYpt31aIz 1yCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497160; x=1764101960; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7a7yVeAfR1EVEVSwMX5+J7VwmlWrIPE44SjKvRUAilI=; b=E3yLs6rzWI7VlSTm7ucMLYo7Ge2z+47san2rIIAuYN2VH7XYrYHv6p0h1mIxXM1WGa dbOsGN698ZnPDQ18+vGkwjYMl63JQAVSLiwyaOU4FwMTFx524A3VR8W0IlIBu5F9wWfd fWFBAxRakBDKxCospoMLr9DOTbOEZ8S6mfvjpRHqJP8D5bUJUkptGu3A1akRU849/Kzt vS8kYwa3gnFBvBJx87MiGY92jodC5xvVzuDMJeOq2Ksig47AKKxYXEczs+MuEbljdiba 4Pt8C/aooAuWZBB2iVbUypgxoqqL0Jd26nxXRZMPAr90WTdoDSAVatqtJe/agWW/Ou42 PsSw== X-Gm-Message-State: AOJu0YzfTZtFu7kir75g+jbEbpZmpKlkTiProl2zTLfOfsM5Qm04j3PL 23bPB8QGdGRYzplOUDJIyiILn0P/W4z7kMMvF5gJ1jP/X0UqihrISnPFv5P2ZZG5 X-Gm-Gg: ASbGncsqhC4rKmMLKDBcdkhMi1vt9xipbeg7hkgxQhz9HvZMtKcqtB8XMHUR1p2ZYv8 wh6IsSlliLygl7Uc4LqgDM8SdjWcYTNwz9TwCZCbnygL67GnNcsL83pNZsBxxplfUXBLBJ6QNRc wkJMIyiMmhyTCE8wq+9a8MD+E7C0MSamfEtQDPwDtymH9/g74/ZKVdZhH1wUIb1jDu7pa7I3ixe ZErxVvj98Xhad8BPYZDzhOGi9x6LUq6OLcSDWAWB8ykyP594cMoKR+UyPx9BZplepxAYMoencga KZRwfnAOHZLu8izBjylLrW1v0Gs82o7rWCeEhkfDH2DGxyM/oPSnhIiM/haxIt5XfmrFyC2hGmF YZ5Kume2sFZAiWoUzqRvf3Z3P995xRd4UkOivc1//rm2yhX/CMKRS96m9qvn1uWjdqesxQ8Kivo o5d66kHv4wNEUanJFr2aQZ5iLmWXYeDPMaOJVhJXaVQtMaqfVY4DnD5Me+DJdlszDscGLJWs79g xfBMw42fyNtWBhF X-Google-Smtp-Source: AGHT+IHztsgt3/fkQp4gqi9bXTY2nV3n2hrYyO+viHqk00qj9yOnDdTzcnF4AOkxe1x/gL8MNUWq8w== X-Received: by 2002:a92:c269:0:b0:433:7900:f1b6 with SMTP id e9e14a558f8ab-4348c87af7emr212112075ab.7.1763497159637; Tue, 18 Nov 2025 12:19:19 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:18 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 17/31] dyndbg: move mod_name down from struct ddebug_table to _ddebug_info Date: Tue, 18 Nov 2025 13:18:27 -0700 Message-ID: <20251118201842.1447666-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" struct _ddebug_info already has most of dyndbg's info for a module; push debug_table.mod_name down into it, finishing the encapsulation. This allows refactoring several callchains, passing &_ddebug_info instead of &ddebug_table, and hoisting the "&dt->info" deref up instead of repeating it thru the callchans ddebug_table contains a _ddebug_info member, so its users keep access to mod_name, just now with "->info." added in. In static ddebug_add_module(&di), reinforce the cursor-model by dropping the modname arg, and setting di->mod_name at each caller. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- -v3 more s/dt/di/ internal interface changes -v5 convert class_in_range macro to function --- include/linux/dynamic_debug.h | 1 + lib/dynamic_debug.c | 50 ++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 4775f66e96dd..10f1a2a1bee4 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -107,6 +107,7 @@ struct _ddebug_class_maps { }; =20 struct _ddebug_info { + const char *mod_name; struct _ddebug_descs descs; struct _ddebug_class_maps maps; }; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 49de591f036a..e7a6ce260c34 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -46,7 +46,6 @@ extern struct _ddebug_class_map __stop___dyndbg_class_map= s[]; =20 struct ddebug_table { struct list_head link; - const char *mod_name; struct _ddebug_info info; }; =20 @@ -253,10 +252,11 @@ static int ddebug_change(const struct ddebug_query *q= uery, /* search for matching ddebugs */ mutex_lock(&ddebug_lock); list_for_each_entry(dt, &ddebug_tables, link) { + struct _ddebug_info *di =3D &dt->info; =20 /* match against the module name */ if (query->module && - !match_wildcard(query->module, dt->mod_name)) + !match_wildcard(query->module, di->mod_name)) continue; =20 if (query->class_string) { @@ -268,8 +268,8 @@ static int ddebug_change(const struct ddebug_query *que= ry, valid_class =3D _DPRINTK_CLASS_DFLT; } =20 - for (i =3D 0; i < dt->info.descs.len; i++) { - struct _ddebug *dp =3D &dt->info.descs.start[i]; + for (i =3D 0; i < di->descs.len; i++) { + struct _ddebug *dp =3D &di->descs.start[i]; =20 if (!ddebug_match_desc(query, dp, valid_class)) continue; @@ -289,7 +289,7 @@ static int ddebug_change(const struct ddebug_query *que= ry, #endif v4pr_info("changed %s:%d [%s]%s %s =3D> %s\n", trim_prefix(dp->filename), dp->lineno, - dt->mod_name, dp->function, + di->mod_name, dp->function, ddebug_describe_flags(dp->flags, &fbuf), ddebug_describe_flags(newflags, &nbuf)); dp->flags =3D newflags; @@ -1156,12 +1156,12 @@ static bool ddebug_class_in_range(const int class_i= d, const struct _ddebug_class class_id < map->base + map->length); } =20 -static const char *ddebug_class_name(struct ddebug_table *dt, struct _ddeb= ug *dp) +static const char *ddebug_class_name(struct _ddebug_info *di, struct _ddeb= ug *dp) { struct _ddebug_class_map *map; int i; =20 - for_subvec(i, map, &dt->info, maps) + for_subvec(i, map, di, maps) if (ddebug_class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 @@ -1189,13 +1189,13 @@ static int ddebug_proc_show(struct seq_file *m, voi= d *p) =20 seq_printf(m, "%s:%u [%s]%s =3D%s \"", trim_prefix(dp->filename), dp->lineno, - iter->table->mod_name, dp->function, + iter->table->info.mod_name, dp->function, ddebug_describe_flags(dp->flags, &flags)); seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); seq_putc(m, '"'); =20 if (dp->class_id !=3D _DPRINTK_CLASS_DFLT) { - class =3D ddebug_class_name(iter->table, dp); + class =3D ddebug_class_name(&iter->table->info, dp); if (class) seq_printf(m, " class:%s", class); else @@ -1247,7 +1247,7 @@ static const struct proc_ops proc_fops =3D { =20 static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) { - vpr_info("module:%s attached %d classes\n", dt->mod_name, dt->info.maps.l= en); + vpr_info("module:%s attached %d classes\n", dt->info.mod_name, dt->info.m= aps.len); } =20 /* @@ -1265,7 +1265,7 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, struct _ddebug typeof(_dst) __dst =3D (_dst); \ int __nc =3D 0; \ for_subvec(_i, _sp, _box, _vec) { \ - if (!strcmp((_sp)->mod_name, (_dst)->mod_name)) { \ + if (!strcmp((_sp)->mod_name, (__dst)->info.mod_name)) { \ if (!__nc++) \ (__dst)->info._vec.start =3D (_sp); \ } else { \ @@ -1280,7 +1280,7 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, struct _ddebug * Allocate a new ddebug_table for the given module * and add it to the global list. */ -static int ddebug_add_module(struct _ddebug_info *di, const char *modname) +static int ddebug_add_module(struct _ddebug_info *di) { struct ddebug_table *dt; struct _ddebug_class_map *cm; @@ -1289,20 +1289,19 @@ static int ddebug_add_module(struct _ddebug_info *d= i, const char *modname) if (!di->descs.len) return 0; =20 - v3pr_info("add-module: %s %d sites\n", modname, di->descs.len); + v3pr_info("add-module: %s %d sites\n", di->mod_name, di->descs.len); =20 dt =3D kzalloc(sizeof(*dt), GFP_KERNEL); if (dt =3D=3D NULL) { - pr_err("error adding module: %s\n", modname); + pr_err("error adding module: %s\n", di->mod_name); return -ENOMEM; } /* - * For built-in modules, name lives in .rodata and is - * immortal. For loaded modules, name points at the name[] - * member of struct module, which lives at least as long as - * this struct ddebug_table. + * For built-in modules, name (as supplied in di by its + * callers) lives in .rodata and is immortal. For loaded + * modules, name points at the name[] member of struct module, + * which lives at least as long as this struct ddebug_table. */ - dt->mod_name =3D modname; dt->info =3D *di; =20 INIT_LIST_HEAD(&dt->link); @@ -1316,7 +1315,7 @@ static int ddebug_add_module(struct _ddebug_info *di,= const char *modname) list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); =20 - vpr_info("%3u debug prints in module %s\n", di->descs.len, modname); + vpr_info("%3u debug prints in module %s\n", di->descs.len, di->mod_name); return 0; } =20 @@ -1379,7 +1378,7 @@ static int ddebug_remove_module(const char *mod_name) =20 mutex_lock(&ddebug_lock); list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) { - if (dt->mod_name =3D=3D mod_name) { + if (dt->info.mod_name =3D=3D mod_name) { ddebug_table_free(dt); ret =3D 0; break; @@ -1399,7 +1398,8 @@ static int ddebug_module_notify(struct notifier_block= *self, unsigned long val, =20 switch (val) { case MODULE_STATE_COMING: - ret =3D ddebug_add_module(&mod->dyndbg_info, mod->name); + mod->dyndbg_info.mod_name =3D mod->name; + ret =3D ddebug_add_module(&mod->dyndbg_info); if (ret) WARN(1, "Failed to allocate memory: dyndbg may not work properly.\n"); break; @@ -1497,7 +1497,8 @@ static int __init dynamic_debug_init(void) mod_ct++; di.descs.len =3D mod_sites; di.descs.start =3D iter_mod_start; - ret =3D ddebug_add_module(&di, modname); + di.mod_name =3D modname; + ret =3D ddebug_add_module(&di); if (ret) goto out_err; =20 @@ -1508,7 +1509,8 @@ static int __init dynamic_debug_init(void) } di.descs.len =3D mod_sites; di.descs.start =3D iter_mod_start; - ret =3D ddebug_add_module(&di, modname); + di.mod_name =3D modname; + ret =3D ddebug_add_module(&di); if (ret) goto out_err; =20 --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (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 5DE0D2FBDF2 for ; Tue, 18 Nov 2025 20:19:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497168; cv=none; b=ufLloC591tC/RCsldm6sphE7NdesMh/tdXKAEAZSyx5MFGRmJ6Pd48rNLa1tMbc/hH5G7O1okL5DCPaU71HykPp04tjsKPWFqSC6f2Sq/VwrDIWmvFgVTD6d6wbJz5KojvUYfazgQwuW6ACLLAYFAl+bfrLlTIzpalVGJZflttE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497168; c=relaxed/simple; bh=h4hGK8NXdkFYKPnhl/r55PWj/OBPe3aZBRJTV3ozSFE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aHY/iIb5929w9HVrCgeHXoXZlRI7i60mX3veTDQc1LTq+nEikAJn5T1wUJg4Sc3e+Yo7K9YBhBbTU3Vzp+N5advT7ZnBx/VL324t/8YbWA4/C8XRW77+yHVODp9Bl3iAtdv1Kwb00rWucp1oyDrMjq1qb6RxO+vZOS05cra1rQw= 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=Tjsq+O7L; arc=none smtp.client-ip=209.85.166.45 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="Tjsq+O7L" Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-948da744f87so207756539f.1 for ; Tue, 18 Nov 2025 12:19:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497161; x=1764101961; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R8rJPBpgb/y9MW7yrHalBuru+/aWXTBfYFUpRP2Lj64=; b=Tjsq+O7LxWgdIqw5tYq0Ujg+wjZ8eQBaQWsJpcEp9BdRc8qjkPelNgpW4IozahCb+U zxpBSkHWD6KojlNLfM34BmdcgrD8BcS3qmiQy8FC8+xTPxMwJjsmISoaNUPhivl+KeUe rjcYiZEQgU/mVbjvxoDf7MHoEQ0aNwW6WUIfJv09MclnsoaDkuFGDGzbVtiSozQaWeZf 0tG5R8flbALzjMDWkHvDpDbgrbQsmnIHWd3jZ2BLrN0Y3egFyb9+esqmrvKU1LNquPEz GOe3RVwd8E9hWAdQU9FzMbFkAROnaOraPqcZp/osithM9J4kFThdF7l6byuCprXazOLw JIjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497161; x=1764101961; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=R8rJPBpgb/y9MW7yrHalBuru+/aWXTBfYFUpRP2Lj64=; b=vnZtjuUs873DVrSjD3O4AyiA8Y6CCg991wX3+NoA4QEd4HhearPMGbaTNl+UAoFwXZ c0e++28EvLG1pijpxQFyMRkvSGO+iMmT7/j3X9bpNIpLfwVUZyeVefD6L+yU4gcXBEyB 6s89L1o7wJRYpvgzHUbSwt0KGhCe8q3gUI8k6s2uvjvAohYqaG9mdoRizOCq2p0WWWpa ptZci+NuwHK0GWCJlBYgyFbYg/cG0qU8nO+1kMWknv0EjuJmu5TKwGRMPBEqgwl4l2Ft eKjxcrZOPGRhdfJvi03cRbi1soil/phkCIJ7Pc/8qX6dtLsKvUmdU/qnJiDCtZa2rHzB BrkA== X-Gm-Message-State: AOJu0YyjRS5pbB16U3s3cva6sa9sQw58uZreMtrN03pqveBhXR4YEPGx kvYh9MaHiTfx5+NZmwSDdleck+WspRF7jD4R1vbVYCtqaJlXAIIO0NzjkdrKqq55 X-Gm-Gg: ASbGncsgmISsoyP7aUqv+JOjtjMaXRGFhbtDo0EZyM9etFHP/Qlu3MuFdWYL6AdnH3+ 3QLzECTMKEyx4pMk5yXgvxikJZ3vvevqmR4xxp/r7PGPx5iXFBZGhmFSgOLODv2THAme8Rd07+b FT42Is0DzTSXVja/T/rbVviVtJOHyoYLqaKvErCu8aY+pBuV1onioTnPYwudTz8z+TVauM3re+1 kkXzKJrDQpE5Q5v4X+PPq+qeooP+OLHEx9AlOl28zY9Z4qgWjTUovCXjfMs9eQbf2mV40HAvt9L /ZRM1+ZA5jE9QaVe2MOR3RhyskVg6k6VgY56feBzidulTdebM1jmtipPFQ9AbH1AQikYAkfXNGl R23NwpfHsBl7zqA8tIthhgiCjtLWdP/ab2WmukEzzjLSBTIKBeozVqN/5KswUGvUqesGv9cGDTc XUw92YbjIW/gbedRc0Cpph/datIeLZ2LiGZCL8nS41eG5xmWNbWUP/1GUVpfbpAUc15HY= X-Google-Smtp-Source: AGHT+IG942AHn26XRKkPHJltlQxdCJPyc6nBp8jIQdzK9uIBaU9Jt6nAf8x/PnXAISpYvg9DhYREDw== X-Received: by 2002:a05:6602:29c3:b0:945:ab97:6bbc with SMTP id ca18e2360f4ac-948e0ce6590mr2100241639f.6.1763497160887; Tue, 18 Nov 2025 12:19:20 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:20 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 18/31] dyndbg-API: remove DD_CLASS_TYPE_(DISJOINT|LEVEL)_NAMES and code Date: Tue, 18 Nov 2025 13:18:28 -0700 Message-ID: <20251118201842.1447666-19-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" Remove the DD_CLASS_TYPE_*_NAMES classmap types and code. These 2 classmap types accept class names at the PARAM interface, for example: echo +DRM_UT_CORE,-DRM_UT_KMS > /sys/module/drm/parameters/debug_names The code works, but its only used by test-dynamic-debug, and wasn't asked for by anyone else, so reduce LOC & test-surface; simplify things. Also rename enum class_map_type to enum ddebug_class_map_type. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 23 ++------ lib/dynamic_debug.c | 102 +++------------------------------- lib/test_dynamic_debug.c | 26 --------- 3 files changed, 14 insertions(+), 137 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 10f1a2a1bee4..d543b84d447e 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -58,27 +58,16 @@ struct _ddebug { #endif } __attribute__((aligned(8))); =20 -enum class_map_type { +enum ddebug_class_map_type { DD_CLASS_TYPE_DISJOINT_BITS, /** - * DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, one per bit. - * expecting hex input. Built for drm.debug, basis for other types. + * DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, mapped to bits[0= ..N]. + * Expects hex input. Built for drm.debug, basis for other types. */ DD_CLASS_TYPE_LEVEL_NUM, /** - * DD_CLASS_TYPE_LEVEL_NUM: input is numeric level, 0-N. - * N turns on just bits N-1 .. 0, so N=3D0 turns all bits off. - */ - DD_CLASS_TYPE_DISJOINT_NAMES, - /** - * DD_CLASS_TYPE_DISJOINT_NAMES: input is a CSV of [+-]CLASS_NAMES, - * classes are independent, like _DISJOINT_BITS. - */ - DD_CLASS_TYPE_LEVEL_NAMES, - /** - * DD_CLASS_TYPE_LEVEL_NAMES: input is a CSV of [+-]CLASS_NAMES, - * intended for names like: INFO,DEBUG,TRACE, with a module prefix - * avoid EMERG,ALERT,CRIT,ERR,WARNING: they're not debug + * DD_CLASS_TYPE_LEVEL_NUM: input is numeric level, 0..N. + * Input N turns on bits 0..N-1 */ }; =20 @@ -88,7 +77,7 @@ struct _ddebug_class_map { const char **class_names; const int length; const int base; /* index of 1st .class_id, allows split/shared space */ - enum class_map_type map_type; + enum ddebug_class_map_type map_type; }; =20 /* diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index e7a6ce260c34..e5522fea49bb 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -667,76 +667,6 @@ static int ddebug_apply_class_bitmap(const struct _dde= bug_class_param *dcp, =20 #define CLASSMAP_BITMASK(width) ((1UL << (width)) - 1) =20 -/* accept comma-separated-list of [+-] classnames */ -static int param_set_dyndbg_classnames(const char *instr, const struct ker= nel_param *kp) -{ - const struct _ddebug_class_param *dcp =3D kp->arg; - const struct _ddebug_class_map *map =3D dcp->map; - unsigned long curr_bits, old_bits; - char *cl_str, *p, *tmp; - int cls_id, totct =3D 0; - bool wanted; - - cl_str =3D tmp =3D kstrdup_and_replace(instr, '\n', '\0', GFP_KERNEL); - if (!tmp) - return -ENOMEM; - - /* start with previously set state-bits, then modify */ - curr_bits =3D old_bits =3D *dcp->bits; - vpr_info("\"%s\" > %s:0x%lx\n", cl_str, KP_NAME(kp), curr_bits); - - for (; cl_str; cl_str =3D p) { - p =3D strchr(cl_str, ','); - if (p) - *p++ =3D '\0'; - - if (*cl_str =3D=3D '-') { - wanted =3D false; - cl_str++; - } else { - wanted =3D true; - if (*cl_str =3D=3D '+') - cl_str++; - } - cls_id =3D match_string(map->class_names, map->length, cl_str); - if (cls_id < 0) { - pr_err("%s unknown to %s\n", cl_str, KP_NAME(kp)); - continue; - } - - /* have one or more valid class_ids of one *_NAMES type */ - switch (map->map_type) { - case DD_CLASS_TYPE_DISJOINT_NAMES: - /* the +/- pertains to a single bit */ - if (test_bit(cls_id, &curr_bits) =3D=3D wanted) { - v3pr_info("no change on %s\n", cl_str); - continue; - } - curr_bits ^=3D BIT(cls_id); - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, *dcp->bits, NULL); - *dcp->bits =3D curr_bits; - v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, - map->class_names[cls_id]); - break; - case DD_CLASS_TYPE_LEVEL_NAMES: - /* cls_id =3D N in 0..max. wanted +/- determines N or N-1 */ - old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); - curr_bits =3D CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); - - totct +=3D ddebug_apply_class_bitmap(dcp, &curr_bits, old_bits, NULL); - *dcp->lvl =3D (cls_id + (wanted ? 1 : 0)); - v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, - map->class_names[cls_id], old_bits, curr_bits); - break; - default: - pr_err("illegal map-type value %d\n", map->map_type); - } - } - kfree(tmp); - vpr_info("total matches: %d\n", totct); - return 0; -} - static int param_set_dyndbg_module_classes(const char *instr, const struct kernel_param *kp, const char *mod_name) @@ -745,29 +675,17 @@ static int param_set_dyndbg_module_classes(const char= *instr, const struct _ddebug_class_map *map =3D dcp->map; unsigned long inrep, new_bits, old_bits; int rc, totct =3D 0; - - switch (map->map_type) { - - case DD_CLASS_TYPE_DISJOINT_NAMES: - case DD_CLASS_TYPE_LEVEL_NAMES: - /* handle [+-]classnames list separately, we are done here */ - return param_set_dyndbg_classnames(instr, kp); - - case DD_CLASS_TYPE_DISJOINT_BITS: - case DD_CLASS_TYPE_LEVEL_NUM: - /* numeric input, accept and fall-thru */ - rc =3D kstrtoul(instr, 0, &inrep); - if (rc) { - pr_err("expecting numeric input: %s > %s\n", instr, KP_NAME(kp)); - return -EINVAL; - } - break; - default: - pr_err("%s: bad map type: %d\n", KP_NAME(kp), map->map_type); + char *nl; + + rc =3D kstrtoul(instr, 0, &inrep); + if (rc) { + nl =3D strchr(instr, '\n'); + if (nl) + *nl =3D '\0'; + pr_err("expecting numeric input, not: %s > %s\n", instr, KP_NAME(kp)); return -EINVAL; } =20 - /* only _BITS,_NUM (numeric) map-types get here */ switch (map->map_type) { case DD_CLASS_TYPE_DISJOINT_BITS: /* expect bits. mask and warn if too many */ @@ -833,12 +751,8 @@ int param_get_dyndbg_classes(char *buffer, const struc= t kernel_param *kp) const struct _ddebug_class_map *map =3D dcp->map; =20 switch (map->map_type) { - - case DD_CLASS_TYPE_DISJOINT_NAMES: case DD_CLASS_TYPE_DISJOINT_BITS: return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits); - - case DD_CLASS_TYPE_LEVEL_NAMES: case DD_CLASS_TYPE_LEVEL_NUM: return scnprintf(buffer, PAGE_SIZE, "%ld\n", *dcp->lvl); default: diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 8434f70b51bb..9c3e53cd26bd 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -74,13 +74,6 @@ DECLARE_DYNDBG_CLASSMAP(map_disjoint_bits, DD_CLASS_TYPE= _DISJOINT_BITS, 0, DD_SYS_WRAP(disjoint_bits, p); DD_SYS_WRAP(disjoint_bits, T); =20 -/* symbolic input, independent bits */ -enum cat_disjoint_names { LOW =3D 10, MID, HI }; -DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, = 10, - "LOW", "MID", "HI"); -DD_SYS_WRAP(disjoint_names, p); -DD_SYS_WRAP(disjoint_names, T); - /* numeric verbosity, V2 > V1 related */ enum cat_level_num { V0 =3D 14, V1, V2, V3, V4, V5, V6, V7 }; DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, 14, @@ -88,13 +81,6 @@ DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEV= EL_NUM, 14, DD_SYS_WRAP(level_num, p); DD_SYS_WRAP(level_num, T); =20 -/* symbolic verbosity */ -enum cat_level_names { L0 =3D 22, L1, L2, L3, L4, L5, L6, L7 }; -DECLARE_DYNDBG_CLASSMAP(map_level_names, DD_CLASS_TYPE_LEVEL_NAMES, 22, - "L0", "L1", "L2", "L3", "L4", "L5", "L6", "L7"); -DD_SYS_WRAP(level_names, p); -DD_SYS_WRAP(level_names, T); - /* stand-in for all pr_debug etc */ #define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") =20 @@ -102,10 +88,6 @@ static void do_cats(void) { pr_debug("doing categories\n"); =20 - prdbg(LOW); - prdbg(MID); - prdbg(HI); - prdbg(D2_CORE); prdbg(D2_DRIVER); prdbg(D2_KMS); @@ -129,14 +111,6 @@ static void do_levels(void) prdbg(V5); prdbg(V6); prdbg(V7); - - prdbg(L1); - prdbg(L2); - prdbg(L3); - prdbg(L4); - prdbg(L5); - prdbg(L6); - prdbg(L7); } =20 static void do_prints(void) --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) (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 5190936920C for ; Tue, 18 Nov 2025 20:19:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497168; cv=none; b=WA75IFsi9w0W1MHcnxfPA0pzfVAwBai2o9HJiEHmJpPDtK8q3N/QXRwYuAhRpSuRFC8pYfIdPqODOmUwkqXCA0HxMQBplwKRixcJLb3AQtYD1vpoDeYKfZnzSGJXuNNP6lIkOBmzSqQNxANQscttO4lAsC+mQqkbL0fCum00ALU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497168; c=relaxed/simple; bh=R6nvx7hXJgbx4IPs+LRGJrcKg8CBao34tcHl3XG5ugo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WnmsRF3ki6vMsjAgTR/Y7zeCvtN5ft37LlQcjK0lNgjHmWkmiiQG17u6nVM0VCnATsEPQM/lgdkjbWemKlJUuzxCpOjjcRSMKsBXXfkkdAczc/c4XKdjCsQH+qXRD0bgqfo4KfAnp2ntCHWrIHOSI39axmOpMWMlhe9yv3oLfwQ= 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=eZzEkew9; arc=none smtp.client-ip=209.85.166.41 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="eZzEkew9" Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-948614ceac0so236131739f.0 for ; Tue, 18 Nov 2025 12:19:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497162; x=1764101962; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eIFPfxUwt5dyKIx+sQghmkmn9RMIbFi+TLcPp8KxWW8=; b=eZzEkew9AoAByM8IAaLlvOr+u+xsc7X3j9SXu1px8Krhz6jvlzQKC2nzSkdb5gUIj9 mHNdx1pyaXGlqVDhKSTyu9QZKBOSNhb3VbN1QiUWUoZWVF9sAZyy70EmDN0nQrNPDh3D B9Mzf1qUyX2gpZBLWxmqSUzSUhS0lUpa4U6cNYUELu4m6i7I9Qkdp4AarQ8gzRQaAaWM c+NBPNzpi13k5F+XCp2Ch3IzkAqdzlN7cD/fEf6KLg50GjYUiobGrLNhP8+NrJEytWrV rI2aVtIklGQ3oqjc2Ed/MWuuYxhE8FVYrfB3yhNd+WGwOyfBLEhVnRLEKaqqXOrlKksV kTRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497162; x=1764101962; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=eIFPfxUwt5dyKIx+sQghmkmn9RMIbFi+TLcPp8KxWW8=; b=kT/gR2WePveoPRKoG5eXxUUK8oDXE5neDcbG/VGvmBt/Y9Iq8jk6ZTyfFyfOcsMNci kIKedfkjDPbHj0FKDwj+lUl4QlKQZH+bHB2iRI9Xwd3KHpy3hE3PvEOS/YHTuMXVdH2y G21NThPOXjH/yxug3PXYcVzSdmCooxJaNemSEd921dZvwKq4f9vfuTxMGBPjswNgyTCE e1miVovt8dLyQ8M4GJkY1rbkUZcvVYVoBMMpCfIPEvc4TCBu9tsNHjq33YxBAy73b00D aExMLymIUkpjLDL8CcwzAGc850FyBQgRHmQHG8t7CPvSTw+9AOmj6VMZkxL7eoab8FGq 3tOg== X-Gm-Message-State: AOJu0YwrAD0wRCrVYDRr51qaS5jddeJb1PWXGtxeLFowH8v0Po1Lktem HGJ8OnUYDUMhSw8XLemU7guauAcgJZrp6eVDLDy0H9E7rsHB4h1MsEXcvI63uPyu X-Gm-Gg: ASbGncstMlOLZ26Ain4e5qyoddVlrWp4eZUcdwp12YQz9eAoopqBsG7YiHuwmW99X6P 1DeKS/8yfNK1o65uiQ9SDUyvEUIwOHaS9dxO2A5rSPM5qGkZrTHbT7qVQIeik5TcibrfiH1KtWc mEXK5MbCN6rN+jwbNuSbTbLYsRSjY4SotS8V1knTcL9bCUzjcWpgSwe/xjfQ9DvogT5lAUwpdd7 /UosybXVKiB9PrMxqkZFu6Hu+uBHcs/7YkqMcUFU1NVvgjkYofmM7a0p2sDqLFwntxJZiy1lIsv 93qSVSlhs6q7iVwlVowwZ6GHrXeH7in7XlQtnV2cUTCd/zepuWJixwU0ZAV/QcEEkXfhN/o+yLE tLvQx/Sk3vfq/VIFxdid8G7RuCTOvmjXkQZmCMS9EXFDc72RI+SNQC+HQ2xug5fVn79LWlcVHbC GY7EthVLFzmbUrRvPPLWCJeh+p0Ej980uwKbxBoL1F+pjwe0z+PCFRdZSDO63zvNHFR4F6YfV6x qRxwA== X-Google-Smtp-Source: AGHT+IEI2LSmisimkJBuOVOnCJvdHq8ouzk39uV2tCc3rB/WFcT6B8icT2q9mwqd/duhJJhMxJGT8w== X-Received: by 2002:a05:6602:3415:b0:93e:7883:89a6 with SMTP id ca18e2360f4ac-9492b6b55camr23108339f.16.1763497161782; Tue, 18 Nov 2025 12:19:21 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:21 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 19/31] selftests-dyndbg: add a dynamic_debug run_tests target Date: Tue, 18 Nov 2025 13:18:29 -0700 Message-ID: <20251118201842.1447666-20-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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 Add a selftest script for dynamic-debug. The config requires CONFIG_TEST_DYNAMIC_DEBUG=3Dm and CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=3Dm, which tacitly requires either CONFIG_DYNAMIC_DEBUG=3Dy or CONFIG_DYNAMIC_DEBUG_CORE=3Dy ATM this has just basic_tests(), which modify pr_debug() flags in the builtin params module. This means they're available to manipulate and observe the effects in "cat control". This is backported from another feature branch; the support-fns (thx Lukas) have unused features at the moment, they'll get used shortly. The script enables simple virtme-ng testing: [jimc@gandalf b0-ftrace]$ vrun_t virtme-ng 1.32+115.g07b109d doing: vng --name v6.14-rc4-60-gd5f48427de0c \ --user root -v -p 4 -a dynamic_debug.verbose=3D3 V=3D1 \ -- ../tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh virtme: waiting for virtiofsd to start .. And add dynamic_debug to TARGETS, so `make run_tests` sees it properly For the impatient, set TARGETS explicitly: [root@v6 selftests]# make TARGETS=3Ddynamic_debug run_tests make[1]: Nothing to be done for 'all'. TAP version 13 1..1 # timeout set to 45 # selftests: dynamic_debug: dyndbg_selftest.sh # # BASIC_TESTS 95.422122] dyndbg: query 0: 0"=3D_" mod:* ... NOTES check KCONFIG_CONFIG to avoid silly fails Several tests are dependent upon config choices. Lets avoid failing where that is noise. The KCONFIG_CONFIG var exists to convey the config-file around. If the var names a file, read it and extract the relevant CONFIG items, and use them to skip the dependent tests, thus avoiding the fails that would follow, and the disruption to whatever CI is running these selftests. If the envar doesn't name a config-file, ".config" is assumed. CONFIG_DYNAMIC_DEBUG=3Dy: basic-tests() and comma-terminator-tests() test for the presence of the builtin pr_debugs in module/main.c, which I deemed stable and therefore safe to count. That said, the test fails if only CONFIG_DYNAMIC_DEBUG_CORE=3Dy is set. It could be rewritten to test against test-dynamic-debug.ko, but that just trades one config dependence for another. CONFIG_TEST_DYNAMIC_DEBUG=3Dm As written, test_percent_splitting() modprobes test_dynamic_debug, enables several classes, and counts them. It could be re-written to work for the builtin module also, but builtin test modules are not a common or desirable build/config. Signed-off-by: Jim Cromie Co-developed-by: =C5=81ukasz Bartosik Signed-off-by: =C5=81ukasz Bartosik --- -r3 turn off green at end drop config dep on TEST_DYNAMIC_DEBUG, since basic-test uses builtin params --- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + .../testing/selftests/dynamic_debug/Makefile | 9 + tools/testing/selftests/dynamic_debug/config | 7 + .../dynamic_debug/dyndbg_selftest.sh | 257 ++++++++++++++++++ 5 files changed, 275 insertions(+) create mode 100644 tools/testing/selftests/dynamic_debug/Makefile create mode 100644 tools/testing/selftests/dynamic_debug/config create mode 100755 tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh diff --git a/MAINTAINERS b/MAINTAINERS index 97d958c945e4..0db59cca0d4a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8617,6 +8617,7 @@ S: Maintained F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c F: lib/test_dynamic_debug.c +F: tools/testing/selftests/dynamic_debug/* =20 DYNAMIC INTERRUPT MODERATION M: Tal Gilboa diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Mak= efile index 030da61dbff3..3f1a8044e1c0 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -26,6 +26,7 @@ TARGETS +=3D drivers/net/team TARGETS +=3D drivers/net/virtio_net TARGETS +=3D drivers/platform/x86/intel/ifs TARGETS +=3D dt +TARGETS +=3D dynamic_debug TARGETS +=3D efivarfs TARGETS +=3D exec TARGETS +=3D fchmodat2 diff --git a/tools/testing/selftests/dynamic_debug/Makefile b/tools/testing= /selftests/dynamic_debug/Makefile new file mode 100644 index 000000000000..6d06fa7f1040 --- /dev/null +++ b/tools/testing/selftests/dynamic_debug/Makefile @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +# borrowed from Makefile for user memory selftests + +# No binaries, but make sure arg-less "make" doesn't trigger "run_tests" +all: + +TEST_PROGS :=3D dyndbg_selftest.sh + +include ../lib.mk diff --git a/tools/testing/selftests/dynamic_debug/config b/tools/testing/s= elftests/dynamic_debug/config new file mode 100644 index 000000000000..0f906ff53908 --- /dev/null +++ b/tools/testing/selftests/dynamic_debug/config @@ -0,0 +1,7 @@ + +# basic tests ref the builtin params module +CONFIG_DYNAMIC_DEBUG=3Dm + +# more testing is possible with these +# CONFIG_TEST_DYNAMIC_DEBUG=3Dm +# CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=3Dm diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/too= ls/testing/selftests/dynamic_debug/dyndbg_selftest.sh new file mode 100755 index 000000000000..465fad3f392c --- /dev/null +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -0,0 +1,257 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +V=3D${V:=3D0} # invoke as V=3D1 $0 for global verbose +RED=3D"\033[0;31m" +GREEN=3D"\033[0;32m" +YELLOW=3D"\033[0;33m" +BLUE=3D"\033[0;34m" +MAGENTA=3D"\033[0;35m" +CYAN=3D"\033[0;36m" +NC=3D"\033[0;0m" +error_msg=3D"" + +[ -e /proc/dynamic_debug/control ] || { + echo -e "${RED}: this test requires CONFIG_DYNAMIC_DEBUG=3Dy ${NC}" + exit 0 # nothing to test here, no good reason to fail. +} + +# need info to avoid failures due to untestable configs + +[ -f "$KCONFIG_CONFIG" ] || KCONFIG_CONFIG=3D".config" +if [ -f "$KCONFIG_CONFIG" ]; then + echo "# consulting KCONFIG_CONFIG: $KCONFIG_CONFIG" + grep -q "CONFIG_DYNAMIC_DEBUG=3Dy" $KCONFIG_CONFIG ; LACK_DD_BUILTIN= =3D$? + grep -q "CONFIG_TEST_DYNAMIC_DEBUG=3Dm" $KCONFIG_CONFIG ; LACK_TMOD=3D= $? + grep -q "CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD=3Dm" $KCONFIG_CONFIG ; LACK_= TMOD_SUBMOD=3D$? + if [ $V -eq 1 ]; then + echo LACK_DD_BUILTIN: $LACK_DD_BUILTIN + echo LACK_TMOD: $LACK_TMOD + echo LACK_TMOD_SUBMOD: $LACK_TMOD_SUBMOD + fi +else + LACK_DD_BUILTIN=3D0 + LACK_TMOD=3D0 + LACK_TMOD_SUBMOD=3D0 +fi + +function vx () { + echo $1 > /sys/module/dynamic_debug/parameters/verbose +} + +function ddgrep () { + grep $1 /proc/dynamic_debug/control +} + +function doprints () { + cat /sys/module/test_dynamic_debug/parameters/do_prints +} + +function ddcmd () { + exp_exit_code=3D0 + num_args=3D$# + if [ "${@:$#}" =3D "pass" ]; then + num_args=3D$#-1 + elif [ "${@:$#}" =3D "fail" ]; then + num_args=3D$#-1 + exp_exit_code=3D1 + fi + args=3D${@:1:$num_args} + output=3D$((echo "$args" > /proc/dynamic_debug/control) 2>&1) + exit_code=3D$? + error_msg=3D$(echo $output | cut -d ":" -f 5 | sed -e 's/^[[:space:]]*= //') + handle_exit_code $BASH_LINENO $FUNCNAME $exit_code $exp_exit_code +} + +function handle_exit_code() { + local exp_exit_code=3D0 + [ $# =3D=3D 4 ] && exp_exit_code=3D$4 + if [ $3 -ne $exp_exit_code ]; then + echo -e "${RED}: $BASH_SOURCE:$1 $2() expected to exit with code $= exp_exit_code" + [ $3 =3D=3D 1 ] && echo "Error: '$error_msg'" + exit + fi +} + +# $1 - pattern to match, pattern in $1 is enclosed by spaces for a match "= "\s$1\s" +# $2 - number of times the pattern passed in $1 is expected to match +# $3 - optional can be set either to "-r" or "-v" +# "-r" means relaxed matching in this case pattern provided in $1 is= passed +# as is without enclosing it with spaces +# "-v" prints matching lines +# $4 - optional when $3 is set to "-r" then $4 can be used to pass "-v" +function check_match_ct { + pattern=3D"\s$1\s" + exp_cnt=3D0 + + [ "$3" =3D=3D "-r" ] && pattern=3D"$1" + let cnt=3D$(ddgrep "$pattern" | wc -l) + if [ $V -eq 1 ] || [ "$3" =3D=3D "-v" ] || [ "$4" =3D=3D "-v" ]; then + echo -ne "${BLUE}" && ddgrep $pattern && echo -ne "${NC}" + fi + [ $# -gt 1 ] && exp_cnt=3D$2 + if [ $cnt -ne $exp_cnt ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO check failed expected $= exp_cnt on $1, got $cnt" + exit + else + echo ": $cnt matches on $1" + fi +} + +# $1 - trace instance name +# #2 - if > 0 then directory is expected to exist, if <=3D 0 then otherwise +# $3 - "-v" for verbose +function check_trace_instance_dir { + if [ -e /sys/kernel/tracing/instances/$1 ]; then + if [ "$3" =3D=3D "-v" ] ; then + echo "ls -l /sys/kernel/tracing/instances/$1: " + ls -l /sys/kernel/tracing/instances/$1 + fi + if [ $2 -le 0 ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO error trace instanc= e \ + '/sys/kernel/tracing/instances/$1' does exist" + exit + fi + else + if [ $2 -gt 0 ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO error trace instanc= e \ + '/sys/kernel/tracing/instances/$1' does not exist" + exit + fi + fi +} + +function tmark { + echo $* > /sys/kernel/tracing/trace_marker +} + +# $1 - trace instance name +# $2 - line number +# $3 - if > 0 then the instance is expected to be opened, otherwise +# the instance is expected to be closed +function check_trace_instance { + output=3D$(tail -n9 /proc/dynamic_debug/control | grep ": Opened trace= instances" \ + | xargs -n1 | grep $1) + if [ "$output" !=3D $1 ] && [ $3 -gt 0 ]; then + echo -e "${RED}: $BASH_SOURCE:$2 trace instance $1 is not opened" + exit + fi + if [ "$output" =3D=3D $1 ] && [ $3 -le 0 ]; then + echo -e "${RED}: $BASH_SOURCE:$2 trace instance $1 is not closed" + exit + fi +} + +function is_trace_instance_opened { + check_trace_instance $1 $BASH_LINENO 1 +} + +function is_trace_instance_closed { + check_trace_instance $1 $BASH_LINENO 0 +} + +# $1 - trace instance directory to delete +# $2 - if > 0 then directory is expected to be deleted successfully, if <= =3D 0 then otherwise +function del_trace_instance_dir() { + exp_exit_code=3D1 + [ $2 -gt 0 ] && exp_exit_code=3D0 + output=3D$((rmdir /sys/kernel/debug/tracing/instances/$1) 2>&1) + exit_code=3D$? + error_msg=3D$(echo $output | cut -d ":" -f 3 | sed -e 's/^[[:space:]]*= //') + handle_exit_code $BASH_LINENO $FUNCNAME $exit_code $exp_exit_code +} + +function error_log_ref { + # to show what I got + : echo "# error-log-ref: $1" + : echo cat \$2 +} + +function ifrmmod { + lsmod | grep $1 2>&1>/dev/null && rmmod $1 +} + +# $1 - text to search for +function search_trace() { + search_trace_name 0 1 $1 +} + +# $1 - trace instance name, 0 for global event trace +# $2 - line number counting from the bottom +# $3 - text to search for +function search_trace_name() { + if [ "$1" =3D "0" ]; then + buf=3D$(cat /sys/kernel/debug/tracing/trace) + line=3D$(tail -$2 /sys/kernel/debug/tracing/trace | head -1 | sed -e = 's/^[[:space:]]*//') + else + buf=3D$(cat /sys/kernel/debug/tracing/instances/$1/trace) + line=3D$(tail -$2 /sys/kernel/debug/tracing/instances/$1/trace | head= -1 | \ + sed -e 's/^[[:space:]]*//') + fi + if [ $2 =3D 0 ]; then + # whole-buf check + output=3D$(echo $buf | grep "$3") + else + output=3D$(echo $line | grep "$3") + fi + if [ "$output" =3D "" ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO search for '$3' fai= led \ + in line '$line' or '$buf'" + exit + fi + if [ $V =3D 1 ]; then + echo -e "${MAGENTA}: search_trace_name in $1 found: \n$output \nin:${= BLUE} $buf ${NC}" + fi +} + +# $1 - error message to check +function check_err_msg() { + if [ "$error_msg" !=3D "$1" ]; then + echo -e "${RED}: $BASH_SOURCE:$BASH_LINENO error message '$error_m= sg' \ + does not match with '$1'" + exit + fi +} + +function basic_tests { + echo -e "${GREEN}# BASIC_TESTS ${NC}" + if [ $LACK_DD_BUILTIN -eq 1 ]; then + echo "SKIP" + return + fi + ddcmd =3D_ # zero everything + check_match_ct =3Dp 0 + + # module params are builtin to handle boot args + check_match_ct '\[params\]' 4 -r + ddcmd module params +mpf + check_match_ct =3Dpmf 4 + + # multi-cmd input, newline separated, with embedded comments + cat <<"EOF" > /proc/dynamic_debug/control + module params =3D_ # clear params + module params +mf # set flags + module params func parse_args +sl # other flags +EOF + check_match_ct =3Dmf 3 + check_match_ct =3Dmfsl 1 + ddcmd =3D_ +} + +tests_list=3D( + basic_tests +) + +# Run tests + +ifrmmod test_dynamic_debug_submod +ifrmmod test_dynamic_debug + +for test in "${tests_list[@]}" +do + $test + echo "" +done +echo -en "${GREEN}# Done on: " +date +echo -en "${NC}" --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (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 6DDE9366DD2 for ; Tue, 18 Nov 2025 20:19:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497168; cv=none; b=kwBT5ruo6sLtqABEVcT/Es9GNYiJUh5f398O9DTEye2EiO/fq1AnuMZifaOoZWrjEad/+wZYAR0emJrm+niiAX9MPmff7/cxKskIAP+mbWL6CQv9Ie6kUxiwEEhG8ndyGPLact5o8uDGujY2iurPErt/SF+kw4GEvnuX323u31M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497168; c=relaxed/simple; bh=i9n9PZ6cDORUwNXDdpR9q3FJjPyYgqk84bfG+v7pbMI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jfpQfWseAAejeIXTYKquF8zNCaQGP8zu/AX1AN+DFSalNp3ot5SmVVGZNoc7lDo0yq51FudFSy+2STX2qLzURaXn9hvYhZx/oFjIMN64T8Jh2K2otarkHAbsHseMZJxxUDwCepzgM0vLogP2tAWNPJJjydyGsN0NfKugwGevR38= 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=HSAKtKHb; arc=none smtp.client-ip=209.85.166.182 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="HSAKtKHb" Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-4330d78f935so38693045ab.2 for ; Tue, 18 Nov 2025 12:19:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497163; x=1764101963; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=soWf0YG/+Srs0WepiWrUk4JAonJuGIy1dByc0giWUH4=; b=HSAKtKHbxpTOxm0sIWjdbaaWli5GPq8kEEwqWaUYE63oPg3f+lltfMdbPSifpvmH4y ahoZpzJ/8IAPF1bWx1WqtWXqgOu+8CN2MFZwu4BFJS3PeBS3yl4OCjeFZK8d3+RmOAjt E14HBWGrbft4RPDf8+hmw8u8mVRsM53DY0087xsYSH1Uadov7/hZ4lSCYOJbbfkeI1T6 D+4lq7/fvFPGRMgyhTrdVb/UWh/0YvSl72IAKYIlccQyUFj99ohGzrfWc0RMjzuIdMKP PuMA7jtd8FSfb+3xglfnyzXkQ7fNKkAN075k4QN6Yf6iESmou2nqTQ1ZUN5gOMPOQ1KW yQvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497163; x=1764101963; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=soWf0YG/+Srs0WepiWrUk4JAonJuGIy1dByc0giWUH4=; b=Nuktog0Wxp07MB4mPlwyJNAilT+zczZuirBYFcV3u+YDhyMB9w5uUoa8v9mxLG+FyX 6kPUdwyuvWgG3e7dv99ikQIromFsXlWXPI4fjiFYm4Q6v1LZBHQ+UDkUUIxr4i0JZxLr 6hQcX+9O0lerS8NF1Ik+tAcBIpOVm61rDrMGerxN5q1n+9DB6xrWaXP/v6UHt52tvFR2 yx+3gigfZFIhdlQXcpPGMqF5rwtQwRW9xuv8+9OlkDLJIMVN/uB14fnHPguSPHdWmYiU WGrAEwgy9SVdp2awZ4QQKn0t5nhgs9iPG+g4x4ksfWcNJ0s5RVabddyrpZ794dskf00b Md+g== X-Gm-Message-State: AOJu0YySWX3dK/5+8hfY4A4ctnRefc0xhLSGx2Zv4pgOYGX0029frKxm U0uO66xRlK5xXisupmmKVTfKgmCQHweCKyYRmZPB3H7nBy1kcciiZW8/XFw3AvCD X-Gm-Gg: ASbGncuBwWzlSufLVcHnd5zgH6Pl6iIaZCnj1E4hdPWL+bu7jpcFePdw1UY72VpjnrB Q1HNRO9CWTjPIxh0FUT70mQFDdYPC/Xcwn95oLXkUhHkmJCtc9VIZGAsJ544GfYBssWU9cfZZXc HCcByGGmA6L+a80csLXghE6glTupsq8cIb0ZuhU3kHkBx5zEwmjaPAkCh4yKbqFgLz6UZ2WwRYL 6BTuBnAVS28KHs2LRvcfy2ylpoHmdQOy9lybDDTboV6jOvaKRohos7vLuioSLIjK6szMBruOAEl CwbvAeGlSWn44uyU+78GzsgAoOtUtfyATQQbfgqeSHwgype1Gi5PNlWbVuR2VpSU2+WUtUCLgGs hBafEPzuJiHivQZY6v+CI4tzgkQ4ufPOAwuYWDC1qHT0IqISkEeXyynhw2EjL7ck5cDu/YNo/HY nN1ufTRgEhQ8jCWkS6e9Wjfj8yYWc1jCZsjBtJaDVUmrxx9gsHSjwEtnfipU6breGfNLB/VTyj0 BMnAQ== X-Google-Smtp-Source: AGHT+IERLZKtgnyjJfukFnqSJ6ABnoOP6yH5yt9IMBZXmZSftzdAMsB5udG44uwdyeCiZqRzEkdbag== X-Received: by 2002:a05:6e02:2282:b0:434:a88d:f80f with SMTP id e9e14a558f8ab-434a88dfaa8mr90252745ab.5.1763497162910; Tue, 18 Nov 2025 12:19:22 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:22 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 20/31] dyndbg: change __dynamic_func_call_cls* macros into expressions Date: Tue, 18 Nov 2025 13:18:30 -0700 Message-ID: <20251118201842.1447666-21-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" The Xe driver's XE_IOCTL_DBG macro calls drm_dbg() from inside an if (expression). This breaks when CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy because the invoked macro has a do-while-0 wrapper, and is not an expression. if (cond && (drm_dbg("expr-form"),1)) { ... do some more stuff } Fix for this usage by changing __dynamic_func_call_cls{,_no_desc} macros into expressions, by replacing the do-while-0s with a ({ }) wrapper. In the common usage, the trailing ';' converts the expression into a statement. drm_dbg("statement form"); Signed-off-by: Jim Cromie --- --- include/linux/dynamic_debug.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index d543b84d447e..c4ebbccca5d1 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -217,20 +217,20 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, * (|_cls): adds in _DPRINT_CLASS_DFLT as needed * (|_no_desc): former gets callsite descriptor as 1st arg (for prdbgs) */ -#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do { \ +#define __dynamic_func_call_cls(id, cls, fmt, func, ...) ({ \ DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ if (DYNAMIC_DEBUG_BRANCH(id)) \ func(&id, ##__VA_ARGS__); \ -} while (0) +}) #define __dynamic_func_call(id, fmt, func, ...) \ __dynamic_func_call_cls(id, _DPRINTK_CLASS_DFLT, fmt, \ func, ##__VA_ARGS__) =20 -#define __dynamic_func_call_cls_no_desc(id, cls, fmt, func, ...) do { \ +#define __dynamic_func_call_cls_no_desc(id, cls, fmt, func, ...) ({ \ DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ if (DYNAMIC_DEBUG_BRANCH(id)) \ func(__VA_ARGS__); \ -} while (0) +}) #define __dynamic_func_call_no_desc(id, fmt, func, ...) \ __dynamic_func_call_cls_no_desc(id, _DPRINTK_CLASS_DFLT, \ fmt, func, ##__VA_ARGS__) --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.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 C5D382FB0BF for ; Tue, 18 Nov 2025 20:19:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497171; cv=none; b=kYUvJOn+gCFtTF6Y7gZdq2sAHi3SZm+yjogexh8UCAPSZZW0t/qEOCV9i5UhA9AMFSNeNmQajOQqy2Bd58KG9CyzAsDkotxzDbe9nFcyNzC/OHFgDqx3MukfO3Dnv98LU1IQzUlF5SEvj0rRm/pss2RZjmzn3qb2V+6cyA0BUoE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497171; c=relaxed/simple; bh=AE5bbKiI3NWxLf7QGNAd1Ux6rbA+Xul/0SJqOOMwzyA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SVUQpek09jlnE4Lmb4WEWtpHEFfpVwesYRGRFPQXQP+xVcsQ0F0563aYyOIS0DbCiD3PNiVJU2k93gOFibe5oJ93IsayxgkjF3fw/qQ6aGLqAQak9A3Ia5R1o46/IC0pGaL15XPty4lQeLrpt9FlR8YvMgWRFrnverxMDTYYNuE= 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=eesUBLr1; arc=none smtp.client-ip=209.85.166.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="eesUBLr1" Received: by mail-io1-f54.google.com with SMTP id ca18e2360f4ac-9486248f01bso211579439f.0 for ; Tue, 18 Nov 2025 12:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497165; x=1764101965; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mct+W783etrQqHLEp3lsatraWMaivkS9bmpWM7woGuQ=; b=eesUBLr1oGQ9q++liWsiy373+fFUv3z97Ad84KLOmbs5eDxsL8bcLMmdvEYt40EBxG LFXDML+Xcup/fR8ZT6MS54uqTi6gkRYEdxUenj/ZzIE5KF+pwEuBpNlfcQxhYKMKuB91 L89f6RT15sZ69wS0Zx5an8uNVEAfCNNYT24hYG9Vus1hzXy0rD7aTCwa8JZpw3B8vJl7 CaaRCYbImy6Pk5a7MAAwn70sdhE+9X5zKnkCb0zUTc6nNtTVlQ/7IVTRejQ8Qecskfp5 UmD2jX7o0XXy4AGmQ2iNTBP04xjqS/QI/Qk/D5mrjQniXSEd0MqyMPD21d5pPzFhRM33 Uj7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497165; x=1764101965; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mct+W783etrQqHLEp3lsatraWMaivkS9bmpWM7woGuQ=; b=S/XrvDVvfg65UozXsmaxxO+TGGShiLN/bk90NmK43CIHncbwNjbIHcdwqVN8sOOKRZ iBeALrL50ZtKrNzqNF1zL/fScGkO2sDYGFH/Rs0zkGB17ipAwOfbb/qAJY7EcIkOx9bu YavfZL5lA94NEDcsTGotb3s2gb3IJD6sAN5qvfhXkbRNVjyOnTK4bMNguLt4am1pHlnb RKqVvhv00Gm55T5wqtP5lUMnoHvVlz9KoISjv9ZkLDpWehQ27sa/AvNmyO0wdSHy8ZC4 Bri9GeRWYZ7l/cnS9WRiWo3UWzCEdyyFlYNkZfrxtQf11Xy2VhSShnA6bo6Z/OZQscBi hDvA== X-Gm-Message-State: AOJu0YxNqKUo6d8rn1x0nNYJysEd0Vq5XOP+srVp9Gsx3bEQSj9iFUV1 GyfrO2GljIizjmnCmkhs8zWXVpREon+tnY4c1wY2o40tAXxyI7bc84rlmWntXI1H X-Gm-Gg: ASbGncvwzE9Slcg49w3mivx7Un9+quTMY8hfa4g8hA9G5yf3ey0ebv2TvZG4ZDGrSa2 4URj3ym31AwCst9pnKWO74se37AdocJxH8relt5GXoqtjHtvdGZtMKsS6rX5usKr6JLW2U5LPyA oHQ4VvtgAwTYJmWWV3N+Lyt+zDKNbuJlxpzXZa+/28mL/xPIx9sA38XwhYN3atjTfyePL+e4dSm avmk2p0DKa5mdeXVb1maR8zlIqicsIOt0+cPw+ZjNA0XGdyQSy7nhOM6INdK7ojmi7L9nPp0wMs 6dti0GbyTQctZ6RHHtOd0du+RefLQp9u+EB67zrOh5ptRBZ65sm0J4sRn8haE2X7ZdbHmL6hXu1 hNMtY40bt7MS8tf6DoJPfdrUqj9BpWkKKXK3XCF4NAOq3Lvsbxel7DNzT91AU85UMWUNSQpW//0 qMn37JFEWpqyuuGpjVo1lF1rRwL3LR2/Az1G89zGwSdVi9U4OWa+MVDoeIu4to3L6i+7W4lZmoi oULYQ== X-Google-Smtp-Source: AGHT+IHGfErc/UWqzrlNN2SxeHnF2N6XWTJgrrIplPow/7P3OT9p7p+77a0rWldrj7UKNVwxvpSLbg== X-Received: by 2002:a05:6602:7215:b0:948:6b99:2247 with SMTP id ca18e2360f4ac-948e0cf7a04mr2165293939f.8.1763497164348; Tue, 18 Nov 2025 12:19:24 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:23 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v6 21/31] dyndbg-API: replace DECLARE_DYNDBG_CLASSMAP Date: Tue, 18 Nov 2025 13:18:31 -0700 Message-ID: <20251118201842.1447666-22-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" commit aad0214f3026 ("dyndbg: add DECLARE_DYNDBG_CLASSMAP macro") DECLARE_DYNDBG_CLASSMAP() has a design error; its usage fails a basic K&R rule: "define once, refer many times". When CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy, it is used across DRM core & drivers; each invocation allocates/inits the classmap understood by that module. They *all* must match for the DRM modules to respond consistently when drm.debug categories are enabled. This is at least a maintenance hassle. Worse, its the root-cause of the CONFIG_DRM_USE_DYNAMIC_DEBUG=3DY regression; its use in both core & drivers obfuscates the 2 roles, muddling the design, yielding an incomplete initialization when modprobing drivers: 1st drm.ko loads, and dyndbg initializes its drm.debug callsites, then a drm-driver loads, but too late for the drm.debug enablement. And that gave us: commit bb2ff6c27bc9 ("drm: Disable dynamic debug as broken") So retire it, replace with 2 macros: DYNAMIC_DEBUG_CLASSMAP_DEFINE - invoked once from core - drm.ko DYNAMIC_DEBUG_CLASSMAP_USE - from all drm drivers and helpers. NB: name-space de-noise DYNAMIC_DEBUG_CLASSMAP_DEFINE: this reworks DECLARE_DYNDBG_CLASSMAP, basically by dropping the static qualifier on the classmap, and exporting it instead. DYNAMIC_DEBUG_CLASSMAP_USE: then refers to the exported var by name: used from drivers, helper-mods lets us drop the repetitive "classname" declarations fixes 2nd-defn problem creates a ddebug_class_user record in new __dyndbg_class_users section new section is scanned "differently" DECLARE_DYNDBG_CLASSMAP is preserved temporarily, to decouple DRM adaptation work and avoid compile-errs before its done. The DEFINE,USE distinction, and the separate classmap-use record, allows dyndbg to initialize the driver's & helper's drm.debug callsites separately after each is modprobed. Basically, the classmap initial scan is repeated for classmap-users. dyndbg's existing __dyndbg_classes[] section does: . catalogs the module's classmaps . tells dyndbg about them, allowing >control . DYNAMIC_DEBUG_CLASSMAP_DEFINE creates section records. . we rename it to: __dyndbg_class_maps[] this patch adds __dyndbg_class_users[] section: . catalogs users of classmap definitions from elsewhere . authorizes dyndbg to >control user's class'd prdbgs . DYNAMIC_DEBUG_CLASSMAP_USE() creates section records. Now ddebug_add_module(etal) can handle classmap-uses similar to (and after) classmaps; when a dependent module is loaded, if it has classmap-uses (to a classmap-def in another module), that module's kernel params are scanned to find if it has a kparam that is wired to dyndbg's param-ops, and whose classmap is the one being ref'd. To support this, theres a few data/header changes: new struct ddebug_class_user contains: user-module-name, &classmap-defn it records drm-driver's use of a classmap in the section, allowing lookup struct ddebug_info gets 2 new fields for the new sections: class_users, num_class_users. set by dynamic_debug_init() for builtins. or by kernel/module/main:load_info() for loadable modules. vmlinux.lds.h: new BOUNDED_SECTION for __dyndbg_class_users. this creates start,len C symbol-names for the section. TLDR ? dynamic_debug.c: 2 changes from ddebug_add_module() & ddebug_change(): ddebug_add_module(): ddebug_attach_module_classes() is reworked/renamed/split into debug_apply_class_maps(), ddebug_apply_class_users(), which both call ddebug_apply_params(). ddebug_apply_params(new fn): It scans module's/builtin kernel-params, calls ddebug_match_apply_kparam for each to find any params/sysfs-nodes which may be wired to a classmap. ddebug_match_apply_kparam(new fn): 1st, it tests the kernel-param.ops is dyndbg's; this guarantees that the attached arg is a struct ddebug_class_param, which has a ref to the param's state, and to the classmap defining the param's handling. 2nd, it requires that the classmap ref'd by the kparam is the one we've been called for; modules can use many separate classmaps (as test_dynamic_debug does). Then apply the "parent" kparam's setting to the dependent module, using ddebug_apply_class_bitmap(). ddebug_change(and callees) also gets adjustments: ddebug_find_valid_class(): This does a search over the module's classmaps, looking for the class FOO echo'd to >control. So now it searches over __dyndbg_class_users[] after __dyndbg_classes[]. ddebug_class_name(): return class-names for defined OR used classes. test_dynamic_debug.c, test_dynamic_debug_submod.c: This demonstrates the 2 types of classmaps & sysfs-params, following the 4-part recipe: 0. define an enum for the classmap's class_ids drm.debug gives us DRM_UT_<*> (aka ) multiple classmaps in a module(s) must share 0-62 classid space. 1. DYNAMIC_DEBUG_CLASSMAP_DEFINE(classmap_name, .. "") names the classes, maps them to consecutive class-ids. convention here is stringified ENUM_SYMBOLS these become API/ABI if 2 is done. 2. DYNAMIC_DEBUG_CLASSMAP_PARAM* (classmap_name) adds a controlling kparam to the class 3. DYNAMIC_DEBUG_CLASSMAP_USE(classmap_name) for subsystem/group/drivers to use extern created by 1. Move all the enum declarations together, to better explain how they share the 0..62 class-id space available to a module (non-overlapping subranges). reorg macros 2,3 by name. This gives a tabular format, making it easy to see the pattern of repetition, and the points of change. And extend the test to replicate the 2-module (parent & dependent) scenario which caused the CONFIG_DRM_USE_DYNAMIC_DEBUG=3Dy regression seen in drm & drivers. The _submod.c is a 2-line file: #define _SUBMOD, #include parent. This gives identical complements of prdbgs in parent & _submod, and thus identical print behavior when all of: >control, >params, and parent->_submod propagation are working correctly. It also puts all the parent/_submod declarations together in the same source; the new ifdef _SUBMOD block invokes DYNAMIC_DEBUG_CLASSMAP_USE for the 2 test-interfaces. I think this is clearer. These 2 modules are both tristate, allowing 3 super/sub combos: Y/Y, Y/M, M/M (not N/Y, since this is disallowed by dependence). Y/Y, Y/M testing once exposed a missing __align(8) in the _METADATA macro, which M/M didn't see, probably because the module-loader memory placement constrained it from misalignment. Fixes: aad0214f3026 ("dyndbg: add DECLARE_DYNDBG_CLASSMAP macro") cc: linux-doc@vger.kernel.org Signed-off-by: Jim Cromie --- checkpatch --strict complains about both DEFINE/USE macros in both cases, _var is an lvalue. CHECK: Macro argument reuse '_var' - possible side-effects? CHECK: Macro argument reuse '_var' - possible side-effects? + avoid stale di in add-module review apply-classmap-* after locked list-add V-Ive-lost-track: rework the main design-review comment block add @_base to class_user, and inner _USE_ - can deconflict with defn v4- rework after stub-macros v3- undo 1.9 simplification of ddebug_find_valid_class() ddebug_change needs map to see its controlling param change internal callchains to pass di, not dt v2 a. building 2 .ko's from 1 source file is weird; add a clear comment at the top to justify it (basically cloning) ln 138+ in commit-msg is insufficient. b. retire "DYNDBG_" name shortening b4 adding _CLASSMAP_* macros. c. s/dd_class/_ddebug_class/ d. s/\bddebug\b/_$1/g in header: chgs 1 struct and UNIQUE_ID bases v1.9 - commit-msg tweaks DRM:CHECK warnings on macros: add parens extern DEFINEd _var, static classnames change ddebug_class_user.user_mod_name to .mod_name simplify ddebug_find_valid_class return val improve vpr_cm_info msg format wrap (base) in macro body move __DYNDBG_CLASSMAP_CHECK above kdoc for DYNDBG_CLASSMAP_DEFINE v1.8 - split drm parts to separate commits. preserve DECLARE_DYNDBG_CLASSMAP to decouple DRM, no flag day. fixup block comment v1.7 - previous submission-blocking bug: missing __align(8) in DYNAMIC_DEBUG_DECLARE_METADATA on ddebug_class_user caused corrupt records, but only for builtin modules; module loader code probably pinned allocations to the right alignment naturally, hiding the bug for typical builds. v6- get rid of WARN_ON_ONCE v?- fix _var expanded 2x in macro dyndbg: This fn formerly returned the map which contained the class (thus validating it), and as a side-effect set the class-id in an outvar. But the caller didn't use the map (after checking its not null), only the valid class-id. So simplify the fn to return the class-id of the validated classname, or -ENOENT when the queried classname is not found. Convey more useful info in the debug-msg: print class-names[0,last], and [base,+len] instead of the class-type printout, which is almost always "type:DISJOINT_BITS". And drop ddebug_classmap_typenames, which is now unused. [root@v6 b0-dd]# modprobe test_dynamic_debug_submod [ 18.864962] dyndbg: loaded classmap: test_dynamic_debug [16..24] V0..V7 [ 18.865046] dyndbg: found kp:p_level_num =3D0x0 [ 18.865048] dyndbg: mapped to: test_dynamic_debug [16..24] V0..V7 [ 18.865164] dyndbg: p_level_num: lvl:0 bits:0x0 [ 18.865217] dyndbg: loaded classmap: test_dynamic_debug [0..10] D2_CORE.= .D2_DRMRES [ 18.865297] dyndbg: found kp:p_disjoint_bits =3D0x0 [ 18.865298] dyndbg: mapped to: test_dynamic_debug [0..10] D2_CORE..D2_= DRMRES [ 18.865424] dyndbg: p_disjoint_bits: classbits: 0x0 [ 18.865472] dyndbg: module:test_dynamic_debug attached 2 classmaps [ 18.865533] dyndbg: 23 debug prints in module test_dynamic_debug [ 18.866558] dyndbg: loaded classmap: test_dynamic_debug_submod [16..24] = V0..V7 [ 18.866698] dyndbg: found kp:p_level_num =3D0x0 [ 18.866699] dyndbg: mapped to: test_dynamic_debug_submod [16..24] V0..= V7 [ 18.866865] dyndbg: p_level_num: lvl:0 bits:0x0 [ 18.866926] dyndbg: loaded classmap: test_dynamic_debug_submod [0..10] D= 2_CORE..D2_DRMRES [ 18.867026] dyndbg: found kp:p_disjoint_bits =3D0x0 [ 18.867027] dyndbg: mapped to: test_dynamic_debug_submod [0..10] D2_CO= RE..D2_DRMRES [ 18.867193] dyndbg: p_disjoint_bits: classbits: 0x0 [ 18.867255] dyndbg: module:test_dynamic_debug_submod attached 2 classmap= uses [ 18.867351] dyndbg: 23 debug prints in module test_dynamic_debug_submod --- MAINTAINERS | 2 +- include/asm-generic/vmlinux.lds.h | 1 + include/linux/dynamic_debug.h | 139 ++++++++++++++++++++++++--- kernel/module/main.c | 3 + lib/Kconfig.debug | 24 ++++- lib/Makefile | 5 + lib/dynamic_debug.c | 154 +++++++++++++++++++++++++----- lib/test_dynamic_debug.c | 132 ++++++++++++++++++------- lib/test_dynamic_debug_submod.c | 14 +++ 9 files changed, 396 insertions(+), 78 deletions(-) create mode 100644 lib/test_dynamic_debug_submod.c diff --git a/MAINTAINERS b/MAINTAINERS index 0db59cca0d4a..4ad12af49a35 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8616,7 +8616,7 @@ M: Jim Cromie S: Maintained F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c -F: lib/test_dynamic_debug.c +F: lib/test_dynamic_debug*.c F: tools/testing/selftests/dynamic_debug/* =20 DYNAMIC INTERRUPT MODERATION diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 866c79d8b2a5..7bfd23ea7620 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -366,6 +366,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELL= ER_CLANG) /* implement dynamic printk debug */ \ . =3D ALIGN(8); \ BOUNDED_SECTION_BY(__dyndbg_class_maps, ___dyndbg_class_maps) \ + BOUNDED_SECTION_BY(__dyndbg_class_users, ___dyndbg_class_users) \ BOUNDED_SECTION_BY(__dyndbg_descriptors, ___dyndbg_descs) \ CODETAG_SECTIONS() \ LIKELY_PROFILE() \ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index c4ebbccca5d1..905db0b49104 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -71,8 +71,11 @@ enum ddebug_class_map_type { */ }; =20 +/* + * map @class_names 0..N to consecutive constants starting at @base. + */ struct _ddebug_class_map { - struct module *mod; /* NULL for builtins */ + const struct module *mod; /* NULL for builtins */ const char *mod_name; const char **class_names; const int length; @@ -80,10 +83,18 @@ struct _ddebug_class_map { enum ddebug_class_map_type map_type; }; =20 +struct _ddebug_class_user { + char *mod_name; + struct _ddebug_class_map *map; + const int base; /* user offset to re-number the used map */ +}; + /* - * @_ddebug_info: gathers module/builtin dyndbg_* __sections together. + * @_ddebug_info: gathers module/builtin __dyndbg_ __sections + * together, each is a vec_: a struct { struct T start[], int len }. + * * For builtins, it is used as a cursor, with the inner structs - * marking sub-vectors of the builtin __sections in DATA. + * marking sub-vectors of the builtin __sections in DATA_DATA */ struct _ddebug_descs { struct _ddebug *start; @@ -95,10 +106,16 @@ struct _ddebug_class_maps { int len; }; =20 +struct _ddebug_class_users { + struct _ddebug_class_user *start; + int len; +}; + struct _ddebug_info { const char *mod_name; struct _ddebug_descs descs; struct _ddebug_class_maps maps; + struct _ddebug_class_users users; }; =20 struct _ddebug_class_param { @@ -117,12 +134,81 @@ struct _ddebug_class_param { #if defined(CONFIG_DYNAMIC_DEBUG) || \ (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) =20 +/* + * dyndbg classmaps is modelled closely upon drm.debug: + * + * 1. run-time control via sysfs node (api/abi) + * 2. each bit 0..N controls a single "category" + * 3. a pr_debug can have only 1 category, not several. + * 4. "kind" is a compile-time constant: 0..N or BIT() thereof + * 5. macro impls - give compile-time resolution or fail. + * + * dyndbg classmaps design axioms/constraints: + * + * . optimizing compilers use 1-5 above, so preserve them. + * . classmaps.class_id *is* the category. + * . classmap definers/users are modules. + * . every user wants 0..N + * . 0..N exposes as ABI + * . no 1 use-case wants N > 32, 16 is more usable + * . N <=3D 64 in *all* cases + * . modules/subsystems make category/classmap decisions + * . ie an enum: DRM has DRM_UT_CORE..DRM_UT_DRMRES + * . some categories are exposed to user: ABI + * . making modules change their numbering is bogus, avoid if possible + * + * We can solve for all these at once: + * A: map class-names to a .class_id range at compile-time + * B: allow only "class NAME" changes to class'd callsites at run-time + * C: users/modules must manage 0..62 hardcoded .class_id range limit. + * D: existing pr_debugs get CLASS_DFLT=3D63 + * + * By mapping class-names at >control to class-ids underneath, and + * responding only to class-names DEFINEd or USEd by the module, we + * can private-ize the class-id, and adjust class'd pr_debugs only by + * their names. + * + * This give us: + * E: class_ids without classnames are unreachable + * F: user modules opt-in by DEFINEing a classmap and/or USEing another + * + * Multi-classmap modules/groups are supported, if the classmaps share + * the class_id space [0..62] without overlap/conflict. + * + * NOTE: Due to the integer class_id, this api cannot disallow these: + * __pr_debug_cls(0, "fake CORE msg"); works only if a classmap maps 0. + * __pr_debug_cls(22, "no such class"); compiles but is not reachable + */ + /** - * DECLARE_DYNDBG_CLASSMAP - declare classnames known by a module - * @_var: a struct ddebug_class_map, passed to module_param_cb - * @_type: enum class_map_type, chooses bits/verbose, numeric/symbolic - * @_base: offset of 1st class-name. splits .class_id space - * @classes: class-names used to control class'd prdbgs + * DYNAMIC_DEBUG_CLASSMAP_DEFINE - define debug classes used by a module. + * @_var: name of the classmap, exported for other modules coordinated u= se. + * @_mapty: enum ddebug_class_map_type: 0:DISJOINT - independent, 1:LEVEL = - v2>v1 + * @_base: reserve N classids starting at _base, to split 0..62 classid s= pace + * @classes: names of the N classes. + * + * This tells dyndbg what class_ids the module is using: _base..+N, by + * mapping names onto them. This qualifies "class NAME" >controls on + * the defining module, ignoring unknown names. + */ +#define DYNAMIC_DEBUG_CLASSMAP_DEFINE(_var, _mapty, _base, ...) \ + static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ + extern struct _ddebug_class_map _var; \ + struct _ddebug_class_map __aligned(8) __used \ + __section("__dyndbg_class_maps") _var =3D { \ + .mod =3D THIS_MODULE, \ + .mod_name =3D KBUILD_MODNAME, \ + .base =3D (_base), \ + .map_type =3D (_mapty), \ + .length =3D ARRAY_SIZE(_var##_classnames), \ + .class_names =3D _var##_classnames, \ + }; \ + EXPORT_SYMBOL(_var) + +/* + * XXX: keep this until DRM adapts to use the DEFINE/USE api, it + * differs from DYNAMIC_DEBUG_CLASSMAP_DEFINE by the lack of the + * extern/EXPORT on the struct init, and cascading thinkos. */ #define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ @@ -136,6 +222,26 @@ struct _ddebug_class_param { .class_names =3D _var##_classnames, \ } =20 +/** + * DYNAMIC_DEBUG_CLASSMAP_USE - refer to a classmap, DEFINEd elsewhere. + * @_var: name of the exported classmap var + * @_not_yet: _base-like, but applies only to this USEr. (if needed) + * + * This tells dyndbg that the module has prdbgs with classids defined + * in the named classmap. This qualifies "class NAME" >controls on + * the user module, and ignores unknown names. + */ +#define DYNAMIC_DEBUG_CLASSMAP_USE(_var) \ + DYNAMIC_DEBUG_CLASSMAP_USE_(_var, 0, __UNIQUE_ID(_ddebug_class_user)) +#define DYNAMIC_DEBUG_CLASSMAP_USE_(_var, _base, _uname) \ + extern struct _ddebug_class_map _var; \ + static struct _ddebug_class_user __aligned(8) __used \ + __section("__dyndbg_class_users") _uname =3D { \ + .mod_name =3D KBUILD_MODNAME, \ + .map =3D &(_var), \ + .base =3D _base \ + } + extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); =20 @@ -287,12 +393,18 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) =20 -/* for test only, generally expect drm.debug style macro wrappers */ -#define __pr_debug_cls(cls, fmt, ...) do { \ +/* + * This is the "model" class variant of pr_debug. It is not really + * intended for direct use; I'd encourage DRM-style drm_dbg_ + * macros for the interface, along with an enum for the + * + * __printf(2, 3) would apply. + */ +#define __pr_debug_cls(cls, fmt, ...) ({ \ BUILD_BUG_ON_MSG(!__builtin_constant_p(cls), \ "expecting constant class int/enum"); \ dynamic_pr_debug_cls(cls, fmt, ##__VA_ARGS__); \ - } while (0) +}) =20 #else /* !(CONFIG_DYNAMIC_DEBUG || (CONFIG_DYNAMIC_DEBUG_CORE && DYNAMIC_D= EBUG_MODULE)) */ =20 @@ -300,6 +412,8 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #include #include =20 +#define DYNAMIC_DEBUG_CLASSMAP_DEFINE(_var, _mapty, _base, ...) +#define DYNAMIC_DEBUG_CLASSMAP_USE(_var) #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) #define DYNAMIC_DEBUG_BRANCH(descriptor) false #define DECLARE_DYNDBG_CLASSMAP(...) @@ -346,8 +460,7 @@ static inline int param_set_dyndbg_classes(const char *= instr, const struct kerne static inline int param_get_dyndbg_classes(char *buffer, const struct kern= el_param *kp) { return 0; } =20 -#endif - +#endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ =20 extern const struct kernel_param_ops param_ops_dyndbg_classes; =20 diff --git a/kernel/module/main.c b/kernel/module/main.c index 1ccc5d4399c3..ee35238d2d0a 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2716,6 +2716,9 @@ static int find_module_sections(struct module *mod, s= truct load_info *info) mod->dyndbg_info.maps.start =3D section_objs(info, "__dyndbg_class_maps", sizeof(*mod->dyndbg_info.maps.start), &mod->dyndbg_info.maps.len); + mod->dyndbg_info.users.start =3D section_objs(info, "__dyndbg_class_users= ", + sizeof(*mod->dyndbg_info.users.start), + &mod->dyndbg_info.users.len); #endif =20 return 0; diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index dc0e0c6ed075..4fa720b98571 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2959,12 +2959,26 @@ config TEST_STATIC_KEYS If unsure, say N. =20 config TEST_DYNAMIC_DEBUG - tristate "Test DYNAMIC_DEBUG" - depends on DYNAMIC_DEBUG + tristate "Build test-dynamic-debug module" + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE help - This module registers a tracer callback to count enabled - pr_debugs in a 'do_debugging' function, then alters their - enablements, calls the function, and compares counts. + This module exercises/demonstrates dyndbg's classmap API, by + creating 2 classes: a DISJOINT classmap (supporting DRM.debug) + and a LEVELS/VERBOSE classmap (like verbose2 > verbose1). + + If unsure, say N. + +config TEST_DYNAMIC_DEBUG_SUBMOD + tristate "Build test-dynamic-debug submodule" + default m + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE + depends on TEST_DYNAMIC_DEBUG + help + This sub-module uses a classmap defined and exported by the + parent module, recapitulating drm & driver's shared use of + drm.debug to control enabled debug-categories. + It is tristate, independent of parent, to allow testing all + proper combinations of parent=3Dy/m submod=3Dy/m. =20 If unsure, say N. =20 diff --git a/lib/Makefile b/lib/Makefile index 392ff808c9b9..45a445a5ff96 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -81,6 +81,9 @@ obj-$(CONFIG_TEST_RHASHTABLE) +=3D test_rhashtable.o obj-$(CONFIG_TEST_STATIC_KEYS) +=3D test_static_keys.o obj-$(CONFIG_TEST_STATIC_KEYS) +=3D test_static_key_base.o obj-$(CONFIG_TEST_DYNAMIC_DEBUG) +=3D test_dynamic_debug.o +obj-$(CONFIG_TEST_DYNAMIC_DEBUG_SUBMOD) +=3D test_dynamic_debug_submod.o +obj-$(CONFIG_TEST_PRINTF) +=3D test_printf.o +obj-$(CONFIG_TEST_SCANF) +=3D test_scanf.o =20 obj-$(CONFIG_TEST_BITMAP) +=3D test_bitmap.o ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_KASAN),yy) @@ -207,6 +210,8 @@ obj-$(CONFIG_ARCH_NEED_CMPXCHG_1_EMU) +=3D cmpxchg-emu.o obj-$(CONFIG_DYNAMIC_DEBUG_CORE) +=3D dynamic_debug.o #ensure exported functions have prototypes CFLAGS_dynamic_debug.o :=3D -DDYNAMIC_DEBUG_MODULE +CFLAGS_test_dynamic_debug.o :=3D -DDYNAMIC_DEBUG_MODULE +CFLAGS_test_dynamic_debug_submod.o :=3D -DDYNAMIC_DEBUG_MODULE =20 obj-$(CONFIG_SYMBOLIC_ERRNAME) +=3D errname.o =20 diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index e5522fea49bb..c6b983f2324b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -29,6 +29,7 @@ #include #include #include + #include #include #include @@ -43,6 +44,8 @@ extern struct _ddebug __start___dyndbg_descs[]; extern struct _ddebug __stop___dyndbg_descs[]; extern struct _ddebug_class_map __start___dyndbg_class_maps[]; extern struct _ddebug_class_map __stop___dyndbg_class_maps[]; +extern struct _ddebug_class_user __start___dyndbg_class_users[]; +extern struct _ddebug_class_user __stop___dyndbg_class_users[]; =20 struct ddebug_table { struct list_head link; @@ -168,20 +171,37 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) query->first_lineno, query->last_lineno, query->class_string); } =20 -static struct _ddebug_class_map *ddebug_find_valid_class(struct ddebug_tab= le const *dt, - const char *class_string, - int *class_id) +#define vpr_di_info(di_p, msg_p, ...) ({ \ + struct _ddebug_info const *_di =3D di_p; \ + v2pr_info(msg_p "module:%s nd:%d nc:%d nu:%d\n", ##__VA_ARGS__, \ + _di->mod_name, _di->descs.len, _di->maps.len, \ + _di->users.len); \ + }) + +static struct _ddebug_class_map * +ddebug_find_valid_class(struct _ddebug_info const *di, const char *query_c= lass, int *class_id) { struct _ddebug_class_map *map; + struct _ddebug_class_user *cli; int i, idx; =20 - for_subvec(i, map, &dt->info, maps) { - idx =3D match_string(map->class_names, map->length, class_string); + for_subvec(i, map, di, maps) { + idx =3D match_string(map->class_names, map->length, query_class); if (idx >=3D 0) { + vpr_di_info(di, "good-class: %s.%s ", map->mod_name, query_class); *class_id =3D idx + map->base; return map; } } + for_subvec(i, cli, di, users) { + idx =3D match_string(cli->map->class_names, cli->map->length, query_clas= s); + if (idx >=3D 0) { + vpr_di_info(di, "class-ref: %s -> %s.%s ", + cli->mod_name, cli->map->mod_name, query_class); + *class_id =3D idx + cli->map->base; + return cli->map; + } + } *class_id =3D -ENOENT; return NULL; } @@ -238,8 +258,7 @@ static bool ddebug_match_desc(const struct ddebug_query= *query, return true; } =20 -static int ddebug_change(const struct ddebug_query *query, - struct flag_settings *modifiers) +static int ddebug_change(const struct ddebug_query *query, struct flag_set= tings *modifiers) { int i; struct ddebug_table *dt; @@ -260,7 +279,8 @@ static int ddebug_change(const struct ddebug_query *que= ry, continue; =20 if (query->class_string) { - map =3D ddebug_find_valid_class(dt, query->class_string, &valid_class); + map =3D ddebug_find_valid_class(&dt->info, query->class_string, + &valid_class); if (!map) continue; } else { @@ -590,7 +610,7 @@ static int ddebug_exec_query(char *query_string, const = char *modname) =20 /* handle multiple queries in query string, continue on error, return last error or number of matching callsites. Module name is either - in param (for boot arg) or perhaps in query string. + in the modname arg (for boot args) or perhaps in query string. */ static int ddebug_exec_queries(char *query, const char *modname) { @@ -721,7 +741,7 @@ static int param_set_dyndbg_module_classes(const char *= instr, /** * param_set_dyndbg_classes - classmap kparam setter * @instr: string echo>d to sysfs, input depends on map_type - * @kp: kp->arg has state: bits/lvl, map, map_type + * @kp: kp->arg has state: bits/lvl, classmap, map_type * * enable/disable all class'd pr_debugs in the classmap. For LEVEL * map-types, enforce * relative levels by bitpos. @@ -758,6 +778,7 @@ int param_get_dyndbg_classes(char *buffer, const struct= kernel_param *kp) default: return -1; } + return 0; } EXPORT_SYMBOL(param_get_dyndbg_classes); =20 @@ -1073,12 +1094,17 @@ static bool ddebug_class_in_range(const int class_i= d, const struct _ddebug_class static const char *ddebug_class_name(struct _ddebug_info *di, struct _ddeb= ug *dp) { struct _ddebug_class_map *map; + struct _ddebug_class_user *cli; int i; =20 for_subvec(i, map, di, maps) if (ddebug_class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 + for_subvec(i, cli, di, users) + if (ddebug_class_in_range(dp->class_id, cli->map)) + return cli->map->class_names[dp->class_id - cli->map->base]; + return NULL; } =20 @@ -1159,9 +1185,85 @@ static const struct proc_ops proc_fops =3D { .proc_write =3D ddebug_proc_write }; =20 -static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) +#define vpr_cm_info(cm_p, msg_fmt, ...) ({ \ + struct _ddebug_class_map const *_cm =3D cm_p; \ + v2pr_info(msg_fmt "%s [%d..%d] %s..%s\n", ##__VA_ARGS__, \ + _cm->mod_name, _cm->base, _cm->base + _cm->length, \ + _cm->class_names[0], _cm->class_names[_cm->length - 1]); \ + }) + +static void ddebug_sync_classbits(const struct kernel_param *kp, const cha= r *modname) { - vpr_info("module:%s attached %d classes\n", dt->info.mod_name, dt->info.m= aps.len); + const struct _ddebug_class_param *dcp =3D kp->arg; + + /* clamp initial bitvec, mask off hi-bits */ + if (*dcp->bits & ~CLASSMAP_BITMASK(dcp->map->length)) { + *dcp->bits &=3D CLASSMAP_BITMASK(dcp->map->length); + v2pr_info("preset classbits: %lx\n", *dcp->bits); + } + /* force class'd prdbgs (in USEr module) to match (DEFINEr module) class-= param */ + ddebug_apply_class_bitmap(dcp, dcp->bits, ~0, modname); + ddebug_apply_class_bitmap(dcp, dcp->bits, 0, modname); +} + +static void ddebug_match_apply_kparam(const struct kernel_param *kp, + const struct _ddebug_class_map *map, + const char *mod_name) +{ + struct _ddebug_class_param *dcp; + + if (kp->ops !=3D ¶m_ops_dyndbg_classes) + return; + + dcp =3D (struct _ddebug_class_param *)kp->arg; + + if (map =3D=3D dcp->map) { + v2pr_info(" kp:%s.%s =3D0x%lx", mod_name, kp->name, *dcp->bits); + vpr_cm_info(map, " %s maps ", mod_name); + ddebug_sync_classbits(kp, mod_name); + } +} + +static void ddebug_apply_params(const struct _ddebug_class_map *cm, const = char *mod_name) +{ + const struct kernel_param *kp; +#if IS_ENABLED(CONFIG_MODULES) + int i; + + if (cm->mod) { + vpr_cm_info(cm, "loaded classmap: %s ", mod_name); + /* ifdef protects the cm->mod->kp deref */ + for (i =3D 0, kp =3D cm->mod->kp; i < cm->mod->num_kp; i++, kp++) + ddebug_match_apply_kparam(kp, cm, mod_name); + } +#endif + if (!cm->mod) { + vpr_cm_info(cm, "builtin classmap: %s ", mod_name); + for (kp =3D __start___param; kp < __stop___param; kp++) + ddebug_match_apply_kparam(kp, cm, mod_name); + } +} + +static void ddebug_apply_class_maps(const struct _ddebug_info *di) +{ + struct _ddebug_class_map *cm; + int i; + + for_subvec(i, cm, di, maps) + ddebug_apply_params(cm, cm->mod_name); + + vpr_di_info(di, "attached %d class-maps to ", i); +} + +static void ddebug_apply_class_users(const struct _ddebug_info *di) +{ + struct _ddebug_class_user *cli; + int i; + + for_subvec(i, cli, di, users) + ddebug_apply_params(cli->map, cli->mod_name); + + vpr_di_info(di, "attached %d class-users to ", i); } =20 /* @@ -1198,6 +1300,7 @@ static int ddebug_add_module(struct _ddebug_info *di) { struct ddebug_table *dt; struct _ddebug_class_map *cm; + struct _ddebug_class_user *cli; int i; =20 if (!di->descs.len) @@ -1210,26 +1313,29 @@ static int ddebug_add_module(struct _ddebug_info *d= i) pr_err("error adding module: %s\n", di->mod_name); return -ENOMEM; } + INIT_LIST_HEAD(&dt->link); /* - * For built-in modules, name (as supplied in di by its - * callers) lives in .rodata and is immortal. For loaded - * modules, name points at the name[] member of struct module, - * which lives at least as long as this struct ddebug_table. + * For built-in modules, di-> referents live in .rodata and is + * are immortal. For loaded modules, name points at the name[] + * member of struct module, which lives at least as long as + * this struct ddebug_table. */ dt->info =3D *di; - - INIT_LIST_HEAD(&dt->link); - dd_mark_vector_subrange(i, dt, cm, di, maps); - - if (di->maps.len) - ddebug_attach_module_classes(dt, di); + dd_mark_vector_subrange(i, dt, cli, di, users); + /* now di may be stale */ =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); =20 - vpr_info("%3u debug prints in module %s\n", di->descs.len, di->mod_name); + if (dt->info.maps.len) + ddebug_apply_class_maps(&dt->info); + if (dt->info.users.len) + ddebug_apply_class_users(&dt->info); + + vpr_info("%3u debug prints in module %s\n", + dt->info.descs.len, dt->info.mod_name); return 0; } =20 @@ -1379,8 +1485,10 @@ static int __init dynamic_debug_init(void) struct _ddebug_info di =3D { .descs.start =3D __start___dyndbg_descs, .maps.start =3D __start___dyndbg_class_maps, + .users.start =3D __start___dyndbg_class_users, .descs.len =3D __stop___dyndbg_descs - __start___dyndbg_descs, .maps.len =3D __stop___dyndbg_class_maps - __start___dyndbg_class_maps, + .users.len =3D __stop___dyndbg_class_users - __start___dyndbg_class_user= s, }; =20 #ifdef CONFIG_MODULES diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 9c3e53cd26bd..6c4548f63512 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -6,11 +6,30 @@ * Jim Cromie */ =20 -#define pr_fmt(fmt) "test_dd: " fmt +/* + * This file is built 2x, also making test_dynamic_debug_submod.ko, + * whose 2-line src file #includes this file. This gives us a _submod + * clone with identical pr_debugs, without further maintenance. + * + * If things are working properly, they should operate identically + * when printed or adjusted by >control. This eases visual perusal of + * the logs, and simplifies testing, by easing the proper accounting + * of expectations. + * + * It also puts both halves of the subsystem _DEFINE & _USE use case + * together, and integrates the common ENUM providing both class_ids + * and class-names to both _DEFINErs and _USERs. I think this makes + * the usage clearer. + */ +#if defined(TEST_DYNAMIC_DEBUG_SUBMOD) + #define pr_fmt(fmt) "test_dd_submod: " fmt +#else + #define pr_fmt(fmt) "test_dd: " fmt +#endif =20 #include =20 -/* run tests by reading or writing sysfs node: do_prints */ +/* re-gen output by reading or writing sysfs node: do_prints */ =20 static void do_prints(void); /* device under test */ static int param_set_do_prints(const char *instr, const struct kernel_para= m *kp) @@ -29,24 +48,39 @@ static const struct kernel_param_ops param_ops_do_print= s =3D { }; module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0600); =20 -/* - * Using the CLASSMAP api: - * - classmaps must have corresponding enum - * - enum symbols must match/correlate with class-name strings in the map. - * - base must equal enum's 1st value - * - multiple maps must set their base to share the 0-30 class_id space !! - * (build-bug-on tips welcome) - * Additionally, here: - * - tie together sysname, mapname, bitsname, flagsname - */ -#define DD_SYS_WRAP(_model, _flags) \ - static unsigned long bits_##_model; \ - static struct _ddebug_class_param _flags##_model =3D { \ +#define CLASSMAP_BITMASK(width, base) (((1UL << (width)) - 1) << (base)) + +/* sysfs param wrapper, proto-API */ +#define DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, _init) \ + static unsigned long bits_##_model =3D _init; \ + static struct _ddebug_class_param _flags##_##_model =3D { \ .bits =3D &bits_##_model, \ .flags =3D #_flags, \ .map =3D &map_##_model, \ }; \ - module_param_cb(_flags##_##_model, ¶m_ops_dyndbg_classes, &_flags##_m= odel, 0600) + module_param_cb(_flags##_##_model, ¶m_ops_dyndbg_classes, \ + &_flags##_##_model, 0600) +#ifdef DEBUG +#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_model, _flags) \ + DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, ~0) +#else +#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_model, _flags) \ + DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, 0) +#endif + +/* + * Demonstrate/test DISJOINT & LEVEL typed classmaps with a sys-param. + * + * To comport with DRM debug-category (an int), classmaps map names to + * ids (also an int). So a classmap starts with an enum; DRM has enum + * debug_category: with DRM_UT_. We use the enum + * values as class-ids, and stringified enum-symbols as classnames. + * + * Modules with multiple CLASSMAPS must have enums with distinct + * value-ranges, as arranged below with explicit enum_sym =3D X inits. + * To clarify this sharing, declare the 2 enums now, for the 2 + * different classmap types + */ =20 /* numeric input, independent bits */ enum cat_disjoint_bits { @@ -60,26 +94,51 @@ enum cat_disjoint_bits { D2_LEASE, D2_DP, D2_DRMRES }; -DECLARE_DYNDBG_CLASSMAP(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BITS, 0, - "D2_CORE", - "D2_DRIVER", - "D2_KMS", - "D2_PRIME", - "D2_ATOMIC", - "D2_VBL", - "D2_STATE", - "D2_LEASE", - "D2_DP", - "D2_DRMRES"); -DD_SYS_WRAP(disjoint_bits, p); -DD_SYS_WRAP(disjoint_bits, T); - -/* numeric verbosity, V2 > V1 related */ -enum cat_level_num { V0 =3D 14, V1, V2, V3, V4, V5, V6, V7 }; -DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, 14, - "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); -DD_SYS_WRAP(level_num, p); -DD_SYS_WRAP(level_num, T); + +/* numeric verbosity, V2 > V1 related. V0 is > D2_DRMRES */ +enum cat_level_num { V0 =3D 16, V1, V2, V3, V4, V5, V6, V7 }; + +/* recapitulate DRM's multi-classmap setup */ +#if !defined(TEST_DYNAMIC_DEBUG_SUBMOD) +/* + * In single user, or parent / coordinator (drm.ko) modules, define + * classmaps on the client enums above, and then declares the PARAMS + * ref'g the classmaps. Each is exported. + */ +DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BI= TS, + D2_CORE, + "D2_CORE", + "D2_DRIVER", + "D2_KMS", + "D2_PRIME", + "D2_ATOMIC", + "D2_VBL", + "D2_STATE", + "D2_LEASE", + "D2_DP", + "D2_DRMRES"); + +DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, + V0, "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); + +/* + * now add the sysfs-params + */ + +DYNAMIC_DEBUG_CLASSMAP_PARAM(disjoint_bits, p); +DYNAMIC_DEBUG_CLASSMAP_PARAM(level_num, p); + +#else /* TEST_DYNAMIC_DEBUG_SUBMOD */ + +/* + * in submod/drm-drivers, use the classmaps defined in top/parent + * module above. + */ + +DYNAMIC_DEBUG_CLASSMAP_USE(map_disjoint_bits); +DYNAMIC_DEBUG_CLASSMAP_USE(map_level_num); + +#endif =20 /* stand-in for all pr_debug etc */ #define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") @@ -115,6 +174,7 @@ static void do_levels(void) =20 static void do_prints(void) { + pr_debug("do_prints:\n"); do_cats(); do_levels(); } diff --git a/lib/test_dynamic_debug_submod.c b/lib/test_dynamic_debug_submo= d.c new file mode 100644 index 000000000000..672aabf40160 --- /dev/null +++ b/lib/test_dynamic_debug_submod.c @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Kernel module for testing dynamic_debug + * + * Authors: + * Jim Cromie + */ + +/* + * clone the parent, inherit all the properties, for consistency and + * simpler accounting in test expectations. + */ +#define TEST_DYNAMIC_DEBUG_SUBMOD +#include "test_dynamic_debug.c" --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.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 2352036921D for ; Tue, 18 Nov 2025 20:19:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497169; cv=none; b=rY0wNuisBxz7mUAbERD4h4AVvJVEMUsd9dKrKsFLJAoke+xrvc9verSVpgOssTwvjkoy6ci9yxuRqyN7ynwKWJin/YpVu2gS1LEEa1uENhIWkX/cVEQp+pjP+mlR6B1QG7MQaTki9mWvrP+2sl0BLu1i3L6txj/U0ZpXnVzPvYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497169; c=relaxed/simple; bh=WfBFKyhLRyyzc7Dtwh5RArbJNXQPnwbENTz83sKaVq0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ksjpGZjjAMp2a5cfyGH0YZhmkDoAsozyPY78AlXR9PtCaYZt5AbmnVL2LWLJYoq7A+1HMgtPJfRYNu8nbY5rNk0DMguxzmzW3cSirNOJ6kVKXWVgDhVyfbs/sDzChexVdwU+J8pfqw8C9mGVi9F+XMgq99WQq1qiQO5qF5/CSrI= 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=GPgwTO/z; arc=none smtp.client-ip=209.85.166.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="GPgwTO/z" Received: by mail-io1-f52.google.com with SMTP id ca18e2360f4ac-9486d008fdbso8786639f.1 for ; Tue, 18 Nov 2025 12:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497165; x=1764101965; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Lf2KYKGZTZbOL5PiLrqZOpnGDaNeXmVBMrHOoH3mOwo=; b=GPgwTO/zBAstuEctCsgdW4DqI3iXChjugbfV+dRVyk0NnHghxWVRUA3w+bS3f7zghT BJOjmMcoZKvy+cD/6Cn6xpmUCjNOyUWVRMnxWEo3a0n4BkPAV88bpDyXB3bgqagTmRV0 kxbkZ1LQIKYJcWKdHXZY3K+RsQgUVj377FDensKQlc4OkFONNMZtf6bX9hjJCsxwANKR 4dHFt5n6nue/RkOJSSBMeUgZPGK6fpMMVH1UDBIBE5tWYGcW4Uzqu1yroqkHYg7ZMwqX MGdXuMDv24p4waLuHAD/Nl4++FuttiyUyHXHcpIZIHV/XMBoTPjmVojDU7kK4xCc3CqM u5jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497165; x=1764101965; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Lf2KYKGZTZbOL5PiLrqZOpnGDaNeXmVBMrHOoH3mOwo=; b=NB850tyKoZKBChpI+lQnHAxVxgfYy3uKoM+D4mdDVI/E5o1bAjimvYD4uX79SLW4Wq vw80TpusAPlRKVKalZgL8CmLTx3p+GozMj583bHmO3Cg5ZWOei3+winrEW53k2jdL0yy gxZn5K/tzUcKuj1BlhBnRrt+MOjVAA8s1L4ZWBSbnxe11RJcK6ePb7C0lipIj85Tad6W 72QInMUF15OBYCV2aYA2Fx6vgwMlQWX1fSnBTHwXecWD8FEYJ4ojbPY5BVhhaB3U+Yta JaJQetoYFKgIlR448BZYZ2QFFPTZlnE8oSL5nYtgWY9PpsD3w9MMKJ2+d97otY2SI2Bc 1K2Q== X-Gm-Message-State: AOJu0YxBn5gmvKJImFNNl+azMkfWKsV1hmrwzVtZB/O7H4WDYqtKa58A f0rdOUd68DEP/F8DHSkGvVLvoXW5W8iPU/DNWv9YLU/9wC0DoSxnOdn7I6GTw7SB X-Gm-Gg: ASbGncstm3rcTB9+rvNOURMyE0ajirEpayp1QpYC8fN2GcbXdE052w0wJec20FTeLAM 5fZkP6yA1kAmPnEHSrG8sZ4bReq0Z3ybpaYNMr2U2Gx35W+KDfcoEy9ibDt/+m9RDpQXS5LmQgY Elrhh+78Og0TKK/ahkoXvdo9nv0Aj7NH0VJ07UCSJyn6zJp9p9kFftxYKkLc74Jam0C8fUgMv7a wZaAbtmfLANwsIyvykze5NUqdv9Z+q+cHAFbh+/BVsGAJKrSCcoHeSx45bCI9sVyvmel1+Qls4F Pta3Ef3kZEIUB3z4fwJJCK821ZVMMXbFC5GhiUlE0ZPANu/k1BCHtseC5bw7fLLenRi68c8d+wU LImNhwSEYcAx9TLvjtPX70cbOoBW0WRnDVemwKhrOFVlZMWSOOY8RgWgQT8dDASt1WaTaFLqc7j zkfgkp2cAtWBSfRIj3p/QQhJDMXPl90RNrSNFzdVDN/RVqp+cXnHfKNBd8VMVCXmrHZPhpbfQiO KTSMA== X-Google-Smtp-Source: AGHT+IGx1eNlZGV/xEbBO/tczptXELUHfkRxYaLx6Xv6FIVM3pmvNf0oeW2cq5nrxOsKyemhr0F/dw== X-Received: by 2002:a05:6602:3f93:b0:949:66a:4d77 with SMTP id ca18e2360f4ac-9492b8a1422mr16324939f.5.1763497165261; Tue, 18 Nov 2025 12:19:25 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:24 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 22/31] dyndbg: detect class_id reservation conflicts Date: Tue, 18 Nov 2025 13:18:32 -0700 Message-ID: <20251118201842.1447666-23-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" If a module _DEFINEs 2 or more classmaps, it must devise them to share the per-module 0..62 class-id space; ie their respective base,+length reservations cannot overlap. To detect conflicts at modprobe, add ddebug_class_range_overlap(), call it from ddebug_add_module(), and WARN and return -EINVAL when they're detected. This insures that class_id -> classname lookup has just 1 answer, so the 1st-found search in find-class-name works properly. test_dynamic_debug.c: If built with -DFORCE_CLASSID_CONFLICT, the test-modules invoke 2 conflicting DYNAMIC_DEBUG_CLASSMAP_DEFINE() declarations, into parent and the _submod. These conflict with one of the good ones in the parent (D2_CORE..etc), causing the modprobe(s) to warn Signed-off-by: Jim Cromie --- - USE doesnt need conflict test against DEFINE infact its wrong-headed - of course theyd overlap. --- lib/dynamic_debug.c | 40 +++++++++++++++++++++++++++++++++------- lib/test_dynamic_debug.c | 8 ++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c6b983f2324b..25b3932891e0 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1292,6 +1292,22 @@ static void ddebug_apply_class_users(const struct _d= debug_info *di) (__dst)->info._vec.len =3D __nc; \ }) =20 +static int __maybe_unused +ddebug_class_range_overlap(struct _ddebug_class_map *cm, + u64 *reserved_ids) +{ + u64 range =3D (((1ULL << cm->length) - 1) << cm->base); + + if (range & *reserved_ids) { + pr_err("[%d..%d] on %s conflicts with %llx\n", cm->base, + cm->base + cm->length - 1, cm->class_names[0], + *reserved_ids); + return -EINVAL; + } + *reserved_ids |=3D range; + return 0; +} + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1301,6 +1317,7 @@ static int ddebug_add_module(struct _ddebug_info *di) struct ddebug_table *dt; struct _ddebug_class_map *cm; struct _ddebug_class_user *cli; + u64 reserved_ids =3D 0; int i; =20 if (!di->descs.len) @@ -1315,15 +1332,20 @@ static int ddebug_add_module(struct _ddebug_info *d= i) } INIT_LIST_HEAD(&dt->link); /* - * For built-in modules, di-> referents live in .rodata and is - * are immortal. For loaded modules, name points at the name[] - * member of struct module, which lives at least as long as - * this struct ddebug_table. + * For built-in modules, di-> referents live in .*data and are + * immortal. For loaded modules, di points at the dyndbg_info + * member of its struct module, which lives at least as + * long as this struct ddebug_table. */ dt->info =3D *di; - dd_mark_vector_subrange(i, dt, cm, di, maps); - dd_mark_vector_subrange(i, dt, cli, di, users); - /* now di may be stale */ + dd_mark_vector_subrange(i, dt, cm, &dt->info, maps); + dd_mark_vector_subrange(i, dt, cli, &dt->info, users); + /* now di is stale */ + + /* insure 2+ classmaps share the per-module 0..62 class_id space */ + for_subvec(i, cm, &dt->info, maps) + if (ddebug_class_range_overlap(cm, &reserved_ids)) + goto cleanup; =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); @@ -1337,6 +1359,10 @@ static int ddebug_add_module(struct _ddebug_info *di) vpr_info("%3u debug prints in module %s\n", dt->info.descs.len, dt->info.mod_name); return 0; +cleanup: + WARN_ONCE("dyndbg multi-classmap conflict in %s\n", di->mod_name); + kfree(dt); + return -EINVAL; } =20 /* helper for ddebug_dyndbg_(boot|module)_param_cb */ diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 6c4548f63512..1ba4be9a403a 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -128,6 +128,14 @@ DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_level_num, DD_CLASS_= TYPE_LEVEL_NUM, DYNAMIC_DEBUG_CLASSMAP_PARAM(disjoint_bits, p); DYNAMIC_DEBUG_CLASSMAP_PARAM(level_num, p); =20 +#ifdef FORCE_CLASSID_CONFLICT +/* + * Enable with -Dflag on compile to test overlapping class-id range + * detection. This should warn on modprobes. + */ +DYNDBG_CLASSMAP_DEFINE(classid_range_conflict, 0, D2_CORE + 1, "D3_CORE"); +#endif + #else /* TEST_DYNAMIC_DEBUG_SUBMOD */ =20 /* --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) (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 EF50F2F83BB for ; Tue, 18 Nov 2025 20:19:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497170; cv=none; b=C2oeEdY7xEHGbfL4Z/q/X+FWsOqWv2RN2t5KO1vJP7cAhK/ApetqzZupqK7bThcCo6OUZhbUiB0EzVUCsg0Ds7gqHkxYLb2HPJDbQ7ajrS1UBPRPfSoKn4t/AVfKm2xDhVKDuXgvCvP4ROBl1SASVpJT+8gBTBIE4UCtEOj5sXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497170; c=relaxed/simple; bh=4gcGRgva0eLSrFJr6GtR+Nl4ilJG9ulEI9xGeh4rDlk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qnpTLSNrKLbShE7FstZtUAgthggh1R0sIXpux7VeBVKn+szVJx6C3vuPdBYvoN9FUnNF5u0NqnChcZtYMJJ8vj5q6GhN4rd8R7mu86Y/MyIpbB9L8pbyxzVVBrU/mF1fexE8nv3gdSJ+C5fGNowj7Fks+Ur0JE+enrO4Zf7IaeQ= 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=hTdACzOn; arc=none smtp.client-ip=209.85.166.53 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="hTdACzOn" Received: by mail-io1-f53.google.com with SMTP id ca18e2360f4ac-949022f1c85so136898139f.0 for ; Tue, 18 Nov 2025 12:19:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497166; x=1764101966; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jMXBzIIRyoXzNJBSl4ah2NOKF+5LtDRbEmDzwpRMTZI=; b=hTdACzOniP43qUnmcxYcMxd4Vyu5t0pH9Jj9oc5VzhdZzcnP+tFkl0NO3l6I4ryiFb 2M4ePl3ry9D1Md7lbH9mj5bf7ByH8K+tAdLK35mOdiXH1zsFMNfZq9of6QxWBk28Ab8X MFeUMfhhLKal95Ph+eWZjKCcQEJhP4dX/qIZ67p7YMp1F9ynOO7mDnnDsqso1Pmc55Q/ IPzBkyo52xno60IBnIR1EH9c6YjrT8qGFXgKjK+xsi2GxkWL9a+Y5KNT2LuVt1BlyFZ4 R2ptW9DWlPC3k9GLpd0zbOfTLaopi94BzYba2XUEIxy2iiG0Ts/F0j5M+OKTAZdq/L5/ RH8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497166; x=1764101966; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jMXBzIIRyoXzNJBSl4ah2NOKF+5LtDRbEmDzwpRMTZI=; b=XnC+XdPskE0Lptw2RJuDopao6hXWHRsCOf7m+FZyCoQzSaZKBB2M/BWTa8CP05nceV ft7nMyUBvgLeQ1+k6F7AEV9sfnTi34Mr6dSXGjAzx6/yNrX8TzpyCJ4QBGm7QEFwOVEz 51sbJPmBUf+JVhIXt7DNpfhpxYsUZ+izcbu38eYVe7M2aVo8xqZgNY49aj8Oa/ohXdcE fXS2cbYdhEgpMXjJ2L0zRSxk51b41aUENBQTPTzJkpBggMwOgSbPvjH+jXYR08RWZRWy 908xY+BySW13SojDmz7rSuzp/8NM4nNkWwJsHpXrGCePPMFz+B9TFEWK+6TyL5diLyGH fxSw== X-Gm-Message-State: AOJu0YxXBn2iAEKwTtS/m7H92PmLQngwPmesNrm/OFE/w5ih93JKmlg0 sVcFvILYCLkTkTfo8U442QBF7R7maqtw80r6O8JcauMEgeisAGugq+OOQKeIvemh X-Gm-Gg: ASbGncuGjvz/e/jQlJjEv6Y6xF+0wyVGW+uFXMILsKm1wJ0Mog3m5lrx1RVUwtrX1Ib wFtJqhBJ6hmOS/GRjYpuuS2lCaAYWB7ldeqhohoI8h2AbeUYSsp/HPSMpsRE/SKea6K17sp+/hH Fo1uM7W7OP3tt9l1FS3KE0z3Tyjz1vTK5YAP8DLRlc7q5IR06eiPRP2GeJofj2CIQc8foZ0sXpx B7pToYXvra7ByuRtBNn4EX6BVbkz79F07quWHrb6eazZZ4vAgo30JAy3EE0Bq74l/J/sTkmjcg0 rZfYojoJ2s5kwXeif/ZJgflOMUB+iF6hdFgJsg3p08beWnr8cjs4MeX40JM44EyvJV3WkgkaMMs BswM9TO0Q+INtLYyfVSLB8gD5h1jYGsQFtvrJa1UlkAZijnvO1ARhBbSCClmOIIeF7aAQ4DrDcd SB3MB5zV8FQGmBurMmd67GjVEVpms8rlZ9JSm/PD9Hac1zwQBvbPlL7J6psFW39e94DeY= X-Google-Smtp-Source: AGHT+IFOUykA39ngbL/gi4rSkDM2Dh8wgirVlMpJOQAuJ/4iYCBDDhEoAW+I/UmChihR1kpRWQW33g== X-Received: by 2002:a05:6602:2c06:b0:948:cbd2:3b84 with SMTP id ca18e2360f4ac-948e0d87a37mr1874742539f.11.1763497166224; Tue, 18 Nov 2025 12:19:26 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:25 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 23/31] dyndbg: check DYNAMIC_DEBUG_CLASSMAP_DEFINE args at compile-time Date: Tue, 18 Nov 2025 13:18:33 -0700 Message-ID: <20251118201842.1447666-24-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" Add __DYNAMIC_DEBUG_CLASSMAP_CHECK to implement the following arg-checks at compile-time: 0 <=3D _base < 63 class_names is not empty class_names[0] is a string (class_names.length + _base) < 63 These compile-time checks will prevent several simple misuses, and will issue obvious errors if violated. 4 such examples are added to test_dynamic_debug_submod.ko, and will fail compilation if -DDD_MACRO_ARGCHECK is added to cflags. This wouldn't be a useful CONFIG_ item, since it breaks the build. Signed-off-by: Jim Cromie --- these checkpatch "reuse" issues are on lvalues, irrelevant. CHECK: Macro argument reuse '_clnames' - possible side-effects? CHECK: Macro argument reuse '_base' - possible side-effects? v4- deconflict after pulling macro-stubs forward v3- $macro_name =3D~ s/DYNDBG/DYNAMIC_DEBUG/ prev- - split static-asserts to __DYNDBG_CLASSMAP_CHECK - move __DYNDBG_CLASSMAP_CHECK above kdoc for DYNDBG_CLASSMAP_DEFINE silences kernel-doc warnings --- include/linux/dynamic_debug.h | 9 +++++++++ lib/test_dynamic_debug.c | 13 ++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 905db0b49104..b19c9b1d53b6 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -180,6 +180,14 @@ struct _ddebug_class_param { * __pr_debug_cls(22, "no such class"); compiles but is not reachable */ =20 +#define __DYNAMIC_DEBUG_CLASSMAP_CHECK(_clnames, _base) \ + static_assert(((_base) >=3D 0 && (_base) < _DPRINTK_CLASS_DFLT), \ + "_base must be in 0..62"); \ + static_assert(ARRAY_SIZE(_clnames) > 0, \ + "classnames array size must be > 0"); \ + static_assert((ARRAY_SIZE(_clnames) + (_base)) < _DPRINTK_CLASS_DFLT, \ + "_base + classnames.length exceeds range") + /** * DYNAMIC_DEBUG_CLASSMAP_DEFINE - define debug classes used by a module. * @_var: name of the classmap, exported for other modules coordinated u= se. @@ -193,6 +201,7 @@ struct _ddebug_class_param { */ #define DYNAMIC_DEBUG_CLASSMAP_DEFINE(_var, _mapty, _base, ...) \ static const char *_var##_classnames[] =3D { __VA_ARGS__ }; \ + __DYNAMIC_DEBUG_CLASSMAP_CHECK(_var##_classnames, (_base)); \ extern struct _ddebug_class_map _var; \ struct _ddebug_class_map __aligned(8) __used \ __section("__dyndbg_class_maps") _var =3D { \ diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 1ba4be9a403a..b2bdfdfb6ba1 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -133,7 +133,7 @@ DYNAMIC_DEBUG_CLASSMAP_PARAM(level_num, p); * Enable with -Dflag on compile to test overlapping class-id range * detection. This should warn on modprobes. */ -DYNDBG_CLASSMAP_DEFINE(classid_range_conflict, 0, D2_CORE + 1, "D3_CORE"); +DYNAMIC_DEBUG_CLASSMAP_DEFINE(classid_range_conflict, 0, D2_CORE + 1, "D3_= CORE"); #endif =20 #else /* TEST_DYNAMIC_DEBUG_SUBMOD */ @@ -146,8 +146,19 @@ DYNDBG_CLASSMAP_DEFINE(classid_range_conflict, 0, D2_C= ORE + 1, "D3_CORE"); DYNAMIC_DEBUG_CLASSMAP_USE(map_disjoint_bits); DYNAMIC_DEBUG_CLASSMAP_USE(map_level_num); =20 +#if defined(DD_MACRO_ARGCHECK) +/* + * Exersize compile-time arg-checks in DYNAMIC_DEBUG_CLASSMAP_DEFINE. + * These will break compilation. + */ +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_base_neg, 0, -1, "NEGATIVE_BASE_ARG"); +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_base_big, 0, 100, "TOOBIG_BASE_ARG"); +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_str_type, 0, 0, 1 /* not a string */); +DYNAMIC_DEBUG_CLASSMAP_DEFINE(fail_emptyclass, 0, 0 /* ,empty */); #endif =20 +#endif /* TEST_DYNAMIC_DEBUG_SUBMOD */ + /* stand-in for all pr_debug etc */ #define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") =20 --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (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 CBE2136923B for ; Tue, 18 Nov 2025 20:19:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497171; cv=none; b=lgDBG9NOtsdtOeNbRx+yS/K6O+foesKikKIKkvQW3FUwH3YcFOEg7fb7w7a5HyNiKOAHo3e8Qo/b82GeealKCr0kopH6YE8Yj8Llo2ZJhTjiYsrUciLrLX9XdZGFGK7q6rvb39ITJAoJzGl09BrdQvnnsKEcwK3lUF0R/2mwl1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497171; c=relaxed/simple; bh=/9spDiqKWTi61wro4Tnk70IEPRBQmLk8n9yBr6Oe1iU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S3wWNuWqkQ4Yy+LlKH+9bT6jljoL6RsMTVGBqDtJyPeKtF5FbaZf48pGWEB6dB4gSfyg7jDYnzre1kJob8ubvqlcA/7+PK+eJEEFl2kzr1SnIokAEH/uO3+l8Ha2ZKaCx/uHNI8kyVY7v7RQHk2ADpN0ncnGQwgVevqiN2z8Kzw= 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=LVzOuniH; arc=none smtp.client-ip=209.85.166.42 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="LVzOuniH" Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-94861514a5cso392886239f.1 for ; Tue, 18 Nov 2025 12:19:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497167; x=1764101967; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AkJdwdOvuZtYon9oCXsSDFPk0lzlRWF/tYh6X0VG6iw=; b=LVzOuniHOvRUdfhCTEe+jZ0pkeJ4YTIJjw5KvAg04DE59Q+b5fXBrN/OrQaeN1F58C 530O9Cy2TpKnlHGxZW7VDzRr4Mgc7B84SqsBTAW4MyuWS0y5v1uAjqMxdgn3etgVne/F OTN0WOJTjAHZe6UmelWA3K1Id+AA8ZtI8Qyvg47rCZN/8vg9OHExfC2JQR9IlGveqIZ2 alwDdcqPnXHdFSKxhfU7QIH92cH90dRkXpwwzGfCQkNgJdkzJGTeRwUJ6VAsg6VKrTBK WU2D0H2ZhjKa5ithYnAQCYupxqaRvATGEuv8JBcwOcc8PWH4/WRrX4NyxfRMotP94yXQ pcNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497167; x=1764101967; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=AkJdwdOvuZtYon9oCXsSDFPk0lzlRWF/tYh6X0VG6iw=; b=ChkiDL7PuWs90BHV4ssz6A4wj0gOVaEGIAvAKIqx5KpyDUl42kIkn0dFEyCwGzrcTY BBllqKXSFvwiftYDs81A5yHnYvuvLClQ5SY2c4Mz2t5+igqdiqmLchaM4Jz5ji2pr5zC oBQPM8ZSUdPsUgm9i0DLc2ovrv+E7Na561VYbfrnCeSGQOvngsiIEq3tkBLLhho5yytT vo5Fa7JwExqr+MNSwEqN2XgdB8/lPT9mqh+g3P5oPDYhevvRXEG8gWRAO68iYmNULonb ygZzLrw0Jjl9JkadzgzYQyyhqlg10t7j6xbntBrrFJ50Rt9KodndODUczoacZfsaGFIG Xa0Q== X-Gm-Message-State: AOJu0YyRkS+n2eMiBbVHOePuugzA2IeI3uJYVQlQt807VsKSS3520BXy srBcWsGEWzW4wXQDJgshMTurSoM4KojE5K7qRE94FEkyuhG8cyOzu7RYjPPEEAI1 X-Gm-Gg: ASbGnctBUCG3Ren5EBCjBVCqlWd3iZgTbpDt6Pv3frP1vJ3FwCQCRLzaI/D+wmYlpr5 gScYq+W8+3O6+At09LCDdJU3oN0W9rxRWd98hBqv+8LcvDYkv5TSfpJ1nSYns7tjQWsuMGeW5xl gcPkl6Ge/Kiuc1dMHpc4PuTYXQisWA6X+AY7T0eoJFnVuBDINsnTMXB942oJuCQcP8KSbmeGSxQ 4Z6RQQcAbQbx2giTcm48PgZfjfW6xVBo7lJdZwPoxdSg1u73xk8Efxkm+oWDBVmDB8tK0e42bJY mT9zUQCXniGkNX9mImurZdiuXkkfFeg3ZAJwfcZW0WjW6sRXqZcpd5Z8TVqdwyW5fZyIW/VRj78 n4Bt2RdXQSyQbaDzu51Zf5qIw4FnicMRdkiXbCSV1UIJ1g6dmXiaC+nerOqXNSZ4PfQkhRaFntR JE3v5I9tXOWLsarNGA5N4xPWm4XrP0Ewzpr0xAyGJ/+/O+8s8XYfGoHvrJ51Hs259tB3/BtHz7J udF/Q== X-Google-Smtp-Source: AGHT+IFZpGWUD4HzzmtOBoMpGi8hZWUuQiKNNXIL4zMB3fc5Gey6Cuo0En2AnLuow8yyRJnTGJ95fw== X-Received: by 2002:a05:6602:3405:b0:949:dec:b914 with SMTP id ca18e2360f4ac-9490decba4cmr766766739f.10.1763497167604; Tue, 18 Nov 2025 12:19:27 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:26 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 24/31] dyndbg-test: change do_prints testpoint to accept a loopct Date: Tue, 18 Nov 2025 13:18:34 -0700 Message-ID: <20251118201842.1447666-25-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" echo 1000 > /sys/module/test_dynamic_debug/parameters/do_prints This allows its use as a scriptable load generator, to generate dynamic-prefix-emits for flag combinations vs undecorated messages. This will make it easy to assess the cost of the prefixing. Reading the ./do_prints node also prints messages (once) to the-log. Signed-off-by: Jim Cromie --- lib/test_dynamic_debug.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index b2bdfdfb6ba1..fa81177e8089 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -29,18 +29,25 @@ =20 #include =20 -/* re-gen output by reading or writing sysfs node: do_prints */ - -static void do_prints(void); /* device under test */ +/* re-trigger debug output by reading or writing sysfs node: do_prints */ +static void do_prints(unsigned int); /* device under test */ static int param_set_do_prints(const char *instr, const struct kernel_para= m *kp) { - do_prints(); + int rc; + unsigned int ct; + + rc =3D kstrtouint(instr, 0, &ct); + if (rc) { + pr_err("expecting numeric input, using 1 instead\n"); + ct =3D 1; + } + do_prints(ct); return 0; } static int param_get_do_prints(char *buffer, const struct kernel_param *kp) { - do_prints(); - return scnprintf(buffer, PAGE_SIZE, "did do_prints\n"); + do_prints(1); + return scnprintf(buffer, PAGE_SIZE, "did 1 do_prints\n"); } static const struct kernel_param_ops param_ops_do_prints =3D { .set =3D param_set_do_prints, @@ -191,17 +198,20 @@ static void do_levels(void) prdbg(V7); } =20 -static void do_prints(void) +static void do_prints(unsigned int ct) { - pr_debug("do_prints:\n"); - do_cats(); - do_levels(); + /* maybe clamp this */ + pr_debug("do-prints %d times:\n", ct); + for (; ct; ct--) { + do_cats(); + do_levels(); + } } =20 static int __init test_dynamic_debug_init(void) { pr_debug("init start\n"); - do_prints(); + do_prints(1); pr_debug("init done\n"); return 0; } --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) (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 7700E2FFDFB for ; Tue, 18 Nov 2025 20:19:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497173; cv=none; b=GdUB5Bn7YqYWGRP4FQUYh6eBUidLvCxfS7rvn1vqdYZOkTwHakMMibxUt3LaMD0DYS4WuhLvZZ66On3nvu5jWlz2/qarOmkiaqVoAGUuhIkWx2AG2LIgPGIyia93J8kSTrahHTW48/oz8AiGumvbAxIN8PSjfd5RfascMGaA5hU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497173; c=relaxed/simple; bh=vbquuUPp5Q25fDBamY2DiD25GzqK+mwT0T/p2QvKzJE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EyRBlhiPL54HX7QdvhBRchGfXzHb7Co4mq5DvIyIDerlAvuapIawMReUKsJhPSY6T3DO1EwsKpkBYqpxPBClbMHKA+l8iST+P43JHZrrkmJSNzSoQ5G32Ft/CSgdy74bGx+H9Cuowr6vTAAmBGS6hJ1S16YFqeF/u92vYFoPgKM= 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=ZggbnEXW; arc=none smtp.client-ip=209.85.166.51 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="ZggbnEXW" Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-948733e7810so226481039f.0 for ; Tue, 18 Nov 2025 12:19:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497169; x=1764101969; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cg7h9DusbTMg0eiL3l2pzfbIMjlxlhfIO+RD1u8ONBY=; b=ZggbnEXWoEBj6gWL37bgSbOhphr1jjoD5a0Q4gX5l5fy6/svDPyLBPEprUDXeOTopu oYQ6CNqQ9R4QWOq9vjblL7k6BMJ5ATK0qHzA8gNB47rSYBW1FfwkI/oshdY/VV8oen5Y tPyuu5Ti92pnJUXOiuf6cCUdK/NY+UlRD5EJoAzN6fGsKMYmJfeYMSkh6Uqn1nH0mV1e DogDGpuDp7pDoSB9lufoPBc7L3ps1trgN6wvQgH8k3u8d57l2a+0I/Q3//J5BM5RVy2D Grkj41zpXU+Vt5C7+5bnczUwj+BxnJMRUopoX02ORybl+1O1eAru29VI3q8b45Xa5FL6 Vtmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497169; x=1764101969; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cg7h9DusbTMg0eiL3l2pzfbIMjlxlhfIO+RD1u8ONBY=; b=a39uT7Kpgv7C+GYYCaSHmLv+wvPBflEXMy30CObNNPMr2jQDFdyEsZ2xezSnqO041s GZjb8ulh7vsY1dyW8r4bk3GLz0ngexvpcsO6vGknlzmXLJS25AONicyziqKS9HWOdzaj 6k+2bW6ZgUTXVUfl88MbwWcWX3H8d0OaQs/2KPg6mMCaithPI8xfQwc8pxCzN84eHzZw icsC+clJZag7MCHCVwf6jbCTKmq5YO2FfetJfHhkHqYe6h5f/YnQdXpo3hAknVvGBR5n 9etU8T4LVEwGwoL/oK39KiHa/cvO2kVWfh1fn+eXtPoDD79q/vze3AvElKVGcSJZJGRy kRHg== X-Gm-Message-State: AOJu0YzzfYUt81hotXoOt7TOslEt6qr7B+29z+x+qDvIqdF5LDDM1QCp kZV3wBnoO9Lnu7C7kqW7HSHKDwqHD/kYF6YvXcH3nNhMl0DJ7FBID82T/mTphcFU X-Gm-Gg: ASbGncs+XIatO8GFmFVdyICbSID75IuJxiiU93VFb5E53Npt/ozALZpHKVH5l+sSIh9 iIAS0m2/HJ3A1g59wT1m05E1ZvJt+MsOu7ACjDZ1mpnq9bd5bq8t0vFOAcr0oBO6fe9YJoJQKvS wimvda6lKGOCkAY7V0NsoeAdzyH3KzdlB1LQpgU2nt0QZlvgpH8u1T2aaXTgFCOWuJPy7lB0Ofb 5uui4U5LaGXP+0vHpeW41wHOBCncxWQh+z3uFeHLSDUIBgNgxiXJHqr9U2+vwOixRGYGB8AYRy0 lkeooIlkxUn3uLOtav8bIJxxRvxQiTTebCTONT9KZUserk5XCfuRBemaclPns177njYpEWhf0nG gufIna7tODgEeeqKJgy7+pAD0zCHRU0AvrdscAC7WPETa3is2MeLhA1IX6GYXP7oE1Nofk7zxio hdU/G10n5LaiPnkDU4eeADJBSM0AJKDAmc98NfnUQTPzRjCIV++r8KNL27fVQ93v6sHIw= X-Google-Smtp-Source: AGHT+IFYu4ACOQpobmsCVZEJwVweKtlcHag/1hGFezFU+uIvfspwhrOJmtaHGMOIf1bEE9oTjX/eGQ== X-Received: by 2002:a05:6602:2d8c:b0:948:a2aa:edc8 with SMTP id ca18e2360f4ac-948e0d43f0cmr2217545739f.4.1763497168927; Tue, 18 Nov 2025 12:19:28 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:28 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v6 25/31] dyndbg-API: promote DYNAMIC_DEBUG_CLASSMAP_PARAM to API Date: Tue, 18 Nov 2025 13:18:35 -0700 Message-ID: <20251118201842.1447666-26-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" move the DYNAMIC_DEBUG_CLASSMAP_PARAM macro from test-dynamic-debug.c into the header, and refine it, by distinguishing the 2 use cases: 1.DYNAMIC_DEBUG_CLASSMAP_PARAM_REF for DRM, to pass in extern __drm_debug by name. dyndbg keeps bits in it, so drm can still use it as before 2.DYNAMIC_DEBUG_CLASSMAP_PARAM new user (test_dynamic_debug) doesn't need to share state, decls a static long unsigned int to store the bitvec. __DYNAMIC_DEBUG_CLASSMAP_PARAM bottom layer - allocate,init a ddebug-class-param, module-param-cb. Modify ddebug_sync_classbits() argtype deref inside the fn, to give access to all kp members. Also add stub macros, clean up and improve comments in test-code, and add MODULE_DESCRIPTIONs. cc: linux-doc@vger.kernel.org Signed-off-by: Jim Cromie --- -v10 add stub macros -v9 - fixup drm-print.h add PARAM_REF forwarding macros with DYNAMIC_DEBUG_CLASSMAP_PARAM_REF in the API, add DRM_ variant --- include/linux/dynamic_debug.h | 40 ++++++++++++++++++++++ lib/dynamic_debug.c | 60 ++++++++++++++++++++++----------- lib/test_dynamic_debug.c | 47 ++++++++++---------------- lib/test_dynamic_debug_submod.c | 9 ++++- 4 files changed, 106 insertions(+), 50 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index b19c9b1d53b6..b1d11d946780 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -251,6 +251,44 @@ struct _ddebug_class_param { .base =3D _base \ } =20 +/** + * DYNAMIC_DEBUG_CLASSMAP_PARAM - control a ddebug-classmap from a sys-par= am + * @_name: sysfs node name + * @_var: name of the classmap var defining the controlled classes/bits + * @_flags: flags to be toggled, typically just 'p' + * + * Creates a sysfs-param to control the classes defined by the + * exported classmap, with bits 0..N-1 mapped to the classes named. + * This version keeps class-state in a private long int. + */ +#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _var, _flags) \ + static unsigned long _name##_bvec; \ + __DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _name##_bvec, _var, _flags) + +/** + * DYNAMIC_DEBUG_CLASSMAP_PARAM_REF - wrap a classmap with a controlling s= ys-param + * @_name: sysfs node name + * @_bits: name of the module's unsigned long bit-vector, ex: __drm_debug + * @_var: name of the (exported) classmap var defining the classes/bits + * @_flags: flags to be toggled, typically just 'p' + * + * Creates a sysfs-param to control the classes defined by the + * exported clasmap, with bits 0..N-1 mapped to the classes named. + * This version keeps class-state in user @_bits. This lets drm check + * __drm_debug elsewhere too. + */ +#define DYNAMIC_DEBUG_CLASSMAP_PARAM_REF(_name, _bits, _var, _flags) \ + __DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _bits, _var, _flags) + +#define __DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _bits, _var, _flags) \ + static struct _ddebug_class_param _name##_##_flags =3D { \ + .bits =3D &(_bits), \ + .flags =3D #_flags, \ + .map =3D &(_var), \ + }; \ + module_param_cb(_name, ¶m_ops_dyndbg_classes, \ + &_name##_##_flags, 0600) + extern __printf(2, 3) void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); =20 @@ -423,6 +461,8 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, =20 #define DYNAMIC_DEBUG_CLASSMAP_DEFINE(_var, _mapty, _base, ...) #define DYNAMIC_DEBUG_CLASSMAP_USE(_var) +#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _var, _flags) +#define DYNAMIC_DEBUG_CLASSMAP_PARAM_REF(_name, _var, _flags) #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) #define DYNAMIC_DEBUG_BRANCH(descriptor) false #define DECLARE_DYNDBG_CLASSMAP(...) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 25b3932891e0..69a87eb13262 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -687,6 +687,30 @@ static int ddebug_apply_class_bitmap(const struct _dde= bug_class_param *dcp, =20 #define CLASSMAP_BITMASK(width) ((1UL << (width)) - 1) =20 +static void ddebug_class_param_clamp_input(unsigned long *inrep, const str= uct kernel_param *kp) +{ + const struct _ddebug_class_param *dcp =3D kp->arg; + const struct _ddebug_class_map *map =3D dcp->map; + + switch (map->map_type) { + case DD_CLASS_TYPE_DISJOINT_BITS: + /* expect bits. mask and warn if too many */ + if (*inrep & ~CLASSMAP_BITMASK(map->length)) { + pr_warn("%s: input: 0x%lx exceeds mask: 0x%lx, masking\n", + KP_NAME(kp), *inrep, CLASSMAP_BITMASK(map->length)); + *inrep &=3D CLASSMAP_BITMASK(map->length); + } + break; + case DD_CLASS_TYPE_LEVEL_NUM: + /* input is bitpos, of highest verbosity to be enabled */ + if (*inrep > map->length) { + pr_warn("%s: level:%ld exceeds max:%d, clamping\n", + KP_NAME(kp), *inrep, map->length); + *inrep =3D map->length; + } + break; + } +} static int param_set_dyndbg_module_classes(const char *instr, const struct kernel_param *kp, const char *mod_name) @@ -705,26 +729,15 @@ static int param_set_dyndbg_module_classes(const char= *instr, pr_err("expecting numeric input, not: %s > %s\n", instr, KP_NAME(kp)); return -EINVAL; } + ddebug_class_param_clamp_input(&inrep, kp); =20 switch (map->map_type) { case DD_CLASS_TYPE_DISJOINT_BITS: - /* expect bits. mask and warn if too many */ - if (inrep & ~CLASSMAP_BITMASK(map->length)) { - pr_warn("%s: input: 0x%lx exceeds mask: 0x%lx, masking\n", - KP_NAME(kp), inrep, CLASSMAP_BITMASK(map->length)); - inrep &=3D CLASSMAP_BITMASK(map->length); - } v2pr_info("bits:0x%lx > %s.%s\n", inrep, mod_name ?: "*", KP_NAME(kp)); totct +=3D ddebug_apply_class_bitmap(dcp, &inrep, *dcp->bits, mod_name); *dcp->bits =3D inrep; break; case DD_CLASS_TYPE_LEVEL_NUM: - /* input is bitpos, of highest verbosity to be enabled */ - if (inrep > map->length) { - pr_warn("%s: level:%ld exceeds max:%d, clamping\n", - KP_NAME(kp), inrep, map->length); - inrep =3D map->length; - } old_bits =3D CLASSMAP_BITMASK(*dcp->lvl); new_bits =3D CLASSMAP_BITMASK(inrep); v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp)); @@ -1195,15 +1208,24 @@ static const struct proc_ops proc_fops =3D { static void ddebug_sync_classbits(const struct kernel_param *kp, const cha= r *modname) { const struct _ddebug_class_param *dcp =3D kp->arg; + unsigned long new_bits; =20 - /* clamp initial bitvec, mask off hi-bits */ - if (*dcp->bits & ~CLASSMAP_BITMASK(dcp->map->length)) { - *dcp->bits &=3D CLASSMAP_BITMASK(dcp->map->length); - v2pr_info("preset classbits: %lx\n", *dcp->bits); + ddebug_class_param_clamp_input(dcp->bits, kp); + + switch (dcp->map->map_type) { + case DD_CLASS_TYPE_DISJOINT_BITS: + v2pr_info(" %s: classbits: 0x%lx\n", KP_NAME(kp), *dcp->bits); + ddebug_apply_class_bitmap(dcp, dcp->bits, 0UL, modname); + break; + case DD_CLASS_TYPE_LEVEL_NUM: + new_bits =3D CLASSMAP_BITMASK(*dcp->lvl); + v2pr_info(" %s: lvl:%ld bits:0x%lx\n", KP_NAME(kp), *dcp->lvl, new_bits= ); + ddebug_apply_class_bitmap(dcp, &new_bits, 0UL, modname); + break; + default: + pr_err("bad map type %d\n", dcp->map->map_type); + return; } - /* force class'd prdbgs (in USEr module) to match (DEFINEr module) class-= param */ - ddebug_apply_class_bitmap(dcp, dcp->bits, ~0, modname); - ddebug_apply_class_bitmap(dcp, dcp->bits, 0, modname); } =20 static void ddebug_match_apply_kparam(const struct kernel_param *kp, diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index fa81177e8089..83c4d571a8c9 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Kernel module for testing dynamic_debug + * Kernel module to test/demonstrate dynamic_debug features, + * particularly classmaps and their support for subsystems like DRM. * * Authors: * Jim Cromie @@ -57,24 +58,6 @@ module_param_cb(do_prints, ¶m_ops_do_prints, NULL, 0= 600); =20 #define CLASSMAP_BITMASK(width, base) (((1UL << (width)) - 1) << (base)) =20 -/* sysfs param wrapper, proto-API */ -#define DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, _init) \ - static unsigned long bits_##_model =3D _init; \ - static struct _ddebug_class_param _flags##_##_model =3D { \ - .bits =3D &bits_##_model, \ - .flags =3D #_flags, \ - .map =3D &map_##_model, \ - }; \ - module_param_cb(_flags##_##_model, ¶m_ops_dyndbg_classes, \ - &_flags##_##_model, 0600) -#ifdef DEBUG -#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_model, _flags) \ - DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, ~0) -#else -#define DYNAMIC_DEBUG_CLASSMAP_PARAM(_model, _flags) \ - DYNAMIC_DEBUG_CLASSMAP_PARAM_(_model, _flags, 0) -#endif - /* * Demonstrate/test DISJOINT & LEVEL typed classmaps with a sys-param. * @@ -105,12 +88,15 @@ enum cat_disjoint_bits { /* numeric verbosity, V2 > V1 related. V0 is > D2_DRMRES */ enum cat_level_num { V0 =3D 16, V1, V2, V3, V4, V5, V6, V7 }; =20 -/* recapitulate DRM's multi-classmap setup */ +/* + * use/demonstrate multi-module-group classmaps, as for DRM + */ #if !defined(TEST_DYNAMIC_DEBUG_SUBMOD) /* - * In single user, or parent / coordinator (drm.ko) modules, define - * classmaps on the client enums above, and then declares the PARAMS - * ref'g the classmaps. Each is exported. + * For module-groups of 1+, define classmaps with names (stringified + * enum-symbols) copied from above. 1-to-1 mapping is recommended. + * The classmap is exported, so that other modules in the group can + * link to it and control their prdbgs. */ DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BI= TS, D2_CORE, @@ -129,11 +115,13 @@ DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_level_num, DD_CLASS= _TYPE_LEVEL_NUM, V0, "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); =20 /* - * now add the sysfs-params + * for use-cases that want it, provide a sysfs-param to set the + * classes in the classmap. It is at this interface where the + * "v3>v2" property is applied to DD_CLASS_TYPE_LEVEL_NUM inputs. */ =20 -DYNAMIC_DEBUG_CLASSMAP_PARAM(disjoint_bits, p); -DYNAMIC_DEBUG_CLASSMAP_PARAM(level_num, p); +DYNAMIC_DEBUG_CLASSMAP_PARAM(p_disjoint_bits, map_disjoint_bits, p); +DYNAMIC_DEBUG_CLASSMAP_PARAM(p_level_num, map_level_num, p); =20 #ifdef FORCE_CLASSID_CONFLICT /* @@ -144,12 +132,10 @@ DYNAMIC_DEBUG_CLASSMAP_DEFINE(classid_range_conflict,= 0, D2_CORE + 1, "D3_CORE") #endif =20 #else /* TEST_DYNAMIC_DEBUG_SUBMOD */ - /* - * in submod/drm-drivers, use the classmaps defined in top/parent - * module above. + * the +1 members of a multi-module group refer to the classmap + * DEFINEd (and exported) above. */ - DYNAMIC_DEBUG_CLASSMAP_USE(map_disjoint_bits); DYNAMIC_DEBUG_CLASSMAP_USE(map_level_num); =20 @@ -224,6 +210,7 @@ static void __exit test_dynamic_debug_exit(void) module_init(test_dynamic_debug_init); module_exit(test_dynamic_debug_exit); =20 +MODULE_DESCRIPTION("test/demonstrate dynamic-debug features"); MODULE_AUTHOR("Jim Cromie "); MODULE_DESCRIPTION("Kernel module for testing dynamic_debug"); MODULE_LICENSE("GPL"); diff --git a/lib/test_dynamic_debug_submod.c b/lib/test_dynamic_debug_submo= d.c index 672aabf40160..3adf3925fb86 100644 --- a/lib/test_dynamic_debug_submod.c +++ b/lib/test_dynamic_debug_submod.c @@ -1,6 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Kernel module for testing dynamic_debug + * Kernel module to test/demonstrate dynamic_debug features, + * particularly classmaps and their support for subsystems, like DRM, + * which defines its drm_debug classmap in drm module, and uses it in + * helpers & drivers. * * Authors: * Jim Cromie @@ -12,3 +15,7 @@ */ #define TEST_DYNAMIC_DEBUG_SUBMOD #include "test_dynamic_debug.c" + +MODULE_DESCRIPTION("test/demonstrate dynamic-debug subsystem support"); +MODULE_AUTHOR("Jim Cromie "); +MODULE_LICENSE("GPL"); --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.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 447E9369235 for ; Tue, 18 Nov 2025 20:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497173; cv=none; b=XKFCeFtaa86xlNOJaTCLT1F/5knFCLfQW520cBGjN0KhOQUSBgvfjX+GSKtgmngCCw5j8u4VaFLNRhcq1vxgm+4GqHCfbLLJnchi2OW0qNEEC44YgsJWflQftf2OqJK+td9A2rqYp8JOkHcQPLSg8fBUxsY0AiEiX/Cga2DOoKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497173; c=relaxed/simple; bh=fSdaw1JlkB6R9xYAc/koBzsT+rP7nOm1rusWL3YiAew=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eQxmU7hfQgJVB6G3G0FX70rsosZzR0HeQUxVQ0TREm3RevWM/GP34imt1te+JmYT++1l8F+tqzKAmp1T/EjLlRtwBcOXhSF0GLGvLPYv2tVTvwagQvxpv2A54cUxz/vLjpGn7itXJc+DC0ey8/uCT1taxxjQXVCdlv9rui57iMU= 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=YVv5FLpQ; arc=none smtp.client-ip=209.85.166.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="YVv5FLpQ" Received: by mail-io1-f54.google.com with SMTP id ca18e2360f4ac-9491571438cso95885739f.0 for ; Tue, 18 Nov 2025 12:19:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497170; x=1764101970; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iDmLAh6L3qfE5I3PPkJH8Cxtstet5049GvOKQ6v63l0=; b=YVv5FLpQDnTu2zTyWwrIhHxlbPzyYqoipIxStMimK0gcILoYe13f/81DjvQng7DLNv TEmNjSw+Px5qfbcBhQQ7VKNzp3eRIVxc3FVyHw8zFVY6FkX+IUBgk6jCoAxT0LbzT99p ahs9SBKAatOQY/n8IYAclQd4vLiXb5qqWFszoO/SdkLBpOunrSeDWA4wGMZ/IttPFCPi UqjseASUtGUEk29nMjSUachvl8CedNfWO8oPjzbwfVZTbeSYw3HvBWcMjkOyz724gHkQ KkhqoeP8F3at1K2/rSuVeDApOIf7RC9TdJ4SIay3deZXSZe+rboZOY8Lrq1fg/+qPetn iHzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497170; x=1764101970; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=iDmLAh6L3qfE5I3PPkJH8Cxtstet5049GvOKQ6v63l0=; b=C7iTFOSwzNXv1pJpFBr8k1ObArIehIMLYm1G9Q+PU8+ZhiwONF404lkfIfaiJgpc5i cceb0IeiCVJ4J7tjTHSc/KM0BdTSQVCFu3Qn/KFKjp0bJvlX8TXzD3yY/WYGjUUVUMuC kteCJcZDCrNFeduNOhQerZVYJRZgqrq0vQlSYosvdPW40ulbxT15KVtOnnLWVTVFgMBu XmeCturuBVBrU1fsNLUwEhEDEZhlSqXP1WgZICh58GX19uVSTpsa8MGcCv/RPhZrzUzt vV9uiSMFfZlOaOz8o4vdwPoywNqXmhPJC6lG8f1fEqxMCEdwTeoppWL9UV1oNA48fzuM VGAA== X-Gm-Message-State: AOJu0YzD6d9NfTuS0sJLRAJXg7pL+S0YHqZiLkWgPngz9uJWsK94jcdJ 2ElB27h6KB2V5aqi91Ar3OU46ZC8Rs/i6+vLhAtVcYqtKR0UWa4WjZ0ZJ2acS4Kl X-Gm-Gg: ASbGnct2PrVTJJr6VdjXU8F8ZA9XmsL0038Ue+YA21LcskFCzLgupVS7rLpsBAeAwDT rFN3JTPVeM173f+lCAtW1WgGQBd7ZMUymZ0eemH9ZBekqOLXC++xmkn3Myx1wfprkmZKwerdFjx 3gBXwsldWPv8VsxStLU9XoWn9YUpl+LXUp+mFFUzjDkmFfCIhMBXKvTVnW9no7tZtsWEa2wM8bZ RxtPWOzPSq4fL56Vw6JBjN4qHN4ldovVtBn3KPgz/zb2hj25tr5nBe8WlYyRclyckevJ74Xh9bJ ghX2iEIMfhi59H93LyCSQ6zRa+nQQXQCyAQD0ZfP5Ex2AIq9mqo1AlajekijIzKL0pD+Uw9ChW9 4ZUK4dKuLIpLXOdd5szk+GlaGXAYcNewbZXHgYd4WfMb1sKj9JKq2jFZf15D9MyqGg7CovODKkH s1p5x7KT8Z4KYkRyoMWLPt1vKlMknglWEAoALVHCwUOrVaSFrnfCGxBI6X7usPKE5Xjuy0m/Luw EhSSN8vHXTdHeBV X-Google-Smtp-Source: AGHT+IGHKbB65vavYEMOS/NJ+GV6ZutSZ5VWZuxeJuxtFXQ0Q7SAMBMx+6kusKwl8ZMfFS2eoq8GoA== X-Received: by 2002:a02:c004:0:b0:5b7:c784:53a5 with SMTP id 8926c6da1cb9f-5b7c9a3e6f2mr10102281173.0.1763497170093; Tue, 18 Nov 2025 12:19:30 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:29 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 26/31] dyndbg: treat comma as a token separator Date: Tue, 18 Nov 2025 13:18:36 -0700 Message-ID: <20251118201842.1447666-27-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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 Treat comma as a token terminator, just like a space. This allows a user to avoid quoting hassles when spaces are otherwise needed: :#> modprobe drm dyndbg=3Dclass,DRM_UT_CORE,+p\;class,DRM_UT_KMS,+p or as a boot arg: drm.dyndbg=3Dclass,DRM_UT_CORE,+p # todo: support multi-query here Given the many ways a boot-line +args can be assembled and then passed in/down/around shell based tools, this may allow side-stepping all sorts of quoting hassles thru those layers. existing query format: modprobe test_dynamic_debug dyndbg=3D"class D2_CORE +p" new format: modprobe test_dynamic_debug dyndbg=3Dclass,D2_CORE,+p ALSO selftests-dyndbg: add comma_terminator_tests New fn validates parsing and effect of queries using combinations of commas and spaces to delimit the tokens. It manipulates pr-debugs in builtin module/params, so might have deps I havent foreseen on odd configurations. Signed-off-by: Jim Cromie Co-developed-by: =C5=81ukasz Bartosik Signed-off-by: =C5=81ukasz Bartosik --- - skip comma tests if no builtins -v3 squash in tests and doc --- .../admin-guide/dynamic-debug-howto.rst | 9 +++++--- lib/dynamic_debug.c | 17 +++++++++++---- .../dynamic_debug/dyndbg_selftest.sh | 21 ++++++++++++++++++- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index 63a511f2337b..e2dbb5d9b314 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -78,11 +78,12 @@ Command Language Reference =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D =20 At the basic lexical level, a command is a sequence of words separated -by spaces or tabs. So these are all equivalent:: +by spaces, tabs, or commas. So these are all equivalent:: =20 :#> ddcmd file svcsock.c line 1603 +p :#> ddcmd "file svcsock.c line 1603 +p" :#> ddcmd ' file svcsock.c line 1603 +p ' + :#> ddcmd file,svcsock.c,line,1603,+p =20 Command submissions are bounded by a write() system call. Multiple commands can be written together, separated by ``;`` or ``\n``:: @@ -167,9 +168,11 @@ module The given string is compared against the module name of each callsite. The module name is the string as seen in ``lsmod``, i.e. without the directory or the ``.ko`` - suffix and with ``-`` changed to ``_``. Examples:: + suffix and with ``-`` changed to ``_``. =20 - module sunrpc + Examples:: + + module,sunrpc # with ',' as token separator module nfsd module drm* # both drm, drm_kms_helper =20 diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 69a87eb13262..c34de431305d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -320,6 +320,14 @@ static int ddebug_change(const struct ddebug_query *qu= ery, struct flag_settings return nfound; } =20 +static char *skip_spaces_and_commas(const char *str) +{ + str =3D skip_spaces(str); + while (*str =3D=3D ',') + str =3D skip_spaces(++str); + return (char *)str; +} + /* * Split the buffer `buf' into space-separated words. * Handles simple " and ' quoting, i.e. without nested, @@ -333,8 +341,8 @@ static int ddebug_tokenize(char *buf, char *words[], in= t maxwords) while (*buf) { char *end; =20 - /* Skip leading whitespace */ - buf =3D skip_spaces(buf); + /* Skip leading whitespace and comma */ + buf =3D skip_spaces_and_commas(buf); if (!*buf) break; /* oh, it was trailing whitespace */ if (*buf =3D=3D '#') @@ -350,7 +358,7 @@ static int ddebug_tokenize(char *buf, char *words[], in= t maxwords) return -EINVAL; /* unclosed quote */ } } else { - for (end =3D buf; *end && !isspace(*end); end++) + for (end =3D buf; *end && !isspace(*end) && *end !=3D ','; end++) ; if (end =3D=3D buf) { pr_err("parse err after word:%d=3D%s\n", nwords, @@ -622,7 +630,8 @@ static int ddebug_exec_queries(char *query, const char = *modname) if (split) *split++ =3D '\0'; =20 - query =3D skip_spaces(query); + query =3D skip_spaces_and_commas(query); + if (!query || !*query || *query =3D=3D '#') continue; =20 diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/too= ls/testing/selftests/dynamic_debug/dyndbg_selftest.sh index 465fad3f392c..c7bf521f36ee 100755 --- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -216,7 +216,7 @@ function check_err_msg() { function basic_tests { echo -e "${GREEN}# BASIC_TESTS ${NC}" if [ $LACK_DD_BUILTIN -eq 1 ]; then - echo "SKIP" + echo "SKIP - test requires params, which is a builtin module" return fi ddcmd =3D_ # zero everything @@ -238,8 +238,27 @@ EOF ddcmd =3D_ } =20 +function comma_terminator_tests { + echo -e "${GREEN}# COMMA_TERMINATOR_TESTS ${NC}" + if [ $LACK_DD_BUILTIN -eq 1 ]; then + echo "SKIP - test requires params, which is a builtin module" + return + fi + # try combos of spaces & commas + check_match_ct '\[params\]' 4 -r + ddcmd module,params,=3D_ # commas as spaces + ddcmd module,params,+mpf # turn on module's pr-debugs + check_match_ct =3Dpmf 4 + ddcmd ,module ,, , params, -p + check_match_ct =3Dmf 4 + ddcmd " , module ,,, , params, -m" # + check_match_ct =3Df 4 + ddcmd =3D_ +} + tests_list=3D( basic_tests + comma_terminator_tests ) =20 # Run tests --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (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 060A8377E94 for ; Tue, 18 Nov 2025 20:19:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497175; cv=none; b=pvESqp+SkO04WXhVy5wRJOXXqvseA3d3guis6i3OR8Z0ZRPLJf2L0KW2A8woe3t6TUATiJse8dl1AFr/vMshK138vkcO066wJSZuiKlEqUFuMInbjBW5uk9v1EpxiR7q/231AbH3hmlulMUI97hv2ksRlwMuM9pHIqLTZ4AUndQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497175; c=relaxed/simple; bh=KSE7MkB4NgXgxQWMFFlBNfAoIcqlxC5BEzgg/j3dP24=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ICMeezTL0CE3kL2h1hWqJp3x8s5NJWucAFsoxPq6bd/GS/DZ+1qvxmKQhAjnMtxgP5xZJOSPPtfnxnTP3SF8vvuvSG3Po17cp3QPwsXPz0kA+ViAkncVNt0z7NeaUiFZJSiR516G/lWH6gGF76xRAow+N8/T5wCiijHF6LTd7/g= 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=PGPt23Tr; arc=none smtp.client-ip=209.85.166.42 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="PGPt23Tr" Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-9491571438cso95886239f.0 for ; Tue, 18 Nov 2025 12:19:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497171; x=1764101971; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pSs3Y1qOAJs6RAkTlU1X0YsQPOXWFdsurW/bzJWGvXI=; b=PGPt23TrxsH902kjSuGS6FSChWRkUmFj5/Jpaey33dw+YAmIghDVVDa/ezh0qf0qi5 vc1SnqrKqXuVMtAupWuOV+5QUzN6Gs161SeJWsf/46FHAcaf7zd1h95seIJpV/is3gTW UwpSQdUeDYOYKIZJWLn67cGfGzmSwma0ucoOh7GO2GJuj6SKVGxU2chCWW8P9VOzw8Ew VQJQrNmQ4YMEhRUqbtbkIIfUh5djVPC5rMO3JChTtdo/fCsR7InatGWFkzcpXmy4WONk 11hhmQLuCgducic3pPnVLJouVprgR3RLldcuG8fEqt/ZX+97eH0lPMzQ+TPDplLm/sfj 87oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497171; x=1764101971; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pSs3Y1qOAJs6RAkTlU1X0YsQPOXWFdsurW/bzJWGvXI=; b=L17OzuqFFFAjGerA+ellUQO01XQD1EcV5h90fcfBKw3r0e5MRK3ZTkPRa6DCjERLX4 S8ddRZEKeJwJmFKghgLX3y5Q3N9XsWNpj0VTiHWySUcpsnGqlvj/k9oIGKAXtXJHGju9 J8AcgyxMjwBibcJ2TM6ww42y+pVvDm4m6LipwSCDeHZrD9kUwkQpg0NITO1damF6+vGP n+L8/7mqPhcXgPoyO7q/0eIEjxqfNqZqAK8OsteiXZbHSn0ky9ZGk7Pqa2Xy+0pOeDv/ lEnT62f3BMs5yGmJOHW7gm95qSrdMQaxnDHjhP+xTawPNOwZpBPOlLRyUjJYldCCq0cF TVKA== X-Gm-Message-State: AOJu0YzlgQsw2a5SQk92bCCcLdc7p94kZOuc70TF6a6FfyGfZzTWIPkJ 5QR4mwcdDJX9O/OCwemIk2BDmRJSiGpzEXoIt1DLsqyDMbvnZBGqf/JYOOmlCu3C X-Gm-Gg: ASbGnct6FeVMo+BUkZ3hasSrPwRsPgsFCa9uPZepOW/kB22WScgOQyAI+hqIhmZrPf3 OYmqrBva02WnQu6RwA0l2o++cI2UWtH7Uwd2jaBNslBKgCoWw5mLxP5vGhljIqsULnwDf3651NA AzUN3pnl99pT17kFjiy2/1/LOWTAUsYtsZptg5sglgUCcIcTDUdImd7fqI6LV7ivqdpJ0fcAf/M 71ynConZD8g1dBrb70B0LHWTDh3ZIb+jLvanLBFS//fJ21bVat2Mox5FzGZCgTGtD3VPKFaR+Lo 46oQ9ENd5IgC7Wi+doOG9u6naTRhfwEAPpvMpLGKRLOqQYfdPfNTrVxMzODAtIx5+RhQQ6I9/Mw GSAZ+D465Ah2iJMBKW/EjnT5KBkHxnTGrdosv18q947Fjk6L9t3sxO0jGedCSP5FeoK4XlNGa74 Z3xDQi5W3NDprS6mOtDGkrEx3udk6YWTYZQcRlu7T+QIDzdnpKJuybE8t7cOw02ibGaAM0I51Ei 3+zcR65X5ghJhTR X-Google-Smtp-Source: AGHT+IF/109dS81O6NLrPpISZ9YNF9oRBx0yDRnxWROCoBNih0q1Ou0KcWqNxbpWmEkDq5q5rScEtQ== X-Received: by 2002:a05:6638:c114:b0:5b7:bf63:9c2b with SMTP id 8926c6da1cb9f-5b7c9d5acefmr15014841173.12.1763497171298; Tue, 18 Nov 2025 12:19:31 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:30 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 27/31] dyndbg: split multi-query strings with % Date: Tue, 18 Nov 2025 13:18:37 -0700 Message-ID: <20251118201842.1447666-28-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" Since commit 85f7f6c0edb8 ("dynamic_debug: process multiple debug-queries on a line") Multi-query commands have been allowed: modprobe drm dyndbg=3D"class DRM_UT_CORE +p; class DRM_UT_KMS +p" modprobe drm dyndbg=3D< [ 203.902703] dyndbg: query parse failed [ 203.902871] dyndbg: processed 2 queries, with 0 matches, 2 errs bash: echo: write error: Invalid argument The '%' splits the input into 2 queries, and both fail. Given the limited utility of matching against the working parts of a format string "foo: %d bar %s", nothing is actually lost here. selftests-dyndbg: test_percent_splitting This does basic testing of classmaps using '%' separated multi-queries. It modprobes test_dynamic_debug with several classes enabled, and counts to verify that the expected sites show the enablement in the control file. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- -v3 squash feature, test, doc together gate new test, which needs test-dynamic-debug.ko test-percent-escape --- .../admin-guide/dynamic-debug-howto.rst | 8 ++++--- lib/dynamic_debug.c | 2 +- .../dynamic_debug/dyndbg_selftest.sh | 24 +++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index e2dbb5d9b314..1ceadf4f28f9 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -85,10 +85,12 @@ by spaces, tabs, or commas. So these are all equivalen= t:: :#> ddcmd ' file svcsock.c line 1603 +p ' :#> ddcmd file,svcsock.c,line,1603,+p =20 -Command submissions are bounded by a write() system call. -Multiple commands can be written together, separated by ``;`` or ``\n``:: +Command submissions are bounded by a write() system call. Multiple +commands can be written together, separated by ``%``, ``;`` or ``\n``:: =20 - :#> ddcmd "func pnpacpi_get_resources +p; func pnp_assign_mem +p" + :#> ddcmd func foo +p % func bar +p + :#> ddcmd func foo +p \; func bar +p + :#> ddcmd "func foo +p ; func bar +p" :#> ddcmd <<"EOC" func pnpacpi_get_resources +p func pnp_assign_mem +p diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c34de431305d..636a6b5741f7 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -626,7 +626,7 @@ static int ddebug_exec_queries(char *query, const char = *modname) int i, errs =3D 0, exitcode =3D 0, rc, nfound =3D 0; =20 for (i =3D 0; query; query =3D split) { - split =3D strpbrk(query, ";\n"); + split =3D strpbrk(query, "%;\n"); if (split) *split++ =3D '\0'; =20 diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/too= ls/testing/selftests/dynamic_debug/dyndbg_selftest.sh index c7bf521f36ee..513f6cb1db1d 100755 --- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -256,9 +256,33 @@ function comma_terminator_tests { ddcmd =3D_ } =20 +function test_percent_splitting { + echo -e "${GREEN}# TEST_PERCENT_SPLITTING - multi-command splitting on= % ${NC}" + if [ $LACK_TMOD -eq 1 ]; then + echo "SKIP - test requires test-dynamic-debug.ko" + return + fi + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug + ddcmd =3D_ + modprobe test_dynamic_debug dyndbg=3Dclass,D2_CORE,+pf%class,D2_KMS,+p= t%class,D2_ATOMIC,+pm + check_match_ct =3Dpf 1 + check_match_ct =3Dpt 1 + check_match_ct =3Dpm 1 + check_match_ct test_dynamic_debug 23 -r + # add flags to those callsites + ddcmd class,D2_CORE,+mf%class,D2_KMS,+lt%class,D2_ATOMIC,+ml + check_match_ct =3Dpmf 1 + check_match_ct =3Dplt 1 + check_match_ct =3Dpml 1 + check_match_ct test_dynamic_debug 23 -r + ifrmmod test_dynamic_debug +} + tests_list=3D( basic_tests comma_terminator_tests + test_percent_splitting ) =20 # Run tests --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-il1-f176.google.com (mail-il1-f176.google.com [209.85.166.176]) (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 8B453393DE9 for ; Tue, 18 Nov 2025 20:19:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497177; cv=none; b=uQeq4YXRt1HsadGHNV5CtmVHL/XHi9ypPPAjvDApEFeDUdpmCPQZRBAJ2NdrLVkexMl4maiHIThdWuY3zRYzWQVE7GLEipZW8rTcDD1wyLHhPZ8Gc5AmqvTAwGF1/ITM/GecRZl4jGV6CMig2RjRs3M0h3kz3kW1xwFDYn8pnjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497177; c=relaxed/simple; bh=xlIsHnoTxZ28jgj1HBRw7gqVD6xjdXEs58DpB9g7Tvc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p878uPVLYvNAAnr7XGRqRT6rCOTgREd8yPb5I+i+VPqfPO9MU6ppoeJVa6Fjk14lVpIhVHJpF1ibaq6X+9qW/bD6g0pfvWs2Ekmwn7snF5v4CZ54PTspgS4Q/O6t9eVllyRPJy1xLr9YtaV0uXWVF3HrnyMYmT5wZG99FjYTsPA= 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=OGcsaqr/; arc=none smtp.client-ip=209.85.166.176 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="OGcsaqr/" Received: by mail-il1-f176.google.com with SMTP id e9e14a558f8ab-4336f8e97c3so42512765ab.3 for ; Tue, 18 Nov 2025 12:19:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497172; x=1764101972; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6twf2/xpLjcZPEmlJlQUkGBg342LRmA2abBTvniHwsI=; b=OGcsaqr/zoW328wDnBhSxAyJBHI+GNZaFaJCy2lEtgxP8yOo4A0taR1w3Kn4ctKeHi +ntba1+gxGg91agafNoPqI4vmJabd6WUNHiN37fHWoqw1e9bL5a8J1nfOWkj2jKWNcNW XUZCXDgE7V/t+nd58+jdZkihB/AYSP1Yj/OA6w7NgSK2wAVGyWQK3VGikNW696E9V6F/ upz852yz3M63ZhNxOUaJ1TCMA7btgSxeuMh2So2wmcNfn8yUM+mgVDBelKH16nN9+6nd sevP0rG2WE4DMm38xfX1Y+mUBb0Z9cEQjECFFP5lUdpSzexGsUXOzMTni2xsOC1YXTtt IHzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497172; x=1764101972; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6twf2/xpLjcZPEmlJlQUkGBg342LRmA2abBTvniHwsI=; b=hcvYkQY9+VohPBfHud+wTX2os74TEqLs6DqR5e1jByEkfsZ2hy1i10XFbrKGZKuuWO JbZfTFWuDAKZs6Vll1a+BGmcq+2vJ85fogR3+lccChFuxQk4EQ8YOCcxX22OWLnVCILb q/6FiMIg9QxfNx7rz+utgbz8G0r2Ln9TN4XDDZdKSmRYERwzvbAG/dibmTTtn2rFSMeH dzbl5k+apfvxNWJ2vQeLUlT4HDidep3JGLv7vX1kXVKnQ1FRaDaAq0mZTMtTachSyhs9 WrCrMBsF/udm1N6BHoSU+JvsOYt9vhKbFhNlNqfNATXyErJAhMUbxXLLAzCejoC0/kj7 mOsQ== X-Gm-Message-State: AOJu0YxXXc7f70R0GyKxUWdifA20Y6PEJUDFoctlXWeVp85uBCiqWOCo N2VltxLi3ZPQ4dvbn/9v6SqZh9Tstf65pzbeRqKgZOusCMXtMyT8lY6Z1J5O1MFh X-Gm-Gg: ASbGncvrxnC2kLFvuPADtJ2ZE5pBMuVlZsMKy2jWRJ91xIyJyiNSdd40oSlOqmCo/v2 BhnLpzPbUd/qrfuBHmULSSfiQQpSuOiO2tQ1bKg15Bp7tAKE9XkWQhxdFqp9SOzCk5ZRe8eAfoE z9JLXiYilSiAHDjZ5oZvIkdpYte3O9WGRPZknWQfcVdmSF6vqs71WW/Y6nN0pYj7qBkyIFqqIm3 sExgHcwLA0iv8h4g7ofPTx7i1FdYuiih4vJF5JJkwAWo3OZbCUvAIZykqRlSO7m2FoiOBHReBtG UaxCFHePndHoTPRMEypuoXfrj0SdxTXwW6ZPWvveBaqEYMxTAlkc8yddO8pYcm51zABDa4cby6b ci45j5qFMBxkb604GCHipP8+1mnfHOQRwDv4EELASY8Z/2IqFX2x0xl0eca28P9Y7Eu+isuC1i9 r1c2HhUvIYLWmDUUv3QFVyiu1Hq3H0d8QDRVytAK6Ch6f4CFzbprcrPXiQsGSIM8dcnMA= X-Google-Smtp-Source: AGHT+IFkYXoGTAt3RUYgUsveyerauYsUeZyuGCuESFN5PjmKiqmJ3J3pTqwdApcoCmHPHik0qX6Eqw== X-Received: by 2002:a05:6e02:e:b0:425:7534:ab09 with SMTP id e9e14a558f8ab-4348c88fff8mr219681895ab.7.1763497172358; Tue, 18 Nov 2025 12:19:32 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:31 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 28/31] selftests-dyndbg: add test_mod_submod Date: Tue, 18 Nov 2025 13:18:38 -0700 Message-ID: <20251118201842.1447666-29-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" This new test-fn runs 3 module/submodule modprobe scenarios, variously using both the generic dyndbg=3D modprobe arg, and the test-module's classmap-params to manipulate the test-mod*'s pr_debugs. In all cases, the current flag-settings are counted and tested vs expectations. The 3rd scenario recapitulates the DRM_USE_DYNAMIC_DEBUG=3Dy failure. 1. 2 modprobes (super then sub), with separate dyndbg=3Dclass-settings check module specific flag settings 2. modprobe submod, supermod is auto-loaded set supermod class-params check expected enablements in super & submod 3. modprobe super, with param=3Dsetting (like drm.debug=3D0x1ef) modprobe submod validate submod's class'd pr_debugs get properly enabled The test uses multi-queries, with both commas and percents (to avoid spaces and quoting). This is the main reason the test wasn't earlier in the patchset, closer to the classmap patches its validating. With some tedium, the tests could be refactored to split out early tests which avoid multi-cmds, and test only the class-params. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- r3 - skip test if LACK_TMOD older drop -v used in test_mod_submod(). V=3D1 does it for whole test ifrmmod at test end (Lukasz) test-mod-tmod --- .../dynamic_debug/dyndbg_selftest.sh | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/too= ls/testing/selftests/dynamic_debug/dyndbg_selftest.sh index 513f6cb1db1d..09937dca3056 100755 --- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh +++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh @@ -279,10 +279,83 @@ function test_percent_splitting { ifrmmod test_dynamic_debug } =20 +function test_mod_submod { + echo -e "${GREEN}# TEST_MOD_SUBMOD ${NC}" + if [ $LACK_TMOD -eq 1 ]; then + echo "SKIP - test requires test-dynamic-debug.ko" + return + fi + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug + ddcmd =3D_ + + # modprobe with class enablements + modprobe test_dynamic_debug \ + dyndbg=3Dclass,D2_CORE,+pf%class,D2_KMS,+pt%class,D2_ATOMIC,+pm + + check_match_ct '\[test_dynamic_debug\]' 23 -r + check_match_ct =3Dpf 1 + check_match_ct =3Dpt 1 + check_match_ct =3Dpm 1 + + modprobe test_dynamic_debug_submod + check_match_ct test_dynamic_debug_submod 23 -r + check_match_ct '\[test_dynamic_debug\]' 23 -r + check_match_ct test_dynamic_debug 46 -r + + # no enablements propagate here + check_match_ct =3Dpf 1 + check_match_ct =3Dpt 1 + check_match_ct =3Dpm 1 + + # change classes again, this time submod too + ddcmd class,D2_CORE,+mf%class,D2_KMS,+lt%class,D2_ATOMIC,+ml "# add so= me prefixes" + check_match_ct =3Dpmf 1 + check_match_ct =3Dplt 1 + check_match_ct =3Dpml 1 + # submod changed too + check_match_ct =3Dmf 1 + check_match_ct =3Dlt 1 + check_match_ct =3Dml 1 + + # now work the classmap-params + # fresh start, to clear all above flags (test-fn limits) + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug + modprobe test_dynamic_debug_submod # get supermod too + + echo 1 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits + echo 4 > /sys/module/test_dynamic_debug/parameters/p_level_num + # 2 mods * ( V1-3 + D2_CORE ) + check_match_ct =3Dp 8 + echo 3 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits + echo 0 > /sys/module/test_dynamic_debug/parameters/p_level_num + # 2 mods * ( D2_CORE, D2_DRIVER ) + check_match_ct =3Dp 4 + echo 0x16 > /sys/module/test_dynamic_debug/parameters/p_disjoint_bits + echo 0 > /sys/module/test_dynamic_debug/parameters/p_level_num + # 2 mods * ( D2_DRIVER, D2_KMS, D2_ATOMIC ) + check_match_ct =3Dp 6 + + # recap DRM_USE_DYNAMIC_DEBUG regression + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug + # set super-mod params + modprobe test_dynamic_debug p_disjoint_bits=3D0x16 p_level_num=3D5 + check_match_ct =3Dp 7 + modprobe test_dynamic_debug_submod + # see them picked up by submod + check_match_ct =3Dp 14 + ifrmmod test_dynamic_debug_submod + ifrmmod test_dynamic_debug +} + tests_list=3D( basic_tests + # these require test_dynamic_debug*.ko comma_terminator_tests test_percent_splitting + test_mod_submod ) =20 # Run tests --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178]) (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 A0B033A5E62 for ; Tue, 18 Nov 2025 20:19:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497179; cv=none; b=TTYletthOg4FUekQGDuzK5KeGC8kvZgnS/JHDG+JVopUlVjC6iy5P9KUoKl+OWvsfSLw2bYF0ftBIo517+tH9TEtgCETkL50DgsIqlVk3LI6l1vVOD4DjIVE3D2EuUeLUQhFanM63PmipHcIiBUD7MHx0EsNJgfLWqCI0UhvrI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497179; c=relaxed/simple; bh=VMrdZA7s31F2GEdrtj8PHSNZKtDjrq0E2iTShqTqv5M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oZRqtQHjrz9aHkzHGLFBOe9AWjKh21GlWzrOxZ0WNXz28Z6WmmzQKFq9MIEFP1gMhn14LeyTV2ruwDiUL5AofMN4iUuKLrlmy/EKAsNU8cMz0z8xRBCFbvDXDY9O+Xfv/IUOLE6PDg/p0zx3yTEidkayBuiHDbaGeB3ErJmBG+Q= 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=cVcJQ/VU; arc=none smtp.client-ip=209.85.166.178 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="cVcJQ/VU" Received: by mail-il1-f178.google.com with SMTP id e9e14a558f8ab-4332ae0635fso34810655ab.2 for ; Tue, 18 Nov 2025 12:19:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497173; x=1764101973; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C1toahUY738pvkwlfUtafPSZY20olgovUh6swweGApM=; b=cVcJQ/VUxSTuBMpZwOhtzm8AE5Qs5G6AehZD39HtZTnVHSKdfBuo7v2x+n0sYqV0PP xxxvpGeKwENBYMXJLMG0Diywo2/z5ZAqCXqDq+u4igErrnRh7qgj64vku7MwikY5UIE1 PGhZkOUX1HKilHbUiuj6cJicuLfB/mVu8sjHHZNVOMEcvmmK+pyWRSYViBk5NUpTPmYy /fvhoGkUUTN8jq/c29e42+rhCf66qwT7pTyd2hVv/7v2E/f5v3oSEFb3EaE6nMxq0SIR iccMyJ7lkvW4yo4XnOZSnrqfXH/o1CW1dJIUsyyCj5VJaLdXgOTfW1HRRHbZUJXwxORe 1wfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497173; x=1764101973; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=C1toahUY738pvkwlfUtafPSZY20olgovUh6swweGApM=; b=DCONJkIGdl9PZn4ovLPMoGYtx8AphqwB4IU3boMefKDN/XYuHH2rKYhl76Cpea/H0/ PWifwuU9uMD6at7PzDY8sPL+Mv8sGrNA0qE8flK2LHbIn2UnTeBIkSTDZUhRwD6hkxRz W/yCMlHoZRj93kLNB+lpcXdRETFVyiu2CLh6hQO9ZZqCUz1g81zmKfKJtlz7IHaY/vJw fob0yoOJ/4GMQVCLbAPTSQ682dcSYN22YkJ17HFcJlu+nX3yinRpA0n1s8Vsv9h57ouo Kh1uhQgTphbjzSCqtqLhQNSGoAUEL3AZgad+VTw/JqfxhgrJO7cmZ0CJDD1zoNwUoNlF QbYg== X-Gm-Message-State: AOJu0YzoYZCSzNdCRrSTHbSSYjdxG8gp1K4EYPW4WybalyfvVVmTWt+c 2MZ7VLsz8T026nZYerU8xAhQj4jBVYnKQQ5bJLZ8zZi8hIybJhivKIoOvaA9MGQn X-Gm-Gg: ASbGncvezNUqE+cyfRX9uEydLvna6hV4zgX9XmIzCuiLQlHf5V+8Fx16Gni8eNmUDet ExMOAQi9+YGtc7vMBjgwt+U7gHQqDhmy7Fo6UcluevSif22cuY3+DrYLfYi4aptBd7dnqxJTZTX eYCc3zQ+prGQkyJbpQQA3GnffuXqCZ9Toq533+Du32HHKTR+AHGSQIvPA72cyjREBAZ5iFUke7f XH2nFxyfwyR6xbpjl4vToZphPyF98gvKI7Fl2+UMXHWLTVYrmozDeTbnxtzjmTP3hADkDawHIYH OhG2kMAwsPGJYB19GWqYPnzN/oh9F9rHg4TVssrBNo3crjWtudMZMQqzql61H8wYZDs1Tg1JdL8 e6zHNzlqpnFybKp3IQipd/3ZzWUaghgR9JGDJJbGLQhNHX//ILzD6hTQgZfOBYrTh6fHCLKeBS5 GgUPTqvYuOmUzIPOPw8iWnAAtKkFvybxvMZe6iJccRRgyUzC9ed0FEoOIqfsyXfLc0f+Q= X-Google-Smtp-Source: AGHT+IEP/UZHqJYFr/A1jMUV1bsPYuwts+iE/3zNuDLcQ/zAkDIdEP2KDusPSuCu3YA1VHfgKSswRw== X-Received: by 2002:a05:6e02:1fea:b0:433:2b02:af4d with SMTP id e9e14a558f8ab-4348c867cfbmr207286605ab.12.1763497173341; Tue, 18 Nov 2025 12:19:33 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:32 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 29/31] dyndbg: resolve "protection" of class'd pr_debug Date: Tue, 18 Nov 2025 13:18:39 -0700 Message-ID: <20251118201842.1447666-30-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" classmap-v1 code protected class'd pr_debugs from unintended changes by unclassed/_DFLT queries: # - to declutter examples: alias ddcmd=3D'echo $* > /proc/dynamic_debug/control' # IOW, this should NOT alter drm.debug settings ddcmd -p # Instead, you must name the class to change it. # Protective but tedious ddcmd class DRM_UT_CORE +p # Or do it the (old school) subsystem way # This is ABI !! echo 1 > /sys/module/drm/parameters/debug Since the debug sysfs-node is ABI, if dyndbg is going to implement it, it must also honor its settings; it must at least protect against accidental changes to its classes from legacy queries. The protection allows all previously conceived queries to work the way they always have; ie select the same set of pr_debugs, despite the inclusion of whole new classes of pr_debugs. But that choice has 2 downsides: 1. "name the class to change it" makes a tedious long-winded interface, needing many commands to set DRM_UT_* one at a time. 2. It makes the class keyword special in some sense; the other keywords skip only on query mismatch, otherwise the code falls thru to adjust the pr-debug site. Jason Baron didn't like v1 on point 2. Louis Chauvet didn't like recent rev on point 1 tedium. But that said: /sys/ is ABI, so this must be reliable: #> echo 0x1f > /sys/module/drm/parameters/debug It 'just works' without dyndbg underneath; we must deliver that same stability. Convenience is secondary. The new resolution: If ABI is the blocking issue, then no ABI means no blocking issue. IOW, if the classmap has no presence under /sys/*, ie no PARAM, there is no ABI to guard, and no reason to enforce a tedious interface. In the future, if DRM wants to alter this protection, that is practical, but I think default-on is the correct mode. So atm classes without a PARAM are unprotected at >control, allowing admins their shortcuts. I think this could satisfy all viewpoints. That said, theres also a possibility of wildcard classes: #> ddcmd class '*' +p Currently, the query-class is exact-matched against each module's classmaps.names. This gives precise behavior, a good basis. But class wildcards are possible, they just did'nt appear useful for DRM, whose classmap names are a flat DRM_UT_* namespace. IOW, theres no useful selectivity there: #> ddcmd class "DRM_*" +p # these enable every DRM_* class #> ddcmd class "DRM_UT_*" +p #> ddcmd class "DRM_UT_V*" +p # finally select just 1: DRM_UT_VBL #> ddcmd class "DRM_UT_D*" +p # but this gets 3 #> ddcmd class "D*V*" +p # here be dragons But there is debatable utility in the feature. #> ddcmd class __DEFAULT__ -p # what about this ? #> ddcmd -p # thats what this does. automatically Anyway, this patch does: 1. adds link field from _ddebug_class_map to the .controlling_param 2. sets it in ddebug_match_apply_kparam(), during modprobe/init, when options like drm.debug=3DVAL are handled. 3. ddebug_class_has_param() now checks .controlling_param 4. ddebug_class_wants_protection() macro renames 3. this frames it as a separable policy decision 5. ddebug_match_desc() gets the most attention: a. move classmap consideration to the bottom this insures all other constraints act 1st. allows simpler 'final' decisions. b. split class choices cleanly on query: class FOO vs none, and class'd vs _DPRINTK_CLASS_DFLT site. c. calls 4 when applying a class-less query to a class'd pr_debug here we need a new fn to find the classmap with this .class_id d. calls new ddebug_find_classmap_by_class_id(). when class-less query looks at a class'd pr_debug. finds classmap, which can then decide, currently by PARAM existence. NOTES: protection is only against class-less queries, explicit "class FOO" adjustments are allowed (that is the mechanism). The drm.debug sysfs-node heavily under-specifies the class'd pr_debugs it controls; none of the +mfls prefixing flags have any effect, and each callsite remains individually controllable. drm.debug just toggles the +p flag for all the modules' class'd pr_debugs. Signed-off-by: Jim Cromie --- history -v0 - original, before classmaps: no special case keywords -v1 - "class DEFAULT" is assumed if not mentioned. this protects classes from class-less queries -v2.pre-this-patch - protection macro'd to false -v2.with-this-patch - sysfs knob decides -v2.speculative - module decides wrt classmap protection seems unneeded now, TBD v3 - new patch v4 - drop fn-scope map var, with 2 local vars, renamed to purpose - fix for NULL ptr case. - Add loop-var to reduce many "&dt->info." exprs to "di->" - add 1-liner postcondition comments fixus --- include/linux/dynamic_debug.h | 14 ++-- lib/dynamic_debug.c | 127 +++++++++++++++++++++++++++------- 2 files changed, 110 insertions(+), 31 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index b1d11d946780..b22da40e2583 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -75,6 +75,7 @@ enum ddebug_class_map_type { * map @class_names 0..N to consecutive constants starting at @base. */ struct _ddebug_class_map { + struct _ddebug_class_param *controlling_param; const struct module *mod; /* NULL for builtins */ const char *mod_name; const char **class_names; @@ -259,7 +260,12 @@ struct _ddebug_class_param { * * Creates a sysfs-param to control the classes defined by the * exported classmap, with bits 0..N-1 mapped to the classes named. - * This version keeps class-state in a private long int. + * + * Since sysfs-params are ABI, this also protects the classmap'd + * pr_debugs from un-class'd `echo -p > /proc/dynamic_debug/control` + * changes. + * + * This keeps class-state in a private long int. */ #define DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _var, _flags) \ static unsigned long _name##_bvec; \ @@ -272,10 +278,8 @@ struct _ddebug_class_param { * @_var: name of the (exported) classmap var defining the classes/bits * @_flags: flags to be toggled, typically just 'p' * - * Creates a sysfs-param to control the classes defined by the - * exported clasmap, with bits 0..N-1 mapped to the classes named. - * This version keeps class-state in user @_bits. This lets drm check - * __drm_debug elsewhere too. + * Like DYNAMIC_DEBUG_CLASSMAP_PARAM, but maintains param-state in + * extern @_bits. This lets DRM check __drm_debug elsewhere too. */ #define DYNAMIC_DEBUG_CLASSMAP_PARAM_REF(_name, _bits, _var, _flags) \ __DYNAMIC_DEBUG_CLASSMAP_PARAM(_name, _bits, _var, _flags) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 636a6b5741f7..1082e0273f0e 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -206,6 +206,50 @@ ddebug_find_valid_class(struct _ddebug_info const *di,= const char *query_class, return NULL; } =20 +static bool ddebug_class_in_range(const int class_id, const struct _ddebug= _class_map *map) +{ + return (class_id >=3D map->base && + class_id < map->base + map->length); +} + +static struct _ddebug_class_map * +ddebug_find_map_by_class_id(struct _ddebug_info *di, int class_id) +{ + struct _ddebug_class_map *map; + struct _ddebug_class_user *cli; + int i; + + for_subvec(i, map, di, maps) + if (ddebug_class_in_range(class_id, map)) + return map; + + for_subvec(i, cli, di, users) + if (ddebug_class_in_range(class_id, cli->map)) + return cli->map; + + return NULL; +} + +/* + * classmaps-V1 protected classes from changes by legacy commands + * (those selecting _DPRINTK_CLASS_DFLT by omission). This had the + * downside that saying "class FOO" for every change can get tedious. + * + * V2 is smarter, it protects class-maps if the defining module also + * calls DYNAMIC_DEBUG_CLASSMAP_PARAM to create a sysfs parameter. + * Since the author wants the knob, we should assume they intend to + * use it (in preference to "class FOO +p" >control), and want to + * trust its settings. This gives protection when its useful, and not + * when its just tedious. + */ +static inline bool ddebug_class_has_param(const struct _ddebug_class_map *= map) +{ + return !!(map->controlling_param); +} + +/* re-framed as a policy choice */ +#define ddebug_class_wants_protection(map) (ddebug_class_has_param(map)) + /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching @@ -214,11 +258,10 @@ ddebug_find_valid_class(struct _ddebug_info const *di= , const char *query_class, */ static bool ddebug_match_desc(const struct ddebug_query *query, struct _ddebug *dp, - int valid_class) + struct _ddebug_info *di, + int selected_class) { - /* match site against query-class */ - if (dp->class_id !=3D valid_class) - return false; + struct _ddebug_class_map *site_map; =20 /* match against the source filename */ if (query->filename && @@ -255,7 +298,28 @@ static bool ddebug_match_desc(const struct ddebug_quer= y *query, dp->lineno > query->last_lineno) return false; =20 - return true; + /* + * above are all satisfied, so we can make final decisions: + * 1- class FOO or implied class __DEFAULT__ + * 2- site.is_classed or not + */ + if (query->class_string) { + /* class FOO given, exact match required */ + return (dp->class_id =3D=3D selected_class); + } + /* query class __DEFAULT__ by omission. */ + if (dp->class_id =3D=3D _DPRINTK_CLASS_DFLT) { + /* un-classed site */ + return true; + } + /* site is class'd */ + site_map =3D ddebug_find_map_by_class_id(di, dp->class_id); + if (!site_map) { + /* _UNKNOWN_ class_id. XXX: Allow changes here ? */ + return false; + } + /* module(-param) decides protection */ + return !ddebug_class_wants_protection(site_map); } =20 static int ddebug_change(const struct ddebug_query *query, struct flag_set= tings *modifiers) @@ -265,33 +329,31 @@ static int ddebug_change(const struct ddebug_query *q= uery, struct flag_settings unsigned int newflags; unsigned int nfound =3D 0; struct flagsbuf fbuf, nbuf; - struct _ddebug_class_map *map =3D NULL; - int valid_class; + int selected_class; =20 /* search for matching ddebugs */ mutex_lock(&ddebug_lock); list_for_each_entry(dt, &ddebug_tables, link) { struct _ddebug_info *di =3D &dt->info; + struct _ddebug_class_map *mods_map; =20 /* match against the module name */ if (query->module && !match_wildcard(query->module, di->mod_name)) continue; =20 + selected_class =3D _DPRINTK_CLASS_DFLT; if (query->class_string) { - map =3D ddebug_find_valid_class(&dt->info, query->class_string, - &valid_class); - if (!map) + mods_map =3D ddebug_find_valid_class(di, query->class_string, + &selected_class); + if (!mods_map) continue; - } else { - /* constrain query, do not touch class'd callsites */ - valid_class =3D _DPRINTK_CLASS_DFLT; } =20 for (i =3D 0; i < di->descs.len; i++) { struct _ddebug *dp =3D &di->descs.start[i]; =20 - if (!ddebug_match_desc(query, dp, valid_class)) + if (!ddebug_match_desc(query, dp, di, selected_class)) continue; =20 nfound++; @@ -656,6 +718,7 @@ static int ddebug_exec_queries(char *query, const char = *modname) } =20 /* apply a new class-param setting */ + static int ddebug_apply_class_bitmap(const struct _ddebug_class_param *dcp, const unsigned long *new_bits, const unsigned long old_bits, @@ -1107,12 +1170,6 @@ static void *ddebug_proc_next(struct seq_file *m, vo= id *p, loff_t *pos) return dp; } =20 -static bool ddebug_class_in_range(const int class_id, const struct _ddebug= _class_map *map) -{ - return (class_id >=3D map->base && - class_id < map->base + map->length); -} - static const char *ddebug_class_name(struct _ddebug_info *di, struct _ddeb= ug *dp) { struct _ddebug_class_map *map; @@ -1237,25 +1294,36 @@ static void ddebug_sync_classbits(const struct kern= el_param *kp, const char *mod } } =20 -static void ddebug_match_apply_kparam(const struct kernel_param *kp, - const struct _ddebug_class_map *map, - const char *mod_name) +static struct _ddebug_class_param * +ddebug_get_classmap_kparam(const struct kernel_param *kp, + const struct _ddebug_class_map *map) { struct _ddebug_class_param *dcp; =20 if (kp->ops !=3D ¶m_ops_dyndbg_classes) - return; + return false; =20 dcp =3D (struct _ddebug_class_param *)kp->arg; =20 - if (map =3D=3D dcp->map) { + return (map =3D=3D dcp->map) + ? dcp : (struct _ddebug_class_param *)NULL; +} + +static void ddebug_match_apply_kparam(const struct kernel_param *kp, + struct _ddebug_class_map *map, + const char *mod_name) +{ + struct _ddebug_class_param *dcp =3D ddebug_get_classmap_kparam(kp, map); + + if (dcp) { + map->controlling_param =3D dcp; v2pr_info(" kp:%s.%s =3D0x%lx", mod_name, kp->name, *dcp->bits); vpr_cm_info(map, " %s maps ", mod_name); ddebug_sync_classbits(kp, mod_name); } } =20 -static void ddebug_apply_params(const struct _ddebug_class_map *cm, const = char *mod_name) +static void ddebug_apply_params(struct _ddebug_class_map *cm, const char *= mod_name) { const struct kernel_param *kp; #if IS_ENABLED(CONFIG_MODULES) @@ -1275,6 +1343,13 @@ static void ddebug_apply_params(const struct _ddebug= _class_map *cm, const char * } } =20 +/* + * called from add_module, ie early. it can find controlling kparams, + * which can/does? enable protection of this classmap from class-less + * queries, on the grounds that the user created the kparam, means to + * use it, and expects it to reflect reality. We should oblige him, + * and protect those classmaps from classless "-p" changes. + */ static void ddebug_apply_class_maps(const struct _ddebug_info *di) { struct _ddebug_class_map *cm; --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) (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 6F2353A5E80 for ; Tue, 18 Nov 2025 20:19:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497180; cv=none; b=r+kjlsRj2aoO1/Uird4GWc+wY8ch5nKtffat0KYqz+d7VZTEBqHjEsln8JTL4B8aoXURAcPvlCNmrfn+JrzkDVifJbeUgGCl202TAdmcSS2bdskHyKHc0l2Q0grz7+t//0urCbgfgdOeLRMiwehaZy6xK5KsZlzxCexsXhrZwuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497180; c=relaxed/simple; bh=vxiSdOuWHjMkhFL7/D/79Vvo3vOXK3Mpgsiu+raXiNY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NTssAi2CYo9cShmo6Q7NUmiNV+Ev55cCReihaDexHTIra0qm9ujqfRau7VqW1c64W9u2PrC4TB4BRBXa+yvK0JO/vGTOvDxk85sTpz5kCgk43gO5TGHO1eFd6IJm7+KvraLjSqZQv78XuudUlqoaCyQKYTn9FVyAXQgPYFWfrKs= 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=Z2QnSOJU; arc=none smtp.client-ip=209.85.166.179 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="Z2QnSOJU" Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-433692bbe4fso26137445ab.0 for ; Tue, 18 Nov 2025 12:19:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497174; x=1764101974; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Pzl7FKRTTqXJnEcqZYC3kmINB8k+XvKVj8HTxhUS64o=; b=Z2QnSOJUJmRHMAkOCrv0F5w4AaIeACW2Rt//Dide7dW4RvqY9WWrZJEw3xBnY9p03P LjCkwjgbLOrrpUTmiytDe78RhqcmleMORjCuDoNWpDlEEFIn5X4LU0eN2UZvzDbv7DPB CLLAO1sMYUuu67ZYgUSj1IFwAO1SNY9+90zT6bJUcSmjSdGUpdBR11SAZnxwSJKRundt 3A3te8ZCvxC/h8L7jiN59hR1vMzGEVp4+7S+3a051b6PaAYVGWYbQtIVfQZNq8ptqaWL 9OZdxl7+HKnKipNGAXEDspDZ9wDhjj1rUG+8vDxOKxkG7Ly+Y0vn3D2BqK4zeJKy1mGV sPbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497174; x=1764101974; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Pzl7FKRTTqXJnEcqZYC3kmINB8k+XvKVj8HTxhUS64o=; b=RXr0SOYkx1CZtPRB+uzfTK6xgtKrb4Yzl9UHAkItDGuOFXCvjW3rQf+upmFvW0tvP4 hJgpX4h7IdSfjn9Zx+TuKV6EmlGnyRAXyqhNGD9OHv2nMMxlAfuwWounFhDDKRoupASN 20rGS41zJf9uMe4CK3sT3CqYmljVy6kjAtu/oH2WUjypp1cXPH/C5jv89j5NGAbolVIm m2nOAmdFKA9WWxDHLGjKT2mz2Ht6Yso87LYbWEDNbfHyFodBpbUPgVQw1OdAiW1OImZg cwlJh0Vfnj5guq+5jcZY5NDvVVcA0KjLU9kgiuCYTOALmDWdPA4XfRPuheEPecHq9MCm sfUg== X-Gm-Message-State: AOJu0YwbjYNzvB36j2oJM1rXKjZ0+51d8t8ZEMSVEZhLyAi2N2RzYg3z btKRIrWer4W3dPp5xadKxSpW26VV+Q9yl4Tr5BknTyMeBrS62sIDjci9m7/ONMI8 X-Gm-Gg: ASbGncvWeuZp3cxptvmQXetc3FKjvTWH5XRo1MJps57pk66XtxNEPga9k6xHYZvtOhx xhU8DxGeRHAW6UOmxIND/HAxNUHP1mXw3fYukWVrBlQfFlbrla3BPHiEpzeorSn2Vwegg9ziYbO 7+XJ/DZzlSBTtNoWGwMvYT5TWEJLXcB5b2HQddJw0AXpT9mkOHMsCfWdB32Q7nPwgw4aQ+GleWE RJG3AkrFlg2Yhpqcm9pyAy8tOTvgqxzs2C2RikN6Rbk2N75S82uyZbRrHj7OSqlOllYYPrvdpgP Jdf4JLm8SeVOu6jctddjmCHSFNoDyY+Qy+rSuYOUnU0q8kUCCiBZocvNpD+luWP6bbIk/hqquy2 /3A8KZNYjaIWrHowFWIF6jUc69xyCYPhbiacT6Woxn8STspkSFmet/HIOlYhtaWvet49KNUxOFf SkuLkHUNcF3TD6jzovfkjbR3mTO43QZXgVnByxhpVTsPWplNVtB8G0eg2v1Nd2tLqFR+M= X-Google-Smtp-Source: AGHT+IHrOtzMdyakNuObdh3/HwiaoIGSX4ghGN1icypqK5mgUjKfASizUVusxgNRAZI5rl5+uPN7mA== X-Received: by 2002:a05:6e02:1527:b0:433:30e0:6f68 with SMTP id e9e14a558f8ab-4348c94e1bdmr189470205ab.24.1763497174345; Tue, 18 Nov 2025 12:19:34 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:33 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 30/31] dyndbg: add DYNAMIC_DEBUG_CLASSMAP_USE_(dd_class_name, offset) Date: Tue, 18 Nov 2025 13:18:40 -0700 Message-ID: <20251118201842.1447666-31-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" Allow a module to use 2 classmaps together that would otherwise have a class_id range conflict. Suppose drm-driver does: DYNAMIC_DEBUG_CLASSMAP_USE(drm_debug_classes); DYNAMIC_DEBUG_CLASSMAP_USE(drm_accel_xfer_debug); And (for some reason) drm-accel will not define their constants to avoid DRM's 0..10 reservations (seems a long stretch). So I dont think this potential conflict would become an issue until we have at least a 3-X-3 of classmap-defns X classmap-users So drop this if its too speculative, knowing theres at least a notional solution should the situation arise. Signed-off-by: Jim Cromie --- re-ref of an lvalue is fine. CHECK: Macro argument reuse '_var' - possible side-effects? -v5+ less hand-wavy --- include/linux/dynamic_debug.h | 30 +++++++++++++++++++++++------- lib/dynamic_debug.c | 19 ++++++++++++------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index b22da40e2583..5307be8da5c1 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -87,7 +87,7 @@ struct _ddebug_class_map { struct _ddebug_class_user { char *mod_name; struct _ddebug_class_map *map; - const int base; /* user offset to re-number the used map */ + const int offset; /* offset from map->base */ }; =20 /* @@ -235,21 +235,37 @@ struct _ddebug_class_param { /** * DYNAMIC_DEBUG_CLASSMAP_USE - refer to a classmap, DEFINEd elsewhere. * @_var: name of the exported classmap var - * @_not_yet: _base-like, but applies only to this USEr. (if needed) * * This tells dyndbg that the module has prdbgs with classids defined * in the named classmap. This qualifies "class NAME" >controls on - * the user module, and ignores unknown names. + * the user module, and ignores unknown names. This is a wrapper for + * DYNAMIC_DEBUG_CLASSMAP_USE_() with a base offset of 0. */ -#define DYNAMIC_DEBUG_CLASSMAP_USE(_var) \ - DYNAMIC_DEBUG_CLASSMAP_USE_(_var, 0, __UNIQUE_ID(_ddebug_class_user)) -#define DYNAMIC_DEBUG_CLASSMAP_USE_(_var, _base, _uname) \ +#define DYNAMIC_DEBUG_CLASSMAP_USE(_var) \ + DYNAMIC_DEBUG_CLASSMAP_USE_(_var, 0) + +/** + * DYNAMIC_DEBUG_CLASSMAP_USE_ - refer to a classmap with a manual offset. + * @_var: name of the exported classmap var to use. + * @_offset: an integer offset to add to the class IDs of the used map. + * + * This is an extended version of DYNAMIC_DEBUG_CLASSMAP_USE(). It should + * only be used to resolve class ID conflicts when a module uses multiple + * classmaps that have overlapping ID ranges. + * + * The final class IDs for the used map will be calculated as: + * original_map_base + class_index + @_base. + */ +#define DYNAMIC_DEBUG_CLASSMAP_USE_(_var, _offset) \ + __DYNAMIC_DEBUG_CLASSMAP_USE(_var, _offset, __UNIQUE_ID(_ddebug_class_use= r)) + +#define __DYNAMIC_DEBUG_CLASSMAP_USE(_var, _offset, _uname) \ extern struct _ddebug_class_map _var; \ static struct _ddebug_class_user __aligned(8) __used \ __section("__dyndbg_class_users") _uname =3D { \ .mod_name =3D KBUILD_MODNAME, \ .map =3D &(_var), \ - .base =3D _base \ + .offset =3D _offset \ } =20 /** diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 1082e0273f0e..bf1ff29cca95 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -198,7 +198,7 @@ ddebug_find_valid_class(struct _ddebug_info const *di, = const char *query_class, if (idx >=3D 0) { vpr_di_info(di, "class-ref: %s -> %s.%s ", cli->mod_name, cli->map->mod_name, query_class); - *class_id =3D idx + cli->map->base; + *class_id =3D idx + cli->map->base - cli->offset; return cli->map; } } @@ -206,12 +206,17 @@ ddebug_find_valid_class(struct _ddebug_info const *di= , const char *query_class, return NULL; } =20 -static bool ddebug_class_in_range(const int class_id, const struct _ddebug= _class_map *map) +static bool ddebug_class_map_in_range(const int class_id, const struct _dd= ebug_class_map *map) { return (class_id >=3D map->base && class_id < map->base + map->length); } =20 +static bool ddebug_class_user_in_range(const int class_id, const struct _d= debug_class_user *user) +{ + return ddebug_class_map_in_range(class_id - user->offset, user->map); +} + static struct _ddebug_class_map * ddebug_find_map_by_class_id(struct _ddebug_info *di, int class_id) { @@ -220,11 +225,11 @@ ddebug_find_map_by_class_id(struct _ddebug_info *di, = int class_id) int i; =20 for_subvec(i, map, di, maps) - if (ddebug_class_in_range(class_id, map)) + if (ddebug_class_map_in_range(class_id, map)) return map; =20 for_subvec(i, cli, di, users) - if (ddebug_class_in_range(class_id, cli->map)) + if (ddebug_class_user_in_range(class_id, cli)) return cli->map; =20 return NULL; @@ -1177,12 +1182,12 @@ static const char *ddebug_class_name(struct _ddebug= _info *di, struct _ddebug *dp int i; =20 for_subvec(i, map, di, maps) - if (ddebug_class_in_range(dp->class_id, map)) + if (ddebug_class_map_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 for_subvec(i, cli, di, users) - if (ddebug_class_in_range(dp->class_id, cli->map)) - return cli->map->class_names[dp->class_id - cli->map->base]; + if (ddebug_class_user_in_range(dp->class_id, cli)) + return cli->map->class_names[dp->class_id - cli->map->base - cli->offse= t]; =20 return NULL; } --=20 2.51.1 From nobody Tue Dec 2 02:32:13 2025 Received: from mail-il1-f178.google.com (mail-il1-f178.google.com [209.85.166.178]) (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 A54D536998E for ; Tue, 18 Nov 2025 20:19:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497181; cv=none; b=B0oQImfgUHyNw9IZ+IwftgPxg6N7qDQMIaBYMiBM69+pVgqwm3MTA5DN7gYnBvhB7bo7h91b+nlb3U/NVbduzjbffvYKJnoZUoneC4O5bTuNVQDQob54/VDxmcHh2BMim5HL7jm039J9HbEfqszqzBRqV6bDAvEAqH7u63ePBfA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497181; c=relaxed/simple; bh=O+tXmXknX0a9JEgbiNHhwp0EAjn+/AMT7eM05GGU3Pw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O/BYt6tsz/iHx3d/wQtyytGZoVXxrVN/kWYRN+8X5KX0DrIP28llxDQ9yz4/4x+3l1kx8NrfOd3vk4KZzjkcy7kUtoTFqAZqk8Di5KbKIbTOdB6S7fhXDTmmI/hy98EyWEZxSj9vVFhYCrDwpM7PHxUnAdi64l+AkpLHMMuFbbU= 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=MI0dwqYM; arc=none smtp.client-ip=209.85.166.178 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="MI0dwqYM" Received: by mail-il1-f178.google.com with SMTP id e9e14a558f8ab-4337076ae3fso25481945ab.1 for ; Tue, 18 Nov 2025 12:19:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497175; x=1764101975; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f6vnJl9LV7HlaaUH7ZnHOrsbcFGdoDkm0Y0taUKZPwI=; b=MI0dwqYMaPQR6sSosMKAqw7EIzS1/DMybrjq+IFvYnFr+jxBm8GdxSHZpcD8VmFnuY w0LjGPtQ62ut0gJdBakhk0feKBbtjeD+drnfGQEzTxb5yGL6rZ4b2EnNuUbi6VpZUMfZ RHLRlRnPsHBy5ObAZHrjmlHpjoI8UW/BGLiKLHKqGYdmVGnyiYQMbAXywOZ+VlhwqWdY Ip9VgHCZvd6XMZ1JOhRktpwyYUharbv/7BhJ90BW3ZeaVL2GEtDiEk3bovkTlITstH9y DxjQTDpC1ISPZFoBC26Zt2XKLWN+UqbVV0aZYqY9b2HyBLZ1wLgrGEehpLN2UkpkkQ6o V6Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497175; x=1764101975; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=f6vnJl9LV7HlaaUH7ZnHOrsbcFGdoDkm0Y0taUKZPwI=; b=GBKe0QKOSF74M9NtJVxa0ppLsv1IarzFP1PNkg/L5A6dOEMvHwbx2vfXVTK5RCCAXW +S/V7ehJimJxYN/hUrx3ZC+0OulfSoMRhtM/+/67nYvIGH1WS1tRnbM/P6HODJxwnMFK oPlSbuRmoGp4wzMIv7YBMYK4uwdSZFHqumbDyZXSSJocyn83e9qlUPw1jPFFQN37S7sv FfMHvjZ99mie5MgA1NTmXvNpwdXyFk8BMahriyrh59Rj+bml0c5S0rSKE3FbkhJ1FkRK 2Jl25gnyEM6LXCRmO5C93YXg4+nuw2TIOW3gO2Zi+0YSJOYa+xxiEEczLkDm+kJdB/vc tjnw== X-Gm-Message-State: AOJu0YzHNKZVwedV3MysBsU2Nk0+yYNHN4yFzZXeleicB367Z5d7e04a F1mZyzN2d2Si3yXlv/r+JWiL9h8TYmsWr5ozSi1o1xWgacQgYWnMK1mmL4kvS+3V X-Gm-Gg: ASbGncu9rvkfKRqNERTQpvLEHG9MwGQcQXGWmOzuZfODx7dU6NZYIqdXGGqKoYvy4vy j3udCZZrd40olf4q/zEn0SylW/wXsvtttd5A+lgdSL+Pq8QihDxWtYn0yME+AlReBroEfND4NMO vXVHVySBQEmnU2Sh0mnpGcCZra9i71mH/4gKzpqZAvLTF2Tks/M35MPBeWRR5LRHhxGtpCn+W8y qxJBfvz3/+r0zFvxHTJBJYazalzREmhQkcw5glzzd8a+DnNsTm12d1siRfbcfn20Fo3DVvEl0EE +hydP1rtQDeNodSf1dFIgYKo+7MBUYcqwmp90HXnvXgtKzTnm1ZeCxYUhsLrtxHmPhoVpAs55bG QwW6d3JubhvrNlY8TAWMPcERkqx/Fdr54XiqSe9I0aU/D5HzZn9sMTauOTniBwdnhhAcJqdoHHf UvbHnTIvI1dx5Aeg5Rws7oBqVSQKWBFYQGp2lfreWGnS4IH1LHkjc2QI4k5lJAIePm39UHnHzVu dc+PA== X-Google-Smtp-Source: AGHT+IFhMgxL8xO7QXjyxKhciV5i56lPkCw/9yrS08t5Daw42RmTXFSJThazbTqGeULpmbYf4wiCjA== X-Received: by 2002:a05:6e02:96f:b0:434:a7ce:da4a with SMTP id e9e14a558f8ab-434a7de20damr88076485ab.30.1763497175351; Tue, 18 Nov 2025 12:19:35 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:34 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie , linux-doc@vger.kernel.org Subject: [PATCH v6 31/31] docs/dyndbg: add classmap info to howto Date: Tue, 18 Nov 2025 13:18:41 -0700 Message-ID: <20251118201842.1447666-32-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-1-jim.cromie@gmail.com> 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" Describe the 3 API macros providing dynamic_debug's classmaps DYNAMIC_DEBUG_CLASSMAP_DEFINE - create & export a classmap DYNAMIC_DEBUG_CLASSMAP_USE - refer to exported map DYNAMIC_DEBUG_CLASSMAP_PARAM - bind control param to the classmap DYNAMIC_DEBUG_CLASSMAP_PARAM_REF + use module's storage - __drm_debug NB: The _DEFINE & _USE model makes the user dependent on the definer, just like EXPORT_SYMBOL(__drm_debug) already does. cc: linux-doc@vger.kernel.org Signed-off-by: Jim Cromie --- v3- rework protection around PARAM v0.5 adjustments per Randy Dunlap v0.7 checkpatch fixes v0.8 more v0.9 rewords fixup-howto --- .../admin-guide/dynamic-debug-howto.rst | 129 ++++++++++++++++-- 1 file changed, 116 insertions(+), 13 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentat= ion/admin-guide/dynamic-debug-howto.rst index 1ceadf4f28f9..adac32a5cd23 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -146,7 +146,9 @@ keywords are::: "1-30" is valid range but "1 - 30" is not. =20 =20 -The meanings of each keyword are: +Keywords::: + +The meanings of each keyword are:: =20 func The given string is compared against the function name @@ -194,16 +196,6 @@ format format "nfsd: SETATTR" // a neater way to match a format with whitespace format 'nfsd: SETATTR' // yet another way to match a format with whitesp= ace =20 -class - The given class_name is validated against each module, which may - have declared a list of known class_names. If the class_name is - found for a module, callsite & class matching and adjustment - proceeds. Examples:: - - class DRM_UT_KMS # a DRM.debug category - class JUNK # silent non-match - // class TLD_* # NOTICE: no wildcard in class names - line The given line number or range of line numbers is compared against the line number of each ``pr_debug()`` callsite. A single @@ -218,6 +210,24 @@ line line -1605 // the 1605 lines from line 1 to line 1605 line 1600- // all lines from line 1600 to the end of the file =20 +class + + The given class_name is validated against each module, which may + have declared a list of class_names it accepts. If the class_name + accepted by a module, callsite & class matching and adjustment + proceeds. Examples:: + + class DRM_UT_KMS # a drm.debug category + class JUNK # silent non-match + // class TLD_* # NOTICE: no wildcard in class names + +.. note :: + + Unlike other keywords, classes are "name-to-change", not + "omitting-constraint-allows-change". See Dynamic Debug Classmaps + +Flags::: + The flags specification comprises a change operation followed by one or more flag characters. The change operation is one of the characters:: @@ -238,11 +248,15 @@ The flags are:: s Include the source file name l Include line number =20 +Notes: + +To query without changing ``+_`` or ``-_``. +To clear all flags ``=3D_`` or ``-fslmpt``. + For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only the ``p`` flag has meaning, other flags are ignored. =20 -Note the regexp ``^[-+=3D][fslmpt_]+$`` matches a flags specification. -To clear all flags at once, use ``=3D_`` or ``-fslmpt``. +The regexp ``^[-+=3D][fslmpt_]+$`` matches a flags specification. =20 =20 Debug messages during Boot Process @@ -394,3 +408,92 @@ just a shortcut for ``print_hex_dump(KERN_DEBUG)``. For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is its ``prefix_str`` argument, if it is constant string; or ``hexdump`` in case ``prefix_str`` is built dynamically. + +Dynamic Debug Classmaps +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The "class" keyword selects prdbgs based on author supplied, +domain-oriented names. This complements the nested-scope keywords: +module, file, function, line. + +The main difference from the others: classes must be named to be +changed. This protects them from unintended overwrite: + + # IOW this cannot undo any drm.debug settings + :#> ddcmd -p + +This protection is needed; /sys/module/drm/parameters/debug is ABI. +drm.debug is authoritative when dyndbg is not used, dyndbg-under-DRM +is an implementation detail, and must not behave erratically, just +because another admin fed >control something unrelated. + +So each class must be enabled individually (no wildcards): + + :#> ddcmd class DRM_UT_CORE +p + :#> ddcmd class DRM_UT_KMS +p + # or more selectively + :#> ddcmd class DRM_UT_CORE module drm +p + +That makes direct >control wordy and annoying, but it is a secondary +interface; it is not intended to replace the ABI, just slide in +underneath and reimplement the guaranteed behavior. So DRM would keep +using the convenient way, and be able to trust it. + + :#> echo 0x1ff > /sys/module/drm/parameters/debug + +That said, since the sysfs/kparam is the ABI, if the author omits the +CLASSMAP_PARAM, theres no ABI to guard, and he probably wants a less +pedantic >control interface. In this case, protection is dropped. + +Dynamic Debug Classmap API +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + +DYNAMIC_DEBUG_CLASSMAP_DEFINE(clname,type,_base,classnames) - this maps +classnames (a list of strings) onto class-ids consecutively, starting +at _base. + +DYNAMIC_DEBUG_CLASSMAP_USE(clname) & _USE_(clname,_base) - modules +call this to refer to the var _DEFINEd elsewhere (and exported). + +DYNAMIC_DEBUG_CLASSMAP_PARAM(clname) - creates the sysfs/kparam, +maps/exposes bits 0..N as class-names. + +Classmaps are opt-in: modules invoke _DEFINE or _USE to authorize +dyndbg to update those classes. "class FOO" queries are validated +against the classes, this finds the classid to alter; classes are not +directly selectable by their classid. + +NB: It is an inherent API limitation (due to int class_id defn) that +the following are possible: + + // these errors should be caught in review + __pr_debug_cls(0, "fake DRM_UT_CORE msg"); // this works + __pr_debug_cls(62, "un-known classid msg"); // this compiles, does nothi= ng + +There are 2 types of classmaps: + + DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, like drm.debug + DD_CLASS_TYPE_LEVEL_NUM: classes are relative, ordered (V3 > V2) + +DYNAMIC_DEBUG_CLASSMAP_PARAM - modelled after module_param_cb, it +refers to a DEFINEd classmap, and associates it to the param's +data-store. This state is then applied to DEFINEr and USEr modules +when they're modprobed. + +The PARAM interface also enforces the DD_CLASS_TYPE_LEVEL_NUM relation +amongst the contained classnames; all classes are independent in the +control parser itself. There is no implied meaning in names like "V4" +or "PL_ERROR" vs "PL_WARNING". + +Modules or module-groups (drm & drivers) can define multiple +classmaps, as long as they (all the classmaps) share the limited 0..62 +per-module-group _class_id range, without overlap. + +If a module encounters a conflict between 2 classmaps its _USEing or +_DEFINEing, it can invoke the extended _USE_(name,_base) macro to +de-conflict the respective ranges. + +``#define DEBUG`` will enable all pr_debugs in scope, including any +class'd ones. This won't be reflected in the PARAM readback value, +but the class'd pr_debug callsites can be forced off by toggling the +classmap-kparam all-on then all-off. --=20 2.51.1