From nobody Thu Apr 2 20:28:12 2026 Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (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 A76203FB7E6 for ; Thu, 26 Mar 2026 18:55:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774551304; cv=none; b=ZDj8Ed6KsvBFkdZ+9DKngxAilkjz6wBty6TjRrLaxAkyOZ3WKrkGts0NMqLahdshkhNVK/wKmMyj5UqtmjlvD4muC7cK2n9AbjbOOmGXIwv8PxiFRV67otDJSimyRpY38cOZ2JBbkLYPTsyQcfFsRxGEU2bqftrnykaHzudiOQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774551304; c=relaxed/simple; bh=uocxdG/7/3dQ4Cvc1k0X43etAxjGMK8KCSQSXA4knnk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mZWNrOJAX9IGnUQjQrCQaDfeZ7qieYpF8jZMaikWwYe22G4Cr/DwqZgAdZdOiSeHnvwDRlcdIBieFcSYLW1BXzQSAax8oNrM3q/mumWVPRkRain2KFoRCAyM4jaKLs/kvs0kzag4rrEkVFWp4fqok3mTxu53WHDu677RL/tQoy8= 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=EHy2ugvn; arc=none smtp.client-ip=209.85.167.180 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="EHy2ugvn" Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-467161c4ba7so760711b6e.0 for ; Thu, 26 Mar 2026 11:55:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774551301; x=1775156101; 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=NLjFx8xvoYU6I9e8U5366NO9qUPUvtME5XDnhqfKA8c=; b=EHy2ugvnKJud7To/3hFfIQW2EYGuO1ATiQYbP4tvA7JDtHZ7pOFHIzekFcDqoAbOP9 GbT9OgR24/nEY4b3oPmgn1wbBhiZYXB2yAg139+XER3LHywfmbcsyZv2MLoVdTGNy0/B QVbWMEqTOUJ7FyX7Da+Y9+f7MjFag0rZKPnNWSsEWaokvds7fUSeTKV+idoMKOpDuQ76 SFJN6OTnlm41XK4HaUnJKPw/OsaG8pUdXXbi/ePUytttVFGn0kTe5O2qbDwKG7o0xp3q pDCu8RSyuA3uEUdcr2cUKHrrahg8qf0YsV0wJ8dbwEKUCZMpL6ITHmP73ytZqHwwBvku Dh4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774551301; x=1775156101; 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=NLjFx8xvoYU6I9e8U5366NO9qUPUvtME5XDnhqfKA8c=; b=RQebrCwdX5WZAJjHu1BVSsw8oik36cSjkv8Kr/cqxIDmZWVKlGTDCFiIj0tDMeEF2e /O9jNdRglVBBIZb0MGoLgyaDv1rf9HwrwyP4I5gsAXZA13Bu3hrUkpOrhrQiobjbw9il 3ZpNywYAteC+/hbqpyjssRwyrrVNyQEyqcRszVP/lHLBZN7clbxPKLicALBznljm9kci JUkdZJOlizbFk896BDQ+z5LzqgGRPMYTq2pHWAZyOViQvJzEFZp2Gz4AN9oDRi//AV0V ts2P5Ft741dQhBeka8A1Md2r2LaBWzhWR1OTsBOzZBPJqdjDEUirgxzSu3W+2uZ2KpWj cv+A== X-Gm-Message-State: AOJu0YyOcyeUg5S8+N7Gb+dyfNoxfwHrhMn64yJd5lZwROdXS5Ie0tri daGKVI7aRe9K3YXIh+hDHpIwv4AVZ+MFNer3MvJI44xgSaBKhAzyaUnqMhCpWw== X-Gm-Gg: ATEYQzz5drlYa9R4eMaV/TIsJkvPSWJhLY2V3MmWvw9vvIstJnJ1m2NxjxWZgxGKTB7 rjB6KZF147GfNjkj9ZPAwFAc5UYuWQUZYnyemHW9oiDHV68SD4VbVYatWXByAQ++qLgVH6+Wac6 PTRZNUnhgXMosRPPlT3J8es1G6VymHb7XOUO8XPgQJ9xQxpZldpIMwxh43mM8gWxavHUtuyKcpZ jDQeJOEHWgecs6S2TewRGWkiZHZAZffW6SIgNNp0ViJtWUklC3OobUQUmPPvWusVN94UZscSKYm PKdU++cdCNi8dtwaMfZWpgrdUTlFflaEgIohOBYvqvPricdcSXdVvSVv6KQP2Hzd5QrBDpxcOqE gp/wHzacfvT6FQQTKguXaS7DK2ZGGVMlOiXNhn49wL9Z7QPFztLBEic8HRV7F9g88ZU2HD0tzTX 8TjIaOXJ6YlRnVvUxJeN4cyu/LCutLguI8oSjwxJ6UD3KFjFhK X-Received: by 2002:a05:6808:3509:b0:466:f451:a0c0 with SMTP id 5614622812f47-46a7a84537amr1185457b6e.1.1774551301362; Thu, 26 Mar 2026 11:55:01 -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 586e51a60fabf-41cc7760c08sm3075171fac.4.2026.03.26.11.54.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 11:55:00 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, airlied@gmail.com, simona@ffwll.ch, jbaron@akamai.com, gregkh@linuxfoundation.org Cc: jim.cromie@gmail.com, 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 v12 21/69] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module Date: Thu, 26 Mar 2026 12:53:25 -0600 Message-ID: <20260326185413.1205870-22-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260326185413.1205870-1-jim.cromie@gmail.com> References: <20260326185413.1205870-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. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- v10?- reordered params to match kdoc v12- refactor/rename: s/dd_mark_vector_subrange/dd_set_module_subrange/ 1. Renamed the macro from dd_mark_vector_subrange to dd_set_module_subrange to better reflect its purpose of narrowing a vector to a module-specific subrange. 2. Simplified the arguments by removing the redundant _dst, as the _di pointer already provides access to the target _ddebug_info struct. 3. Refactored for Clarity: Instead of overwriting the struct's start pointer while the for_subvec loop is using it to iterate, I introduced a temporary __start variable. This avoids the "subtle" side effect and makes the logic easier to follow. 4. Updated Documentation: Improved the comment block to explicitly state that the macro scans for the first match and counts contiguous elements. --- lib/dynamic_debug.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 21ba5cb3b406..443f0fd6e8c4 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -169,8 +169,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; @@ -1271,6 +1271,35 @@ static void ddebug_attach_module_classes(struct ddeb= ug_table *dt, struct _ddebug } } =20 +/* + * Narrow a _ddebug_info's vector (@_vec) to the contiguous subrange + * of elements where ->mod_name matches @__di->mod_name. + * + * This scans the @_di->_vec for the first element matching the module + * name, and counts contiguous matches to define the subrange. + * + * @_i: caller-provided index var + * @_sp: cursor into @_vec + * @_di: pointer to the struct _ddebug_info to be narrowed + * @_vec: name of the vector member (must have .start and .len) + */ +#define dd_set_module_subrange(_i, _sp, _di, _vec) ({ \ + struct _ddebug_info *__di =3D (_di); \ + typeof(__di->_vec.start) __start =3D NULL; \ + int __nc =3D 0; \ + for_subvec(_i, _sp, __di, _vec) { \ + if (!strcmp((_sp)->mod_name, __di->mod_name)) { \ + if (!__nc++) \ + __start =3D (_sp); \ + } else if (__nc) { \ + break; /* end of consecutive matches */ \ + } \ + } \ + if (__nc) \ + __di->_vec.start =3D __start; \ + __di->_vec.len =3D __nc; \ +}) + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1278,6 +1307,8 @@ static void ddebug_attach_module_classes(struct ddebu= g_table *dt, struct _ddebug static int ddebug_add_module(struct _ddebug_info *di) { struct ddebug_table *dt; + struct _ddebug_class_map *cm; + int i; =20 if (!di->descs.len) return 0; @@ -1299,6 +1330,8 @@ static int ddebug_add_module(struct _ddebug_info *di) =20 INIT_LIST_HEAD(&dt->link); =20 + dd_set_module_subrange(i, cm, &dt->info, maps); + if (di->maps.len) ddebug_attach_module_classes(dt, di); =20 --=20 2.53.0