From nobody Tue Dec 2 02:42:12 2025 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (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 B61D32FFF83 for ; Tue, 18 Nov 2025 20:19:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497146; cv=none; b=YGFdIsQ6cVRaG0Mlsu6gwX+k9FX1THkyiMx/Kf4kVMBh8tJayKWAXP5B+Cy/v0SjlcpDG/DikDbuNNK/jhBPsBlEQLulEvB1ePGVi8hFPKyGmq6MbcOkGYb4PVbLaec8e/9UqMj2Kym2aAIdpWjeG/Y93fGNxigCrA6dOJoMf/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497146; c=relaxed/simple; bh=GFEM8+QcfUKEnXIFJm2ldTy6hWoLsDr1RT45XZuDT5o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K0B4fMcs9NETnIV6GKY4GpzeF5fQAAo1V8CHdAFL+DXbiCWCbE8NygX6VDdcJ4kFLvrNQB4YiNHOZywaYj2byuaw64Q3O7qe9m5tZLB2/qreTsdMPA93D3YahqG7Pgtj6KlKxzxJfxW3vaKjAZLqn/y0RvuPUEZrYvbscD03Dy8= 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=ZgHO7wmo; arc=none smtp.client-ip=209.85.166.42 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="ZgHO7wmo" Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-948da744f87so207743539f.1 for ; Tue, 18 Nov 2025 12:19:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497142; x=1764101942; 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=Yf7HPZBJKJHruC1KEyryViKNbg7OZO+TlBUJ1MAjLuY=; b=ZgHO7wmocRYInqdJXeR+KZVlaf0DxSR+0IPw/worYNpR7PziAMWizMHWlbjH5tkwH2 SjcREKR6FQhC2EKmq8b8LXiKG741uy8vh4GTsf8Kkssc6hJH7jSColMXhaR1Y4/WxGS1 LGCjAuBghWp1TXMjawh0xOuiXtlgD5UVI6fadnvLAwTAxy+LuH5J+ihcdjaMYipYfmpn AkUyCf9tdGEeszcPEruys6XJ/OcnGyEJBzt2H7Kjg/b1OJsmkqdqlA6DN2L0yMQhkR3u xkbAjsztVdlG/WhwZvV0tv7W4MVOIhpT4Sdd7ltvNUW/aw8rggzmezbrp8MzDzkiG2/9 hDiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497142; x=1764101942; 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=Yf7HPZBJKJHruC1KEyryViKNbg7OZO+TlBUJ1MAjLuY=; b=MrikqY69zOzO1J5jwcaEQW5GI5AMaKGnuHBKM7zGqD62ykwzwyIcfUHOY42r6k/dVz 5G8rC2cds7rtlcqPzsoUCC6pARBrRnQXDwb3GnxQ32clOHFBiS15LPDhkx9W84QY2FyI NvTd1irEuL85rvTXvc+B0VzMbyonCTjpyRLS2EXRUbIUr2wDAx7sOk6EtiUeQW5pRtBC eYXTX4nO9ne5Y7ySlB9gymHQa/AUlnJnIOO/6OlSEqnn9XgasXq2SYe8TAS8xlYREPM8 8ugKuDG0nFye+5QE/EsFp6PG/INCWdGMaczEjLYPPLFA8W0zWGyHmiczAZZ2pwxjeOUX MrPw== X-Gm-Message-State: AOJu0YwC4FtUPl3OFCbWvRiPuoeldLl7lS8yyYGcAYaERkkDZNmhXNV0 YcvXIoFgsG2t4Ar+lBarhmFOd9rXLPgohuchzoUGFhIoq8w68KEmewxxf5fZ2mjJ X-Gm-Gg: ASbGncsy3Bk1CrrQVqGNy22qIN9vY9ruvaku0CHt/iCBbFfgwsVKEUaX611FmskYLr+ cccG3hQ7K+G1gGrKQjUDrOhP0z9i4Fn1h/+LgIYk8IQnFZFNQCpUC17nr7ocCNLUOf64mv3bf3J EuauBWyLBL8K9iWvwbZq1B/VLp0uB49OtwWpxBGgaYS0X0h0m2RhrTJ2hbkUnmHPUWxpm6Uw1F/ 20HYDg72CsfqaVwGDfPHsuY9Cd/m8ZnM1eWXx06xQox4jf/TMphQSHqHh3sEdkaEBEkN56IDjv6 G3CS5PI3CaQ6LcBIDzMmd7vX6JQuDs6YE7sCA9e2jILTusF/i/ho8IAn6WzqiTyCrxYsorZq7uj Ow2JydcYyyUa6VsAetY891YShBxnusJWCsaK32GxgPowfPt5cGgF+YkVUuSN2uH2Ud5JBGMYB1q klV3qpyx37eZ1JPKAeulkoS4ix66E2ZwqHhXirpwqCh+rlnS5hraN+Uc29/d2stVGxMvk= X-Google-Smtp-Source: AGHT+IFyy6Jrx9tl9L5mqbYqFHfaDNvQOzCPxl+EKL0q8oHuHQE3Af4yD/v7Nfkkp9FTpOmIpMo3lg== X-Received: by 2002:a05:6602:1344:b0:945:a27d:d4a6 with SMTP id ca18e2360f4ac-948e0d640d6mr1903420639f.12.1763497141733; Tue, 18 Nov 2025 12:19:01 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:01 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 01/31] dyndbg: factor ddebug_match_desc out from ddebug_change Date: Tue, 18 Nov 2025 13:18:11 -0700 Message-ID: <20251118201842.1447666-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-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 5a007952f7f2..eb5146bcfaca 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -171,6 +171,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) { @@ -203,42 +249,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.51.1