From nobody Tue Apr 7 14:04:18 2026 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (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 1FF473BED22 for ; Fri, 3 Apr 2026 14:24:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775226254; cv=none; b=cnUiyvKb6tdC5oQrFsdVR0hBo0jAIlCLyO2uNizYeltMcGMgg48nuTnCckZ69/xX1jl4xwofVWzCk363CcIIdb845UeqYOy0DzmCUJYrRcZ1TPzHaiNowytUZAlUSmupFIzEbxZuBCDAJMqcluOdj9Aym54Wir3V40tt+h3BJGc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775226254; c=relaxed/simple; bh=/89vDYlBhMLpJ7u6S9FMe0zD93ir3EtKs+spl8omcbI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sezm2KCriwyBZeb6qsTBJUp1uVbEgfpTMuo5KFemHZb+bMgeQluiZx2TkKImOaQyBUTMNyFv0ZBfoxspROwVR3+zpdUXIzr32o2eFycvgyTLZOsiw19CRyrFrKnG5djTbHev0agJ6Y9u3U6HVEnfE/ALT1YbZuY1BZqjRtqTg3Q= 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=gw5PdwFy; arc=none smtp.client-ip=209.85.210.45 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="gw5PdwFy" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-7d7f09aa39fso2554825a34.0 for ; Fri, 03 Apr 2026 07:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775226252; x=1775831052; 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=7Vh5jItPLrzs3QNiph18TB7iH3kbRO7YJxOr4c937Uw=; b=gw5PdwFyzYeYufT7Z2D0UwI+N4Du0p9PXhrivQ/Ofk9zwg9TG2EV4QwTiwJC90IsuE NOJ5QMzqDJztHxCGFIPTInejE0Jw8ZgPEbLb+jM1Q6OlEVhsAPKaqcAJFYimcVPrmZcr PbT6f3N7AfPHco+DH2aRkaITCNrS22fFoETGmoOyRYw80Rp6yQDtHtitySCdkcflSv55 rDyKvoK/D3dxDN/NqUyBVrVT9S1k6koUuuf/5tw8sGs25mhKrPQLDt+qU0WYDsQX/KKI 6cqXJqSprdzGHxC9hE3+G7fcBUBvI6bmMdLFAHosarkVPSMEcVhq3mZlSiWU3+BlMVfo hh8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775226252; x=1775831052; 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=7Vh5jItPLrzs3QNiph18TB7iH3kbRO7YJxOr4c937Uw=; b=DLrmrIkzlc34RZ2QOH7u+Rjt0HdqoOloT9FD8ks8ElmocHSTgpQuhGLWD65Sy/UzkB J7Z/Q6f4xxzoMjcFuleljbi/QH0L+Ys0nUXk8aeimf8TepvpUTqq9h5cKMa6oV7wYVgW 6NMy19DWkgJ8kdnUQslSCRwdjqfxJREZpFzOg4JSg7gUnCkQaoUAfBImF2o+sfJ3f9Kf KJ5Wju5ehph918//IUNocakaYzKsTLrjGkj7gxNqRWVfaBfOzvyRyiNxrcC4gI54QqTM PKhdJhumlFx7LfCnRcE9k3OmRlOVlFSqsRGojD5y2kpitcFBb9H7nLL34iVmOJOPz8su zd9g== X-Forwarded-Encrypted: i=1; AJvYcCXqe+uTjCFvAMUQYNoGleWmyo83w8DKOWcJSfTPPN3G5d0OdXyaHF2L0FDeUEpftJC5yXZ6fh/Mcko+d38=@vger.kernel.org X-Gm-Message-State: AOJu0Yze3CBPYoVugrJ7aWie9g/P9YYjC/a/HNSo3Au8r1nPApOCwZxt wt9cPKmiXX+U6DxYjXIDDv4NiomEExyzaS/9thK+CeHcXh119fvzAXcW X-Gm-Gg: ATEYQzw4mTDw2W0NIera+M25nx5h0YRb00pnNjLrQ3Wy5GwuKkEjCeyuRDT6MPXaXDu +ssoLa5m5eOW1ZKTw8dfCfOzhjR/FFBkIgnrYaS/B1gne1VtQ7z7nAJZqzsAru5p1qLOk37GLY/ rh8oja1ATp3R6D92P+mMtqAA9zMACTiHZYqX45UrLQjvovu3PCUpv0PrcdJWtpQLiMIR4wD/P1B xzFUbXf8+8vW9OUvFk59siPru7luRPqQvrTV4Gwtn1JHRih1vik2Mo+GnqDvvuPDYfGhKZcVcu8 xkS35VOxB/qMrScquYGq4Q4PzVudyV8JRqQMV8lHvNHHO5Wo4PLHVPo4bNkh267Xt3FSY8gPodo qPZWgLQzrFSYcbI1/7yL+Ywm3OZItVOOE9OF/yUuqg81PBj6rQtDgqdjQyXL87pMuwx5qR96o/L maYxyHSZIFKSdfwyFZZhc99lvAS6sKdPfUyhKDBcvVv3bkEsvXp1LWzGWMvuPT8Hn3065dZwgMy zASwJXgZmfR0w== X-Received: by 2002:a9d:6014:0:b0:7db:c162:992c with SMTP id 46e09a7af769-7dbc1629d6bmr670050a34.16.1775226251970; Fri, 03 Apr 2026 07:24:11 -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 46e09a7af769-7dbb7c3a0c8sm1806671a34.12.2026.04.03.07.24.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2026 07:24:11 -0700 (PDT) From: Jim Cromie To: peterz@infradead.org, gregkh@linuxfoundation.org Cc: jpoimboe@kernel.org, jbaron@akamai.com, aliceryhl@google.com, rostedt@goodmis.org, ardb@kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Jim Cromie , Louis Chauvet Subject: [PATCH 4/5] dyndbg: factor ddebug_match_desc out from ddebug_change (for demonstration only) Date: Fri, 3 Apr 2026 08:24:00 -0600 Message-ID: <20260403142401.1387033-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260403142401.1387033-1-jim.cromie@gmail.com> References: <20260403142401.1387033-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 9bee7dde5148..0b13810b03db 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