From nobody Tue Apr 7 12:53:56 2026 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.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 8E4812F90C5 for ; Fri, 13 Mar 2026 13:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408175; cv=none; b=GiO73BvkbI6MKxg18XC3axOvrZxyUEK25f7YEIPg/Vr+FKyHjsOT3AEiDP0elizZ1vMyKEmAyENinnkD/edTjbFRePmkRPg9tS0VHjkQUE3ZllRK6VtRh42PPR3WvjO+pYZUfSls1NM4u8LNwnnY35+JvgH+Z7kcjmBVJaDbvsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408175; c=relaxed/simple; bh=m4l8y31rHp314wh/pOxhDrUgtpeO5zShqIbyCammnKs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b+118IpwKaQIa5XHtFMUdTGOMHsGfTPPm1FvdCUiyyvb0H8D7nLtU3a2V1d+IQn59w4fTXu2pTmzmCkhthIbOWPkQBC/917l8QWf2MSv5iLhrCpJdTxgue6BBVXRyNvSuJ0/9EWushZOAa9DRTRPFyDvg21K8eWEAeuWZm4po/c= 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=BAjUQiUv; arc=none smtp.client-ip=209.85.167.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="BAjUQiUv" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-467161c4b89so1364615b6e.3 for ; Fri, 13 Mar 2026 06:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773408173; x=1774012973; 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=vePjq7+VFJ5ZhNc2ZqKhZQksj6wQ9j47ntZTNCfs3mg=; b=BAjUQiUvPCMqwRaoTiNYNTxYQWOcyNjEgj28UR26P2EAjncQPFcHzyFo+nhIW5j7Ol SitrkRWOykf87NJmXVK8AYt8PSlkj7wrPd7vFhPL9GHwY6Tn4H3Svg0LpJZx8TCcdTnd PMM5ULtVPdB43Jrt+a1a5B+af0ZwqoD2g7YAJcoKpW2/SMfcWnTkfIHtzQLKjPR2xVk4 oBZL6wWVh66ep0vQFoCBrhYvdbAZqMgsQKNCJIncGbflEsD5/ld1ivaevjuLaX2ytPFn Fdm7me9C6RnsVc7sYLweXLxlwv/PzWxFgvCSA8WDqhj8XX8rBzxa0jiWqGIq3Wcsv8U8 Cq9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773408173; x=1774012973; 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=vePjq7+VFJ5ZhNc2ZqKhZQksj6wQ9j47ntZTNCfs3mg=; b=Ry8xe3C0KzJ/bPnOR0izmPkrCmF/2OMI6hFvNyUS6TScD1c+tKeEyCAf5zyhjd2uwX IFjRA82+mTpQg4ns2iCyHv28dA0o1mTn6yq8d4PWyzTZPSZ9cl67+tjo70ejLhKA7eHu Aug/Hyk/+2DEiA4C4qGPuYhbu23z6LBqokUpcMjMkJWNCqZb9RVwZrlllBmW0MXOksVH Twe4cTYb3sLMG/iVZEZtPDYqNBWsSAFlLC0ao2OCto1O+U3RzIXoXpLyMnuZDk5neM40 EUZH3fKD6Zjtem+CyKAMY/h2E/UnmxJsp00ow0V9UEjHVF48S/j62YqqxbQpKoH4HJOS Cn7A== X-Forwarded-Encrypted: i=1; AJvYcCXvBzxo8rjbG1jp+sCBcSh8DUfj9duTu2Q2QFkBQ5vfHd/GNNoV7yHFcd669NpWvLufUzqualJK0yxn1xA=@vger.kernel.org X-Gm-Message-State: AOJu0Yze8+GMgmIe/z/N2VVM3BML+cd0IobNA4iwns89dFRYMENX0Zhe ZnBVAaL4vJRB4gGgGSIQ6ZbTb60YJx95E+FsCUvMlPqs5Zeq2zlyTANT X-Gm-Gg: ATEYQzwkvm2RyiK8dMPK6W61JomdfWMo3seaLeH20QhSXZoAZ/Ffp+AlpOw9kc72j3P r+DOzPOESx2OPp1MGpBq4pGkHiXltyYj9Wr1kk4aPmsPu404hmHzvqRa8pTnnX7ymozMYESkSqM Sl+V+o0HIHKQfGz/JtIWVRj0m0ud2BWmbKpi3rEogTANah+u49IDW2l/HQthGhjK6yJhYNd7MXe tURtqWw7njs5izNPjoK7r5Uyl/MgYAeeZOptYt1CLtS2w8Cn9hviI/IDsDyrg6WvTOU2nWDeF3q 1QCcpRaXM25K57/ghWNM9aIwAmILuONbUw3NyzXOeh7+ETORZcpZh7QK9BHp0jIlTMPxPCaohuQ ZZUp5xwBe1sHaCCXc17WfhMoB5csxPZN7khknc/PAO4Oq2t2P64rmMgMZ5TTaqtzcsGKeyxR1vK BanCqYbC3DhwF7VU1WqpxlA7EwPri5lIFkWu06RG7gLQZ+5Wkr X-Received: by 2002:a05:6808:158e:b0:45e:e07d:85af with SMTP id 5614622812f47-467570a2be8mr1583016b6e.2.1773408173272; Fri, 13 Mar 2026 06:22:53 -0700 (PDT) Received: from frodo (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 5614622812f47-4673434a35csm4795987b6e.20.2026.03.13.06.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 06:22:52 -0700 (PDT) From: Jim Cromie To: airlied@gmail.com, simona@ffwll.ch, jbaron@akamai.com, gregkh@linuxfoundation.org, Andrew Morton , Jim Cromie , linux-kernel@vger.kernel.org Cc: mripard@kernel.org, tzimmermann@suse.de, maarten.lankhorst@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, christian.koenig@amd.com, matthew.auld@intel.com, arunpravin.paneerselvam@amd.com, louis.chauvet@bootlin.com, skhan@linuxfoundation.org, pmladek@suse.com, ukaszb@chromium.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH v11 02/65] dyndbg: factor ddebug_match_desc out from ddebug_change Date: Fri, 13 Mar 2026 07:19:27 -0600 Message-ID: <20260313132103.2529746-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313132103.2529746-1-jim.cromie@gmail.com> References: <20260313132103.2529746-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 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_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) { @@ -204,42 +250,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.53.0