From nobody Tue Apr 7 12:55:31 2026 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (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 1213D38F636 for ; Fri, 13 Mar 2026 13:23:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408213; cv=none; b=mRimDNXjfmNsP5ZW1oJNmeybHniVrPyjmI7ycbJS2xiqCH/yLIRK5GTzUvGS6Br+bSGj/gfRWhPaGMwn4yhRQIZr8kYY3WmNV+KO7BANUAgw11AAtHugaoNSJQvT5a3XJrc6qZ4an2YxJ/BHiR67c8W3dZeoBnO67TcI2/5Eyb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408213; c=relaxed/simple; bh=hQSWH2C33w5JtsWzjpP/Kl4w16w5C+lIPPSk1luBD5U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PLIBJ6HxDHy5eg8ieCI++tDQbAjoHL6hAE9YbcgANt+QjJm8GBCzcMsAlgv5xqpsULUig8780I61XbF/OKkOmfOB0ekTUKsZpH1TQBh81hxhMxns4ev/fAYz+V2cpc2e/Z++UXmOj5plBah0eW+EHs6id4z4gitS/vzi2jceIYg= 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=bmJcIC35; arc=none smtp.client-ip=209.85.167.171 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="bmJcIC35" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-4648447e29bso833783b6e.0 for ; Fri, 13 Mar 2026 06:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773408211; x=1774013011; 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=MaAiGHt7PLiNFokoH+wcRTOWenkuKwVpfHhxx7Kp6sw=; b=bmJcIC35w3JZz5nAP2vmizpzJN4Ss2iBxbUYmmJkIUqoot3UpTjCediERby4zQuzi4 kde7pZZFiFbJc8AZokDtkhgkFH6yBl8SmAmWkUHkc8CYiBrmI16b6awLu20JxRYj5zIb /H9kJKaRoPIF7l2LpTtFafg4JUL1tRGG1lqER1wgSr06ZbYOprBbN11bS8uVYLGcQUIV 3LnzM/tv4nr6zUkx6TUepCNbKFn0jmKD8YiT0XLqNQ+dcxpEzQnKZ5TFIHPXm/nodiX2 VfSgcZe9vAC+1Wrw9g2JdjNixQfnzkYJ+mkgXx0rzysSDH67U/sE1KkExVdE2a9Yt8n4 S/KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773408211; x=1774013011; 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=MaAiGHt7PLiNFokoH+wcRTOWenkuKwVpfHhxx7Kp6sw=; b=SDumz4bbK7nV/owA9mX7gNLJe/CRdVjiTensFwa/SgqeZyRMev9Srz9GLVB0lFLWjj CkXDL9Ufj3Xr1atz968KLByiTfDJHoxMQKfTd6FxL2Yh54HAZ1DqkTZ9YV80QoV/JCEp xpuAcRiN4Yl8chtit5gWrTqdgAztumPUL+NmUaaA9Ab9Jgpwzd5Kvcw2qQLsQaEqoxJN DZvjfp4bTZyURGcyW+Yo7NbVlrmG4eA6CiI+HtY12jRYGuQ9WJiZtaKSebJZFtXxU064 wmEyRpDNobClUbncMnq8Es6MV+gXqg6LoMf+gttZlvOwyvzAu4NOU/wdodmfrc8bj9ur Wrww== X-Forwarded-Encrypted: i=1; AJvYcCXMqyEzZ1PhuIqkH7GzTd+B28mM3pfQowhYjsSYhtIg3M0JpPHtxXwdenu9/kinY6IlS63oGD7gvXFE3po=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5TOtAz+Xor+ysCY4NRFShyUTrYnHvHbaBavSOxPfgJXe2oHUH /v5/KGYQ7KQyAqL14Uwt36x1QXBTF/tLDwta3zP5qbijxgPcaTqdSQaQ X-Gm-Gg: ATEYQzwVafqiYZqAXSNM6gU2BKIJvrfaFBXZXW9jKK829FX5iEcPxHruSyP6bR+ev0b Av2s6WtR2l9cW66pl9LECGNeDG3Jom8wVAmrCEk7qFaX/nEDV09ow8j9qcsZzG9aR+drSfZW9Tc 2n2Gv8fJerCMTSfMuntJLEzLGAt3aF2CymPTjw+pRLYvVUxOOFdBpqsuidJQD6T+jspbwK9xgJ+ 60pKWoulChP13+tiPI349UzGjLIBH/7j+kOQQDbYL9sifV0KfqJGouBRutj1SD066nvo1iV+O6H CIwVkOTwylxcX9E+5/OMCq3NbmHrQVebpVX5q/EKRhfJ8MB9wSr+pW4/TQoFtVIMenGMT+JtzM+ SER8l3xHwNjxqV+1KgQjBdXnbnCrxZQhnB35RqNjE2HeTC1CvQerSmyCoeJp2lPwx2NZgNlIveA jjWeTChzEMG4Ckjn1UMGecu/yqhY0GkcyHrq2MK++bfSz9cpV7 X-Received: by 2002:a05:6808:4f4e:b0:45c:925b:5848 with SMTP id 5614622812f47-467574304eemr1623103b6e.45.1773408210779; Fri, 13 Mar 2026 06:23:30 -0700 (PDT) Received: from frodo (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 5614622812f47-4673434a35csm4795987b6e.20.2026.03.13.06.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 06:23:30 -0700 (PDT) From: Jim Cromie To: airlied@gmail.com, simona@ffwll.ch, jbaron@akamai.com, gregkh@linuxfoundation.org, Andrew Morton , Jim Cromie , linux-kernel@vger.kernel.org Cc: mripard@kernel.org, tzimmermann@suse.de, maarten.lankhorst@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, christian.koenig@amd.com, matthew.auld@intel.com, arunpravin.paneerselvam@amd.com, louis.chauvet@bootlin.com, skhan@linuxfoundation.org, pmladek@suse.com, ukaszb@chromium.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH v11 17/65] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module Date: Fri, 13 Mar 2026 07:19:42 -0600 Message-ID: <20260313132103.2529746-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313132103.2529746-1-jim.cromie@gmail.com> References: <20260313132103.2529746-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" 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 Reviewed-by: Louis Chauvet --- 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 f47fdb769d7a..df7223532cf5 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -170,8 +170,8 @@ static void vpr_info_dq(const struct ddebug_query *quer= y, const char *msg) } =20 static struct _ddebug_class_map *ddebug_find_valid_class(struct ddebug_tab= le const *dt, - const char *class_string, - int *class_id) + const char *class_string, + int *class_id) { struct _ddebug_class_map *map; int i, idx; @@ -1247,30 +1247,35 @@ static const struct proc_ops proc_fops =3D { =20 static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) { - struct _ddebug_class_map *cm; - int i, nc =3D 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 =3D cm; - } - nc++; - } - } - if (nc) { - dt->info.maps.len =3D 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.l= en); } =20 +/* + * 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 =3D (_dst); \ + int __nc =3D 0; \ + for_subvec(_i, _sp, _box, _vec) { \ + if (!strcmp((_sp)->mod_name, (_dst)->mod_name)) { \ + if (!__nc++) \ + (__dst)->info._vec.start =3D (_sp); \ + } else { \ + if (__nc) \ + break; /* end of consecutive matches */ \ + } \ + } \ + (__dst)->info._vec.len =3D __nc; \ +}) + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1278,6 +1283,8 @@ static void ddebug_attach_module_classes(struct ddebu= g_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; =20 if (!di->descs.len) return 0; @@ -1300,6 +1307,8 @@ static int ddebug_add_module(struct _ddebug_info *di,= const char *modname) =20 INIT_LIST_HEAD(&dt->link); =20 + dd_mark_vector_subrange(i, cm, di, maps, dt); + if (di->maps.len) ddebug_attach_module_classes(dt, di); =20 --=20 2.53.0