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 65563ECD6FC for ; Thu, 12 Feb 2026 00:14:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 76F3010E690; Thu, 12 Feb 2026 00:14:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="b4059qje"; 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 580D210E684 for ; Thu, 12 Feb 2026 00:14:31 +0000 (UTC) Received: by mail-oa1-f67.google.com with SMTP id 586e51a60fabf-4043b909ed4so4733835fac.3 for ; Wed, 11 Feb 2026 16:14:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770855270; x=1771460070; 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=SMJ/bHdO8JBnj6tZd55l165UUxz5fr9jcZRmbT/pweI=; b=b4059qje9I5tWkOIDjD/CLJrJmAaN3Z6CYPcI3Kiv9exdk2TuUL2UV/CTkMgBEs2bF cgUZk/IHXSEdv6ZPVBDwQsBXO+Fti7klC/qGueTFqJ/KxSZ4u5pij9vsSuDtgtqeSH53 G00UNhd7iLBjKzRkUurxYqd3Ip7UYSJXa5j2ezGbAsYD9yQQuHExpR4qGTK9vgJM37xB XkwNah7HIhPZqwlk0vMAd5sgt8YvoZIyBC+4F5oxkqaPqeYazR0Odc22jk/V6SBRyL68 7EnKHQB7DTbnENu24nhE3ZZiy4Apnjfmyky43t+DHuAQTxUSOBW9Jbmhy3bVT4gT0cwu /Y9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770855270; x=1771460070; 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=SMJ/bHdO8JBnj6tZd55l165UUxz5fr9jcZRmbT/pweI=; b=s5IOjfpSiNjFYWe6gaRIhQFPMWY+FPQ1MbxNBVqeaQnH24wnQ+TwkC31QITHkYNZGW I5u9ffksKIjuhfQ0BNazLvnGSDdAe4blilPhB7eyxOaZzHQV3gPSdu2DNkl7Ck/Kv4Yt sRaB8Cv9mt684pcxPq/ECHYbvasWAo0buMTEKj8tpl3MznJLbwcpAEg99Ly7NTDBGZVN RaWZRw8TjFls6EGbTeTg+HWQ5c2f8ST30Ff8LY0eRPvo0/ie96fkuJc/TebqrKRonFIg 9lH3TMcETUIVsckBsRz8LjE6Wj1CcDQ69jXX0qLeHKUvWVe3vk24QvAU0XjQIyi2FFoC 3Z5A== X-Gm-Message-State: AOJu0YzzToeXHzaFzwGaX4pV2h00yprI2zZbCvsnuiRTV6teaLv+kANO S4K/KB/fHBumuLNxWk68IC+liKTpFDz5rvLNY0mEt0o8d3YCWlCGDZhcIKA4lKM0 X-Gm-Gg: AZuq6aJMtoTobuFiUKhy7T3pNRloXHZuUAl9HKP2cIlMwxdmWT+ZiABMeudHIh7T2ob IeJJp+55rQ8DWGJeFd+On7xN79zFdcqtSb8/eSEtXKyOvqxAlNiRWcg4xath3tL0Tp2tzMfTW9d lSTH4qNDqblXktQb2v85ofuj49kPyueeCSpkrxSnBVLN5BjXwqoHM+pvJ7uIg8KaEmeimcuz0A7 l/3n5bwpLu0jX/IDhnFxxOTmp7YirFc276ES2E0nRz7pRPBvjDZ+tUNXj/7VnVpMlJDg3Ptm9s1 Ll2uqVoJGa4qRtEIfF8Du1kSLvkRw6bpO1q6TvbOiLWIvlZVNbnCk5u67AUEDoZDDAIBqOi5Jmr s+mKuX+8UpgAsb05GvCAg3r5U2fgi3MxqqV8DZLEiTfecW4JXF7ydY3c3C9EduBVIqz1In5+hB0 wCsVlzpf7A3MqqZEMwDaeqXCVIj1Ro2Bi+Pc/w17hGYfOxJe9zXTfn X-Received: by 2002:a05:6871:7892:b0:40a:5795:152f with SMTP id 586e51a60fabf-40ec6ea154emr677096fac.4.1770855270303; Wed, 11 Feb 2026 16:14:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Feb 2026 16:14:29 -0800 (PST) From: Jim Cromie To: dri-devel@lists.freedesktop.org, intel-gfx-trybot@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 17/61] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module Date: Wed, 11 Feb 2026 17:13:12 -0700 Message-ID: <20260212001359.97296-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260212001359.97296-17-jim.cromie@gmail.com> References: <20260212001359.97296-1-jim.cromie@gmail.com> <20260212001359.97296-2-jim.cromie@gmail.com> <20260212001359.97296-3-jim.cromie@gmail.com> <20260212001359.97296-4-jim.cromie@gmail.com> <20260212001359.97296-5-jim.cromie@gmail.com> <20260212001359.97296-6-jim.cromie@gmail.com> <20260212001359.97296-7-jim.cromie@gmail.com> <20260212001359.97296-8-jim.cromie@gmail.com> <20260212001359.97296-9-jim.cromie@gmail.com> <20260212001359.97296-10-jim.cromie@gmail.com> <20260212001359.97296-11-jim.cromie@gmail.com> <20260212001359.97296-12-jim.cromie@gmail.com> <20260212001359.97296-13-jim.cromie@gmail.com> <20260212001359.97296-14-jim.cromie@gmail.com> <20260212001359.97296-15-jim.cromie@gmail.com> <20260212001359.97296-16-jim.cromie@gmail.com> <20260212001359.97296-17-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" The body of ddebug_attach_module_classes() is dominated by a code-block that finds the contiguous subrange of classmaps matching on modname, and saves it into the ddebug_table's info record. Implement this block in a macro to accommodate different component vectors in the "box" (as named in the for_subvec macro). We will reuse this macro shortly. And hoist its invocation out of ddebug_attach_module_classes() up into ddebug_add_module(). This moves the filtering step up closer to dynamic_debug_init(), which already segments the builtin pr_debug descriptors on their mod_name boundaries. Signed-off-by: Jim Cromie --- reordered params to match kdoc --- lib/dynamic_debug.c | 57 ++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index be3a430cc332..c2c450e3daa3 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -171,8 +171,8 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) } static struct _ddebug_class_map *ddebug_find_valid_class(struct ddebug_table const *dt, - const char *class_string, - int *class_id) + const char *class_string, + int *class_id) { struct _ddebug_class_map *map; int i, idx; @@ -1248,30 +1248,35 @@ static const struct proc_ops proc_fops = { static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _ddebug_info *di) { - struct _ddebug_class_map *cm; - int i, nc = 0; - - /* - * Find this module's classmaps in a subrange/wholerange of - * the builtin/modular classmap vector/section. Save the start - * and length of the subrange at its edges. - */ - for_subvec(i, cm, di, maps) { - if (!strcmp(cm->mod_name, dt->mod_name)) { - if (!nc) { - v2pr_info("start subrange, class[%d]: module:%s base:%d len:%d ty:%d\n", - i, cm->mod_name, cm->base, cm->length, cm->map_type); - dt->info.maps.start = cm; - } - nc++; - } - } - if (nc) { - dt->info.maps.len = nc; - vpr_info("module:%s attached %d classes\n", dt->mod_name, nc); - } + vpr_info("module:%s attached %d classes\n", dt->mod_name, dt->info.maps.len); } +/* + * Walk the @_box->@_vec member, over @_vec.start[0..len], and find + * the contiguous subrange of elements matching on ->mod_name. Copy + * the subrange into @_dst. This depends on vars defd by caller. + * + * @_i: caller provided counter var, init'd by macro + * @_sp: cursor into @_vec. + * @_box: contains member named @_vec + * @_vec: member-name of a type with: .start .len fields. + * @_dst: an array-ref: to remember the module's subrange + */ +#define dd_mark_vector_subrange(_i, _sp, _box, _vec, _dst) ({ \ + typeof(_dst) __dst = (_dst); \ + int __nc = 0; \ + for_subvec(_i, _sp, _box, _vec) { \ + if (!strcmp((_sp)->mod_name, (_dst)->mod_name)) { \ + if (!__nc++) \ + (__dst)->info._vec.start = (_sp); \ + } else { \ + if (__nc) \ + break; /* end of consecutive matches */ \ + } \ + } \ + (__dst)->info._vec.len = __nc; \ +}) + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1279,6 +1284,8 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _ddebug static int ddebug_add_module(struct _ddebug_info *di, const char *modname) { struct ddebug_table *dt; + struct _ddebug_class_map *cm; + int i; if (!di->descs.len) return 0; @@ -1301,6 +1308,8 @@ static int ddebug_add_module(struct _ddebug_info *di, const char *modname) INIT_LIST_HEAD(&dt->link); + dd_mark_vector_subrange(i, cm, di, maps, dt); + if (di->maps.len) ddebug_attach_module_classes(dt, di); -- 2.53.0