From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04A35CD5BD1 for ; Tue, 2 Jun 2026 22:48:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6987810F66E; Tue, 2 Jun 2026 22:48:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nk74fVJR"; dkim-atps=neutral Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id 40B0D10F655 for ; Tue, 2 Jun 2026 22:48:35 +0000 (UTC) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-4600ddc4017so2535806f8f.0 for ; Tue, 02 Jun 2026 15:48:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780440514; x=1781045314; darn=lists.freedesktop.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=BdDKIkZQT8kN6q6EUNEFoTcvXlPCpXkuxCaw1ETC1j0=; b=nk74fVJRcbipG0QD/jDzfEydgPiDJC7rRx2pf5Q1q3IfzEqc6pDwEriyam3P4F1+n7 HQbJAZpnwjEAjL6Jkw84XZ5CSPsATv8RdLUXqfuDNDDlTuxqDtzFdK87rMkkde/Nd6/T PYVcz5pdduDVSx6CBWqcU1l7CieQz1oLUTqWdw92PVnhBIMCvLzVvOr/OibI3Y8zHdMS 8xQycI4iK6AbfSpEOEcykvT77VWpW+p1y0dYCDp+E9v50vzEZXEefCMrx/u0FRmOgMDG 6tOQFYFoN7bAsD78bVWdk0n24a9OvmuAVC8rU/oS1mY7SMm5Yvx4hOEgZFratp6rHyAL s0iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780440514; x=1781045314; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=BdDKIkZQT8kN6q6EUNEFoTcvXlPCpXkuxCaw1ETC1j0=; b=cTQfw0MCaxj4duufB9sqBNeFox3QtRi5OYDdFGYta0slw19YeRsg8huA6CDPvooMMt YftrlQ73oDJFbOKll4j5klK4DgJ7CBEk44fiW2livKmQTw5lo8yifAFt7epeTcVCCuQF wNfU7YKRJs3kwM1po7PVFIOU9F7BrDPOvh7oFdkmoEIzT0V6KBZESnsIX3MJkGRG4uqP r8tjlaL9eBRm8N46cyRPLZaea7I01CucFgN057sQVppUxd8dBDxNSvwHDGHfx/u1wcvH 10K87OavQ/zE6aPlzne1aVaJb87h5LCHgOm7TXWaKX9c3pCNl52nfaR+SXE11LMFRNsb 2pSA== X-Forwarded-Encrypted: i=1; AFNElJ9/efQcdBi2J76ohmLqb5vpf+nvwkqG+twrMfx6lzhmdI/z2cf1N2yl8W4G2rQh5SNwnKkN+mSmJOo=@lists.freedesktop.org X-Gm-Message-State: AOJu0YwKPgwC6ibXhDARLvn32i2SEFYuC8pN0eQUp5UAB542KwiDt9KB jNFJUx/Z+myOF1ajm4yKROvpYLt6OnUtshr8XYzBUJ7/kz2mvGdvyOCf X-Gm-Gg: Acq92OGLoMWGRk/+hUaOSgqT0IJF6pb4zSAfsMKlMe6X+sCBxvTvLaS1+j9vyy0ZSsD 8BDvfOU9nmGLNOwh82Cmu4m5WNboUuKaZPtNiWOQCLe1FUx4RYnURdqY6AxqXowaKQacH2Qe0mF 2E1jhYhJRFEkMzq+y3qQKFQTS8uJQcClMWPzZkYfYf/Spwk5RcRcsS4BT7nJ0qkqVvMgIuFuo0N 4buZHCuOP+fVefKQSiERgimFnKEBLvEUMSAf8fABCMbae8dac+YnzDnCr36Xvp9PeXZo6qlQCRU 7h+iO2LNtNC1f1TAYMooEs2yS4lkFgH/EW4tPbNPJLE3EOUKarNJQdeDmYNCdU2fwKnRZAni/L+ s5xrFb9uowOLsx8URw/YAaSjR5Iuul5EXZ1Z16JMGQ1D+hk4KzpKg8eA0kO8D3VeYXsIPJ5cXq1 WTNxZ93xh4G77HqxEAOSOtleu4R/l3MmHyDxNz5zDcVQ== X-Received: by 2002:a5d:624a:0:b0:45e:ce28:666a with SMTP id ffacd0b85a97d-46021781a64mr481587f8f.1.1780440513739; Tue, 02 Jun 2026 15:48:33 -0700 (PDT) Received: from [172.16.188.153] ([213.181.114.83]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4601f2f2710sm1999791f8f.14.2026.06.02.15.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 15:48:33 -0700 (PDT) From: Jim Cromie Date: Tue, 02 Jun 2026 22:48:05 +0000 Subject: [PATCH v4 08/25] dyndbg: factor ddebug_match_desc out from ddebug_change MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260602-dd-maint-2-v4-8-19a1445585a8@gmail.com> References: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> In-Reply-To: <20260602-dd-maint-2-v4-0-19a1445585a8@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780440488; l=4346; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=ytc0P/UZw6i8hpySK2Au28vrT+KoK4/4tvvmOq28NjE=; b=5Nnx0wurAISA7XPWvLxIHjr9MiqVPJsdjQtzB3crXplmEx4Fh70GzBvOTm8YTKred1nIS6x5n Js4PINvk2WlBIWopr7o4sC+XOKirBZgfd5GHiAFVWak9zlb/tYYXGsy X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 Reviewed-by: Louis Chauvet --- 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 18a71a9108d3..6b1e983cfedc 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -172,6 +172,52 @@ static struct ddebug_class_map *ddebug_find_valid_class(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 != 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 == '^') { + char *p; + /* anchored search. match must be at beginning */ + p = strstr(dp->format, query->format + 1); + if (p != 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) { @@ -204,42 +250,7 @@ static int ddebug_change(const struct ddebug_query *query, for (i = 0; i < dt->num_ddebugs; i++) { struct _ddebug *dp = &dt->ddebugs[i]; - /* match site against query-class */ - if (dp->class_id != 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 == '^') { - char *p; - /* anchored search. match must be at beginning */ - p = strstr(dp->format, query->format+1); - if (p != 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; nfound++; -- 2.54.0