From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f65.google.com (mail-oa1-f65.google.com [209.85.160.65]) (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 0396737B407 for ; Thu, 29 Jan 2026 07:30:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769671853; cv=none; b=E/PjhxidSRF6ZUycR8YTY+ysAO5jlHe7PtZDS+VCwFxdBmsWzci3kD4aS+q51JorUaAAtTd416DjQAWMW+53lSoDl0dO+HWLRM6lKb8qAcr4jo/uBx1mGqjaOmbRPRhelKbBZXcg7wx4kfVzJToMz7hrNHDKgFJN+rZ//l/evYE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769671853; c=relaxed/simple; bh=6cVXBLbtabRZRdtTogygWmhmlBp5e86l1xrHg7t48uc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sT523SgNdObDmymYbXVkHRtjcsCjbwyqDH+D5bQHAIoTS75BfLmXBmm4BYd3LYVluFjYFi0YGmsS6ueVkC3adh7Kfzn7XPMkm1Tui5ECHyvqs3NeGTNYMl+4B6b6w1fz0oL1S6AqVO2/b9Y3JoKtjuFzysPh2Ydi21tCHagu1ic= 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=F14FkdT6; arc=none smtp.client-ip=209.85.160.65 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="F14FkdT6" Received: by mail-oa1-f65.google.com with SMTP id 586e51a60fabf-4095b6f9c5aso407224fac.0 for ; Wed, 28 Jan 2026 23:30:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769671851; x=1770276651; 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=1MSGjLuoet6XoLWrKuKWDasPzrFnsjMOT+NIzURHtXc=; b=F14FkdT6McI8jF1AsxnT0vOpFzJmaFNHmvTofW/rXxEyyOMHjBQq8ISpRn6C7aWxtM dBofqsoqBHrR5PRu4hM/gmqGwMFrdALBZ8+mWtSQtnyYNXU4ArGMnxge6slMTYwiGEc+ rdAkbO9WzbkcDl6Cjp0XL8rTWj5mKRMLnumGzIViE4tN9rotF7k4JYEck6ug3Xm+wAp5 FBF7hoGND4yFeyMhU9a67ZHUrUrRxn0m8qGwdd76oDD/0HXG81AQAXbCQR4h8tOaF/8B sIOZvihKWFjB+pD7NEEIsH85JRnlFoXUyNhly9izlJuc/S7Yo7lS3e7yXLGE2U4bMtoB AMow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769671851; x=1770276651; 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=1MSGjLuoet6XoLWrKuKWDasPzrFnsjMOT+NIzURHtXc=; b=iCLHcFuXESBMJq5YffQ++D79LipZea3wuRS7zzK6JETxPBpiQQOJJtz4hbzhJi8sA3 M69eUXF+l41GXnrTeBTXT67XjrRPjuMOxlpKTx0BIY7hvhtq72k7JNiKFKevRRa1E1w4 1aq50wjh11M0gkmpAeryyRBOR1nlNLuXVttG4mmuMGT62EAnAU+/wIy83EX/O7chRDpQ i51qhDIyGVseDd4kVRFNs6Ez0zYVXOv87uJaGVthppusEpv3Uh6XJc2wrbKXwfQD7fHD Nn+mJ3DH5ok8w/OZcCaXhtjwWfs4QjXK5kwwT+QJdVu/KElfxDCPteTowJBw9yC5CgJB wruQ== X-Forwarded-Encrypted: i=1; AJvYcCWfOkdGjNhIyBQ91ynFpn82mWrjIsI9t8kFM+IC6x/HNmT7RjERlLUC5UCgAmOuLqJxvxM+AXQrz8j5ASM=@vger.kernel.org X-Gm-Message-State: AOJu0YzD3G6rnQFPp1l8oUtRxkMeGAJz/q9AA9o+sNpDdpR4MNe0X5dx QjF3XBl3GV2EGUacJSH8NfejAKTBowW3+GA5J5lQCWDje+d1VCnsk2Z1 X-Gm-Gg: AZuq6aLibnmpEFZr8a1Zda3w6xxWBBRxaZaJS4DgoxLe91AiahNjOJl4Qlti519ptLK xoEqJMyIf9hXzp7TtI5eKDt91zeWQYpoMGbAdZIGcM0BssUefxxi4YyfS67+1aY7N7sgJMxsPB4 /I+80Pg3mlaD0cl5e443qEMJDtDxqOuwgaUxeEdk3LO8OGz47tRcyO2X4Sk49eRkqMT8QY3Eo1S M/im4SfRHARxZfHC7/3JbYzqt3rsx475x1i+Ifili0r4mQQrzeQeO0FSbyA6lN0Hp8j/M4Z02Vd H/sdvHm2xUppXrzI1fN75ji+pNOA0UVPv860gEqg1D/6ZSZRmeHCr5y95bP0khA6nTjSwf8NYBd I14tpgHdhTNkxb47JIFjh2nssJLB3vZtfw2BTcOI99gen+/gifXO5/TEpWexYhsAc53zjM3r3f6 zlR16/MqeLs4+nlnwGquDbqO9FrAMOYdIo+m/AD/Xn X-Received: by 2002:a05:6820:4588:b0:65f:1012:69c5 with SMTP id 006d021491bc7-662f20f917fmr3325685eaf.76.1769671850804; Wed, 28 Jan 2026 23:30:50 -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 006d021491bc7-662f9961dffsm2869395eaf.5.2026.01.28.23.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jan 2026 23:30:50 -0800 (PST) From: Jim Cromie To: gregkh@linuxfoundation.org Cc: Jim Cromie , Jason Baron , =?UTF-8?q?=C5=81ukasz=20Bartosik?= , Louis Chauvet , Bagas Sanjaya , Dave Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org, Petr Mladek , Shuah Khan , linux-doc@vger.kernel.org, Andrew Morton , linux-kernel@vger.kernel.org Subject: [PATCH v9 17/32] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module Date: Thu, 29 Jan 2026 00:29:03 -0700 Message-ID: <20260129072932.2190803-18-jim.cromie@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260129072932.2190803-1-jim.cromie@gmail.com> References: <20260129072932.2190803-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. 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.52.0