From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) (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 4CEF73815DC for ; Wed, 8 Apr 2026 20:02:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678544; cv=none; b=M1WwjRSEWCCLyFIWj+LY0nm25WYEFTUNgsr32yEx5v4gYlP1p3/FC+sHLMiatfQ73qMCvvi/iLJTc7OKMwH8Bb7tQYXtqKX7CsJdH6NvzLqrxsTaR3xsf4JC8RYAbyqJfk5bFHHwNLzCmqY7p8RJedGUt10rS9AfNS77a2/AFo4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678544; c=relaxed/simple; bh=aSp2tGGV4u70JIzjXLhhj/itWzrqvlxUbbmMGC8eIxY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=odWd/wqcsUdy9vwMFtj1gH7DDTGHy2BKzYUdUJN/88DyhJwbG8GWE3OjVXsyaBkL4ROlrRljg2wzLtqV47CVUKGolT3DLDjAVzy3XwkjgjY/Z9o3z5b4m11NWAFfs0Y2gscoCgUUAcdrEK06P0/TQ3JNiVCeQydZ7rC7ZFcsyrs= 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=K7CA14QC; arc=none smtp.client-ip=209.85.161.53 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="K7CA14QC" Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-67fdb2afaf5so81669eaf.1 for ; Wed, 08 Apr 2026 13:02:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678542; x=1776283342; 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=K7CA14QCuDnkbJ8r8/ysaZa5I64QPzr/umEczsQcGBWXPEyA/F1K9XN0B9RWu0Lz6U RQwQX26/V4W7gj0gBGrhhAt8sk4VbqpY57C8ovua3dZzMT0aM5Ib9lHhDFiDqTTb4GT9 Q/DEW0D8JkJqonUMNM2aFkEfGvf23wPRL+xz+DEZUgjl7/iExE+Tiax+Uqj8l0JeT6NS rIyr03G39MgCcYS/A8hkgnyB39a8PR7ca4nViXzpsNePbuxk0+8ZRc6qSrV6VGDsoaTi 3vBqk0WJMLBiXD7SeSwFSHvtoNXA7H98mns8EPhQXi7IHiNHKFp6uIGTu9s2GvFmuMqD SExQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678542; x=1776283342; 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=DrUwZ44GxPixJbXfd2a13Yc571lw7LZN931is33rLgXZgzIFFH7VZvUx58SDN/nUU3 J+IH5Os8d6N3WL1FZAeAr3G4WfdGrRTz6bvDgkKUmVOtsYceIaGsZUStUeii2/xx5ES2 UHA1CC4DCm5TJrbSjSO0ExK9q+XYRg85AY1/SlcCdJ6AwRpn0Htyf5B4RIe3g1VqlkY+ ZeuTrgJop1+cOA0/fFaCcbXLzLtI9hhaMcsL9M222M9C1QALh1yc1x0PV7SGgoEgOcD2 xE8nKxrnpvxMmGjChDcll7xUM/3KgFFDTVzu48FqaXeR/eIQj2N3S6x0CG97NdxMuN/S R9/A== X-Gm-Message-State: AOJu0YyBACZCnIAWaZzGog20YL4IBVJ4J6Zfv7TETdj88JlQA/bt4ejT 0xCXjif6SeM4PtlSwQlFkL6sBtOkqFfIpZTLjuKF0nsGLVYs0ePGVpvq8QE9Ww== X-Gm-Gg: AeBDieucpHwxgRI+BDUMOGlcuYKYhjSCZeaaD2x2aUAg2D8g0hU6lmIFM8YXQfgW82p GekIvANbFb4JBDw/hRhqQfQWRVQ3YJbVHE74BZwwgcU3OT3SByaI+hGNmYgB9wz/q9FwtIUWAe2 HspECx34SO0FIF6VKAlh2VcBe9ss39LXbavLVhwHWvy9xyvckNMbkcIUAGyjXDf/U6b3g15odqj WFWuEwURSIZe1a5BkByZt9IR0w61BhE98kocVkvHPdkt/U1IQaX69ugwtHNAhKW5hZUNJGV137N n019SVUJgDYwdItf3HqBKaeaHG4T9qWl6A/w9GquEL7BB/rijKL8s9D1yTZYElKaQFxn9/selj6 MGlnmnPZPqEXyV3ytQhLppuvswLe72dLEw2SfUrTj+KvHmY8ugvMv19Usm99PVTx2IWlB5bcNcX KUkIYbvxAu+LoacpCdCaqOV7u8qespLzRm75p9UEteXiHaa3rXo68u5Z2hUlD+gmGi14ikJOYFj OQ= X-Received: by 2002:a05:6820:906:b0:688:93a0:85e3 with SMTP id 006d021491bc7-68893a08f67mr3629216eaf.60.1775678542034; Wed, 08 Apr 2026 13:02:22 -0700 (PDT) Received: from frodo.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 006d021491bc7-680a63c7fd1sm12254208eaf.8.2026.04.08.13.02.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:21 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, jbaron@akamai.com, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v13 05/36] dyndbg: factor ddebug_match_desc out from ddebug_change Date: Wed, 8 Apr 2026 14:01:40 -0600 Message-ID: <20260408200211.43821-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408200211.43821-1-jim.cromie@gmail.com> References: <20260408200211.43821-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: 8bit 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_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