From nobody Tue Feb 10 03:57:33 2026 Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) (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 2D7C32F3632 for ; Wed, 14 Jan 2026 01:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768355930; cv=none; b=tI1O5b971i/y3isNSFbVcdOEirzbKJ5s02ReUy4VSFXjclkiz7PxHzVqtv5z+q4SygAKC2CwcY8tGDjrIpMW+G1b1YkFCMCzDhtLdsSbirbuyAxXeEAAM7vW27B3J/yNaiVdDWgqA1Vmcisyqt4cjl9CjDFKHKWL2bhhRraA7k4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768355930; c=relaxed/simple; bh=J1eDk9ZVPw8FZKq7NBfxm7axQ7Jd97Z9A2H46UDDwHk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A9o8oOsxHZ21kPLO7yDpFAsvr7Dj39P+dPC1TETWJf8/Hksx3S0jtB11YPdjSUdCtG05jX5BSkblW+BE9uNI905s7jcBedTcElWNOrKkigDtir0ByFoUWF6CkjALlNSN5YZqg8QbjaeDbcYK7MbVkhgzkXBxMm1mS7C7bt0upJc= 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=NzkkMq6D; arc=none smtp.client-ip=209.85.210.65 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="NzkkMq6D" Received: by mail-ot1-f65.google.com with SMTP id 46e09a7af769-7c7613db390so5003707a34.2 for ; Tue, 13 Jan 2026 17:58:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768355928; x=1768960728; 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=6JUGCGjJm2Xj6X5n/nhoMCGHMBetXjpQki6LB/h6PNI=; b=NzkkMq6DKrxBwdDJbQF0KXJ/Bv6fpmu9qaNiJSRckfj+g7zGirqdj65Wyqo9MjA+ZG PEje0Z8fjUh2ZO4fC70tmut7UC1vGuJhQnsSuNLbm0reuG6OWE7SWLQv9CB/SGSaqooU yX2N7emaRSj5MDc+pkaJBR6RYmE8vRCm+LHfWUDkUGTyiFksdAfcQClSTX/quofom7UY zdDKP7aRztU1VgncBlciIRrnvpe48F1+i6TDgBypUQT2BRw7MGXgcP2i4a9nrRCyfUou k+ONxJ3G2XVRrrwVWHaFJyylxG6+rAHfcUVrtg9HSY7Ct/Hg7cmKhfexeUlE6sodO5tW Z++g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768355928; x=1768960728; 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=6JUGCGjJm2Xj6X5n/nhoMCGHMBetXjpQki6LB/h6PNI=; b=caUwPiN98PZXG3KoUmVbYQrdD2TMT9je8HW3rG8jUwq8yVH3NFP7dxBUx9ogLT5bLj pyo7YOvbvir6CccOVEF7sQ5YnKLZyZIdqXVCZ3xzXpe+LqA7npyJmul4/lWb7ivyH02x AQiLFVW322sPBIY/WOo0hrDMolFLjnBdTsGsq3+BXHTx++EyGCKQhiKrlllkxG31gSFW ylpUhaBVt4cThSZvWqUlpasuz/ygr66HOIXU5juVbfL9XQzUub3jsCMjFL3a9L1hkz2p 6HB1U8Sfma2krMLvCZzNdtH0tU6JvUjFMj3PHxx0v6dyybqjW+ijWgB/GNkhMjqE2lnv bDiw== X-Forwarded-Encrypted: i=1; AJvYcCUE61LzTt0Cqp5GODPdRGKp1r9sYb7gWLwYAFqkFAco2QGVQHJHimw9PNsKF1VhjnR0K3XV5H4I2ETY7oo=@vger.kernel.org X-Gm-Message-State: AOJu0YzaMFjJFrsUzePeNTCiRk8aVGArZaWE/ib9+pQpAMXp9Nlv3I8X a1M0azIEw/jRFkP3e7GY8Kjaa8ak2UC8cLf5ILlxZ6P3ATaknD9dfGZbaL9zK7u5CG6eDw== X-Gm-Gg: AY/fxX5KDsj27H4hm3CegdlJwodCBIdt4Mcv7HYyb8KKq56RxqlwSUoqFW5ctn65YLc PMX+iyyI/s3iOG+kb4Btb1Kk86EYggeQZkWHnW5tQnDsrvbjgLt99OHQcVMtmRqtpZI/PzHDAW1 tA10EEzWGv+wQ4SD8E3ZRSTc/lBLsSTwtEJ2A8K6WSaDDdlZ8KCduX8MID7mSJnDoOPIFvC0eez A4r/k7uhGmH/ZS8ROavHTluAYNrr4X++QMaQVgbsRzvD7IA+y3ZprwJLmd5Puqp8GJxXmRVrXt2 u/u4qjuhJOr/abFj5rOVe/VluLIHWGebXnicmj35vrk8k+KTsIRhSKNV809ihzqfo8M7xsYgz1Z wTdUtKJToARyY8g2i83i2s4c0A9RdQKUyTKBuLZCFdiQxCNS6+9+MhZdCBMBanOYf0qASYwWwGG N+8aAed8RD4Cr28SIhfL79TRF+pw9QVD9q+6oC X-Received: by 2002:a9d:708f:0:b0:7c7:8280:9206 with SMTP id 46e09a7af769-7cfcb6b1274mr339324a34.38.1768355927952; Tue, 13 Jan 2026 17:58:47 -0800 (PST) Received: from frodo (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 46e09a7af769-7ce4781c447sm16782299a34.9.2026.01.13.17.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 17:58:47 -0800 (PST) From: Jim Cromie To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: Jim Cromie , Jason Baron , =?UTF-8?q?=C5=81ukasz=20Bartosik?= , Louis Chauvet , Bagas Sanjaya , Dave Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org, Petr Mladek , Shuah Khan , linux-doc@vger.kernel.org, Steven Rostedt , "Liam R. Howlett" Subject: [PATCH v8 01/31] dyndbg: factor ddebug_match_desc out from ddebug_change Date: Tue, 13 Jan 2026 18:57:17 -0700 Message-ID: <20260114015815.1565725-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260114015815.1565725-1-jim.cromie@gmail.com> References: <20260114015815.1565725-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.52.0