From nobody Tue Apr 7 12:52:14 2026 Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (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 472FC3164C7 for ; Fri, 13 Mar 2026 13:12:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773407529; cv=none; b=IdhoaQwnYom0eZJpG3G7kYxrGqvY0RwrCtUtXpTifwirMTiGCf+Oq02/oT9CGqfStJj2vLTI/0px4vyMaKTz5xv+Whm3Hf+diTgMIvqREKT/v62qpT8IPaM3+XGHOeqB0qGr/WZHAb1bGiCFiJMD9bLjiHgaaSKu9dmp09hQYLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773407529; c=relaxed/simple; bh=m4l8y31rHp314wh/pOxhDrUgtpeO5zShqIbyCammnKs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BVhLbHX64hHHS9e0DvMX1dnMPbV6VCZm7gHFC9piIoCIjcm+RanIfoDZgYCBcg/8tCYjowhDkDNbYyqsYFQWhRHaAA+Nh2g1XcPYgmSgjJQXY3BC5ZFQJMUizbD59ZIDdWkQHz6p9vvspSkerJZlPvPY7fbSJLm+2k/KM25j8Rw= 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=LNvGoGNK; arc=none smtp.client-ip=209.85.210.49 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="LNvGoGNK" Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-7d738fe814cso1778308a34.3 for ; Fri, 13 Mar 2026 06:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773407527; x=1774012327; 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=LNvGoGNKQFymKlaT6oeRFPV+CRX+y3zbWABn6iEYQg1it5xPAIX9s5aE+5eMpyteEb iGxyUJyV82E+tQIPOO0/0iodwfdC4wlXxyDAxMncNC98wPhzmk67zUFWoSecAiCWYLlH w14BxMnFyCyWormkCjWQUIlWHxdmmfRCBfchIyuBeJB9LgDkCESqp7UJ9cHUl22NTQZS XnHQ0p0iOpW4IvjIAEF1RtH3jzmzSwK6CnjKHYZqXMbcT7CK5EQiGfNN7aDH4vGK3AeB gKYOQ2kcz+0DDv7eirkglX4ZngeEhnWnVLCkDmrPF5CY9WJ6JuFxk/EuNyehOLDSQr/L ScuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773407527; x=1774012327; 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=S8Tg8d1ym9C88nrmKFJk09w0Rd4lDDzEVPYGW3fNt0AFDh8SSJRzSwXvdARwXGWkhj dG1nPnD3T3ah3AgbhWRsCLywtlNONEpX31U5gsF/iQXAfAoMFKMve1i1tI0L6EIY6E5s GIxlmESMrmf2HHP02MJxPP9l3GaX0DXDb8zLtk9Y1lDACdnnLYU7eVX0fSpRB9ttNhgg aQvn2WybUtkbxKfQD5hNUOPmUU55lVgg0DTa2O11B9WHAKCUNV0s5ZhmpQ87FlfV5oF4 NgjzPGg60FWR8fXz1Szd+OR+7vblkJJ9aztKkAcI1AHg5Ts5aNdaqDG+OsbfGBl7ONDt Iv3Q== X-Forwarded-Encrypted: i=1; AJvYcCVg8bISiivVnlPJ4K5vR1jlp1sWHgZddAhPcvDrdL779keZnxp9I29SASO2I+/96Qdu4SfubaJ7CeGJ7Og=@vger.kernel.org X-Gm-Message-State: AOJu0YwrRVnJBGXZQaBjR/sEBHXe9ubObNiVbYSufdYz8oDMCxdAUBGY in2RgSnOnDbZ/coW1EreoUuAo93b025XhyD1tSVZP+x/4LhzTVCMZ7A5 X-Gm-Gg: ATEYQzyQRXpzr0KGTLIArEXr2jSvOWbPhu9RQOpMAeaq6nKhCwq149yeIFkOhLEAiqh 7nB+tCb5+R3n23KDWBKQ0Es9HhG5H3m3JH0u6kxDIPFqpzx66N0jkVDBM3GRXQJrUZraI6Ejao7 uVoziyumfH+f5rBLkDcSJDjis/t8sA1Vtdzbx4twJ9vzmT+mxcvuABhSf8xn1amZ0SNqmxqAZed LpBuQv268S9zm7pZK5uDvPloOAn69yVBNu44Mf5SXcd3jvz6XAb1QwHYrHIn6/V3gwvOHzmyB6G z+CXD+Mc01hkkimSpQQCA1VFa+5t5KWh7YovgCeX4EI+C7VUkiCvJ2LYAvGbu/gwqRPQcgbSS9/ 1qcJ3oc491mDERAjg8K6za2KSl0ASAJeTOea64vri3eYjywyouYSu2Ivjx752x0pEmwpchTUNxG z+rYeRVmJmrS2e1Tp4BsYOcpV0CH6sTLPLPhhpMUETfEjvxcQTYGmNHmLL+10= X-Received: by 2002:a05:6830:64c8:b0:7d7:5bb2:568d with SMTP id 46e09a7af769-7d7825771e3mr1924422a34.28.1773407526988; Fri, 13 Mar 2026 06:12:06 -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 46e09a7af769-7d76ae90586sm6733728a34.22.2026.03.13.06.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 06:12:06 -0700 (PDT) From: Jim Cromie To: Andrew Morton , Jason Baron , 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:09:09 -0600 Message-ID: <20260313131045.2526422-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313131045.2526422-1-jim.cromie@gmail.com> References: <20260313131045.2526422-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