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 D1271ECD6FE for ; Thu, 12 Feb 2026 00:14:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0EFE310E670; Thu, 12 Feb 2026 00:14:19 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Sl+fMQ5G"; dkim-atps=neutral Received: from mail-oa1-f67.google.com (mail-oa1-f67.google.com [209.85.160.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5EAB910E670 for ; Thu, 12 Feb 2026 00:14:13 +0000 (UTC) Received: by mail-oa1-f67.google.com with SMTP id 586e51a60fabf-40866608701so1412710fac.1 for ; Wed, 11 Feb 2026 16:14:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770855252; x=1771460052; darn=lists.freedesktop.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=Q0LQBHi60FYK7dLdxKFcjU244j3IhX00Oyc6HhuUyA8=; b=Sl+fMQ5GOIMvnslBG2yrEuBPPKRVKzsyoR7/HOPTK/eB3hWhhywmsKDvrdk4lXJjBg 9PZIHfmGtdjp6Bag91LuOLFw1K7HzrcK1/Wecwy7U0IJhQj52HTqK1nHLNJEgabcsrQy u1b5EzbJtmU0pAl0FoQGEDFxeHlQzm9U+vt+MhGYxqq2An2aY7NyfFmsTI+GVfyXzZJk ioFTjPnb+lCUFxCu4dCbmUznEwSaIZg9rwTgCkBoJvywq5zRtSLOzJk/RtKYrMso382g Riblo3le4RCtywS06r9I7feC99bfuv8BwFyNWHt6GVPaAtwLrwEu/K7cKkvRKtHd+y4l vYfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770855252; x=1771460052; 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=Q0LQBHi60FYK7dLdxKFcjU244j3IhX00Oyc6HhuUyA8=; b=WNqwUAW1Sd3qPovQ9ZTthagrSwcmRm/ZX5lVVvjmv2OI+7x/kToYehbgsI54umbXCM iYMXf00MyZ84ZyWcZlE9dTsG2LfPAQ1hw9howgDBuaGtoiT8lVxrshObMd076dcZ5DkV NmrTlykjLX8EHYjfNgheu9elF9zVW2a6MuOYOsYR35tPgFBFfiNRyC0iYnu0jI9gNVRn Ac4Y8273jn+x3CV7ASO0iG5hFrhvcF1cyig/GU1DYmx0QUacuB3BWyx+JyKSj8CNZD+T tIjsuxsfSqOThQTqKAlfp3KLmFhApjnlVexW7+lgOmqWQDdn2KKkdtHEjh2Kg0p9ydmQ NWXQ== X-Gm-Message-State: AOJu0Ywn10PixG/QLUThWzjKgLBRD2OGIyxNz/1UbahRc4dEds7s/9U7 H604rdJqafhudi4CmVgDOjH+jqo20trH4IR4ShM7CyYJZh5RjnZSlnnpa/xbPfGO X-Gm-Gg: AZuq6aLJtJIUkMTh79CJlP0Nn/n9dWQwHH0OIgM/sbziSbZMkj8GhebR6hjQ+M2BbKm /iean5uCUhEE+x1NcY7UVX5wgnonoU+3LnUr/cj/SQLKQywaEstJzv7QCz7m71Q/k/jtcgplIsv JUKnDHAo0zGvUhr9IrRkRbNoI1E6znPm9ce4fbQYA4U/iaL+UPqhPa5WSNXwPN9Mw6RAMoQVCHL m9nEIzFdfVarx/9SD0CwTfuoZ5yea4oZpkTqckUn+JGRqpxOQgWFoGZBwMcPj6hEzzE2FH92ZrS 9IWCe22kBPD/U1Tu9ACLw1BBoVox67eII0UKGeaQQ1J0c8PTwlw/Ptpgl6v2hZkMuuzQ0nNN1JH lczECTPAlh+RGk8IxgrcmP/Aoi/gJye7XYh2ICPe/052uU541J8+4UM9FnUoCwM6/GvmHQAnr/W pytrud+KkYARopnw0nUvDO8734tJTSlvwYUKOLc5tN0na0fpTPlxWD X-Received: by 2002:a05:6871:7a6:b0:409:737b:719 with SMTP id 586e51a60fabf-40eca08ad25mr326190fac.24.1770855252299; Wed, 11 Feb 2026 16:14:12 -0800 (PST) Received: from godzilla (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 586e51a60fabf-40eaf1062ffsm2331939fac.13.2026.02.11.16.14.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Feb 2026 16:14:11 -0800 (PST) From: Jim Cromie To: dri-devel@lists.freedesktop.org, intel-gfx-trybot@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 02/61] dyndbg: factor ddebug_match_desc out from ddebug_change Date: Wed, 11 Feb 2026 17:12:57 -0700 Message-ID: <20260212001359.97296-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260212001359.97296-2-jim.cromie@gmail.com> References: <20260212001359.97296-1-jim.cromie@gmail.com> <20260212001359.97296-2-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 7d7892e57a01..e7578507945a 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.53.0