From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (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 26F3E362157 for ; Wed, 8 Apr 2026 20:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678559; cv=none; b=aV398y4LKGArGdv9MV8zIM/g3X4s2GNicSyfXEYu0L5viZM+wNDMi5BQ3qKiLvwqTeeH1YrlRTBAU4jSZ3aZ4cZ3qae8Vvm72CUfl6zWiVL4Dcix8PDaXIZJzSvPUN52U2355sjbh9QiFeL9PDdK1jVHT2CHvQw2L318yVdGhps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678559; c=relaxed/simple; bh=uocxdG/7/3dQ4Cvc1k0X43etAxjGMK8KCSQSXA4knnk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uFnIUEP77AybKIZzyxzOJYAiZrdqyLEEw4QyZRLdQJwPbXosWhNRfW2+JWSenaiEAqMQu2z3Qt9uKU+zwBb5q35zyvleHUSoesGh6a14Jg0+wQx+UmZGuTEMwq9kZoGYOqbta3yFaXsTFaLWfZPDbwc40dRV1hMZFxUbbrWzlIw= 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=FWTtryTa; arc=none smtp.client-ip=209.85.161.41 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="FWTtryTa" Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-67fdb2afaf5so81870eaf.1 for ; Wed, 08 Apr 2026 13:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678557; x=1776283357; 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=FWTtryTa5h0MXUA8sObx+DTXdgpAI7sKcquNLh1/sZGwDOjyf2FZ24AIkfRKxovCTz NGsxfNlnIK6K9Y5LZfOaClfGjlsQentohuJsHsj8q8I9U0igL0P6Z/EiVv83dj5d5Ett tXDI+QAt0LIQvRdOJFbP3ZWzq5zPlyd1VSpqozm6vhbHRXMCmrvQXh5ROrjoSWgwYq0G E0bB6JyF4W1a78uYSNdHrn5Ej8k98nBt4SMmbYOjQbzUmgBlWTJkVbpTgsVmvTnZ/W/T 0MOZZILQzuysxTWN4SPC2XFoDFPycIJzM5ZjLz00ABZQNv7DQrUW+QxHglXGtbyVpv07 nwSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678557; x=1776283357; 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=iKFap6u7RCH7nMG52W1lFNpZP6ifLRHjxFPH32PxdMLu0ReyeznicysA1F9xvdAo42 mphN46F9Cm+SCiKatfHEOu5K8HJjwa0lsj/mLzOSLuvhZd9hdCzYgdgoB235zOhYkmmL +QX/OspYg6YiKxHi5IjVVfoWWZkJdTjy6cz7KgMHpIHMtROr9WLIOqsK9hU7SBuGxYup LuSj5yLigo5XU5TKFBrOFQoLWl1Yw4vzGuFSsd3w2TjRnAA6wMSsvGSDEPPzj4PuMChL aqSt5VPUkvMjjO00PfsJ6jbtH7+jHeHA/XVNcMWTdOgbEclNd7e4c4La7ogAeHMakofB B3Rg== X-Gm-Message-State: AOJu0Yz7LS3RHydqkPvrhFl/twGGvBHoQk3xpY2ukjR9qquPNyjJE1Et nHrKgzTm4nybZN0rYZWs5KHe+M7cLZV19+ISc4lCNTiJrfrC0PJsNqo6Jdk8hA== X-Gm-Gg: AeBDiet2zj3lIYGnwwRWQpxL1ya6PBAoLZ1jH5O0+wVcytx/StC84q5A5YA+YFUS4TE JPEjaH36cEIsUbLqm4Z45ImLX44dHB2ccEJANimTCrn3bs54lUCBaCvt0fG6G79OkoEj1whGOvM sh1h5eCSy7CNrU3XhzjM20M3uU/WMwzgka9Xghi805dhO0HF7FLdm88ApUV2zY8ITzwoEaP6lPE NYB4M73p54TATfywwGkI/93R11Am2qTWW8a4XrIVV3VftGA8qeO4ydkOCgFSIWr4UJgjGQ9Dqvx LCHiuR88hPwL+g47T0WtsNEo2eKm/L6wXsYQJEZv9Nt4Xf13uB6zWlVwUKSzZP5S6+PbFFIPFjc jXO3ru5wmv+dgKvHXpilqxwMfSvuX1THfzIthCJZlhna/LLMjdaZRs2RkZTkk1D0L21d57P6Iu+ kGFk64KwG80K+PnlsNVJRE1lrH4Kh8tp/frWieoRG2BxWt6VPGyLJIKeBVKr2JTUypsnO3JON5o DU= X-Received: by 2002:a05:6820:190a:b0:67e:1c07:15fb with SMTP id 006d021491bc7-6822152e58bmr10022892eaf.52.1775678556811; Wed, 08 Apr 2026 13:02:36 -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 006d021491bc7-680a63c7fd1sm12254208eaf.8.2026.04.08.13.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:36 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, jbaron@akamai.com, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v13 21/36] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module Date: Wed, 8 Apr 2026 14:01:56 -0600 Message-ID: <20260408200211.43821-22-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408200211.43821-1-jim.cromie@gmail.com> References: <20260408200211.43821-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: 8bit 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 *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; @@ -1271,6 +1271,35 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _ddebug } } +/* + * 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 = (_di); \ + typeof(__di->_vec.start) __start = NULL; \ + int __nc = 0; \ + for_subvec(_i, _sp, __di, _vec) { \ + if (!strcmp((_sp)->mod_name, __di->mod_name)) { \ + if (!__nc++) \ + __start = (_sp); \ + } else if (__nc) { \ + break; /* end of consecutive matches */ \ + } \ + } \ + if (__nc) \ + __di->_vec.start = __start; \ + __di->_vec.len = __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 ddebug_table *dt, struct _ddebug static int ddebug_add_module(struct _ddebug_info *di) { struct ddebug_table *dt; + struct _ddebug_class_map *cm; + int i; if (!di->descs.len) return 0; @@ -1299,6 +1330,8 @@ static int ddebug_add_module(struct _ddebug_info *di) INIT_LIST_HEAD(&dt->link); + dd_set_module_subrange(i, cm, &dt->info, maps); + if (di->maps.len) ddebug_attach_module_classes(dt, di); -- 2.53.0