From nobody Thu Apr 2 20:20:46 2026 Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.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 971C63A6B97 for ; Thu, 26 Mar 2026 18:54:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774551280; cv=none; b=aSwFJ+Ync6X3gwT98+Zu1DeWs5nZj99InZX6nyjODGSoQWYWyXPz7ZQJHgBQFuSFVs6dQU6EF7lVCFJELEip6gJb0r2zdMsnJSvKEn7Z3Lh41fYRM3Ywj4+Bde5AbfYYFF9hhFAbF84lx1ZWxhjNZF/CZTRYz7Q6TQvNp9j0Po4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774551280; c=relaxed/simple; bh=aSp2tGGV4u70JIzjXLhhj/itWzrqvlxUbbmMGC8eIxY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TLg31jG/fkq56leUsEUAEo7ksH3t9oST8npbgwZMXmTz32FVJDeFV7yS5k8p4cfdFHGnWz+nGTrESkqj87/T1qsh1OeZfjrdVJ/4EfltKYqKnaum1jS1kDSZTjd8pAuj9PtkAYzFnb1EYdV6EEGnQPA/CvslK4J0riQ7eTQ2SGs= 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=d0t3Lopz; arc=none smtp.client-ip=209.85.167.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="d0t3Lopz" Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-466f1c3c627so782764b6e.1 for ; Thu, 26 Mar 2026 11:54:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774551277; x=1775156077; 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=aHUGvvDPJX5utgpnBEa/SBdGHOtXvC1eEVKqa9t2R0g=; b=d0t3Lopz3K8DnwVs2EusO/StVctA46Dj40QosyIbPefSP0lt16HEQy9LR1E0NSbESL rWtXwtd8LfJWzhiXMPh9aZQ6/1b2kkYtsNUpeWJnpts1P10DgXXxNahTMvr3c8Rzi1O/ wgsqnbr7f1RKWSEUNPmGQO+wSRM6Bt7peOJgjJmKApEAY27U+bIbg5n9I51YiqLPiivV mBuKqivnHia2FHDgWjrUz2W9pOQ4uox3kuJ3xs0/T2Vf4IutBgTT3IvksqWly7NfEx7C TpwvavgC6RbhfFoLoBhaQa6tL9kctTOX0/G4mGuWqCt1X4UjKcL6pQ/Vt6lHsowROMe/ pYJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774551277; x=1775156077; 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=aHUGvvDPJX5utgpnBEa/SBdGHOtXvC1eEVKqa9t2R0g=; b=I5RPvpiJK48DvGk6QzQ72iCXksH+f5SsMRS87hNMJJIJAXIToGoKI4v0f4pWaXUjkv +LeUWMnhy+AleL6PFuEGr19bl9cWTrhp+Ay4zRLGEfLxschmmnQSnmp/MterLSCawxf2 gfnUkMiTz9vnslbmTlmqsZlg5oponZBqUry4s5FZqusF77JtKuNEaFk+9ucY2oZH0XkQ tNnMY26HFFsnB5hl41Yrz+N9tVhCRtnUPo+x4omp+LBFjDyqv+X7WH5UdRcX/OmzgLQX z4+3z/vqCONBjZXlRJigUsNQdsnIqY0QjmD1++S1dv3VCQ89cGA5BUO60p9X0SeguMUK /2+g== X-Gm-Message-State: AOJu0YzhzvmwVPEYJGpUN9IAlqLdUG7YhsbXSG20MC01on9q1BAADJb1 iqg/HYR2ptTzoo86xUcaVBD0XqXaCCG91FfaS4fpjMMjD8xl04eitFGUSxZUMA== X-Gm-Gg: ATEYQzyyj1QkRKy+WJjh0y0xteffK41NW/fOqTy9MAcctIFWmjMq0Eoz9MRI9pXaAhv +0vNn73nzvq92oJlBKT9nxoaTKH3K4ZO0Ash+YE6/ijefbDHTBiJF2MEWgk2RP/GJ3BkYEwrbza gsvDWE7idBQKsphWPunr5yrnwhEfSrmWfC2ukmM6sj3AhhQR+E/GvySmM45X7spLyQuLShJK9CB NTQ75dG+E79mBbSijFfkt1SlhhfqHAGXLFx+45p8MKuioh8ZzOUc+rnXfVinLsOfnnzJQSkRc56 nPzqIzSG+HfFYb3B2mJVlBlobovN0/PheVQms70lSMOSzdcvfA+rGFdEvZ8dGUXM4mUlvlGFwOl YpC3fbNxGfAK+e0+c9bJC4mZAGT1bJX5uka4j+KWRbS6wXwhsUoPtdSh4B3evPiN99RhHFrS/kt R6gBDXgwc6H39cCJvS2XIECUGcM16XHHXanoR/eS3sIlX3YOQn X-Received: by 2002:a05:6808:17aa:b0:467:bfa:bdae with SMTP id 5614622812f47-46a5c61027dmr3861126b6e.20.1774551277359; Thu, 26 Mar 2026 11:54:37 -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 586e51a60fabf-41cc7760c08sm3075171fac.4.2026.03.26.11.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 11:54:36 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, airlied@gmail.com, simona@ffwll.ch, jbaron@akamai.com, gregkh@linuxfoundation.org Cc: jim.cromie@gmail.com, 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 v12 05/69] dyndbg: factor ddebug_match_desc out from ddebug_change Date: Thu, 26 Mar 2026 12:53:09 -0600 Message-ID: <20260326185413.1205870-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260326185413.1205870-1-jim.cromie@gmail.com> References: <20260326185413.1205870-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. Reviewed-by: Louis Chauvet 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