From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (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 3DE8332BF48 for ; Mon, 22 Dec 2025 08:24:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.193 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766391858; cv=none; b=g4In91xA3dOhVI0VKcdUzcnIMHouD+MB0Ro1CnIeVm+r0nz/yXO6pwH3yVl7S4Cy43Z1oQZYcfY91mQ5Td/EkQDBJ0evLIZ2MlGl3Jclc//pFuUVc/Ummu0CFeqlGOHaP6LPTi2YUxRnreTSBlu8r/wQKmGofXeU92yMjnzG1nA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766391858; c=relaxed/simple; bh=lMCW/HO3dpm3FiqsuiIdY8qF5JU5ohZP1EB8BC3NbAE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bIIG1QoJwbQkFRikS8EyPJyKtSdsNCGuxuRP7HXElgV9yqNNQ0zsCmk5tm9jY4tCDZow9DbkW1i/3jcWLv8AavhqZkaXH4JNNT8VaKGRyVBBkY4OWbi0s/Tv162FpCs1SJdXwqIO6aO7PQzR+lGrMyQdfNYF/IjXJn8l2UtFDjE= 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=cFIzF7SY; arc=none smtp.client-ip=209.85.210.193 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="cFIzF7SY" Received: by mail-pf1-f193.google.com with SMTP id d2e1a72fcca58-7b89c1ce9easo4232741b3a.2 for ; Mon, 22 Dec 2025 00:24:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766391856; x=1766996656; 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=saj8Myj0AXkSu5hKZJBWN47Kb5BefKCe0HbhKcuaxLQ=; b=cFIzF7SYK7JSu/yGr52anyOwTe4C1ICsgSTxEHKG7k/RHPxZLoLHOwlMYLHW6AGhOQ cqjgg3vuVB3Lzzmbe5tPl9lqkx9ebl3LU9rXcbkNhX9acyIZ2cZXRpMVPwSr6SufA+Qy d6dRP9yEDvPTIy1xE1kOBIGg1hj8deBwgLd8n4fK6QRc8tORMY0DejP96rRBHKnGZSy+ YtWCAfXmTe2jP50ys0Q3JOuWiQC/yknfTqI+Wge0pfL4ZOlaSfLjj9S/JNkoYkbvJmV2 FMmeo9YQdltRmBLtzBipsUhiSjHoM82fgT1/ONhqvMZdRQh/KVLFN5tPu5QqVtk5bcXj 1+aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766391856; x=1766996656; 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=saj8Myj0AXkSu5hKZJBWN47Kb5BefKCe0HbhKcuaxLQ=; b=Eu2xcC8OWkn09OGkMv5lSn3qDhV1NAHXx+USdsUDidHqAlsqr2V3zNFjzmyLl7LvfX D077JoD76I2ArUAAuZj72KQo3TAniqzT1EvlaX8ZkUnGX2BM04R6CysQLxWz0CnFwOVw WoZUMGGAf2b5H0z/MKL6xrZovW4jewygE3oMwvNjAwKGuqWdIPS5eS1oHtYzCnQiKSIE WWL26NDinUya7f7s243rlaQ1DglZmSGuGX1t7YX5zoz1XLC9jGWp5EfuYIMGvUc+GQDV ubTl7cuff/csuMA+FehoFNNtCtQc0tVXzu01v79WMdpWp4l5pFQ3/Z2VzZL3mibV7nyb J4/Q== X-Gm-Message-State: AOJu0Yxi5rfJIoHjakbWmX92WFaV/fFAYXLtgDZNukcZmRT/Es2tHsfG ilbgpzF1n7BcshlCgSGRlCvZJGqccyuNeA2nCbl3V82TJ+A2XfF6vneuynhTntIs+yzfog== X-Gm-Gg: AY/fxX7LxUIxVsQ6LdhCLa7Dm4LIYZIutR2USQK3tDw1vzEJnwF0hZR4fesKQPzzWgB tPiEpuXFiRnxcGdxHvVXhbPGz81CrvBhWhGn1+9WbkOk2HQw/LthnmdavCWw3ccKhX6iYBXcM68 HziY5oSCw1yohv1Kestzs7vSYUn6CcRsjH6nNcJJyfYFaMPKj7ItZrJcOTjtEcn46gOulzaVV7Z W8oBp2bWQVch4rOXoW9Z0kM+BaU1xi/tKXHO0umCR46aYE1kfz37ZS5WbMgc9Z9DcumB6I17eph MLFLqSRZ7e3bCx+ZzxudwqqS+BjznozfIFqnSW3jbCHcp/j8AkvNYauuZPz6jSfIj14fp1b7e0P D1VHaURcVrEXJPx/iG1gYLjdGtKa+sRmb2atHtJbji2rKnnfZ0G+sKQjOoNdQ/3iqmjdopSQ1er kg0eyx5HYR X-Google-Smtp-Source: AGHT+IHhfCBl2Gb658Wb5nP4VimtUGUrU6/VY0t3P4zkMX/95OPPHKG9Ys2L2e1xsI+aRFKPN12sQg== X-Received: by 2002:a05:6a20:9189:b0:366:14ac:8c6c with SMTP id adf61e73a8af0-376ab2e8f52mr9605414637.66.1766391856304; Mon, 22 Dec 2025 00:24:16 -0800 (PST) Received: from frodo ([2404:4400:417e:3d00:8b90:7f55:1261:772f]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-7ff7e493123sm9540699b3a.50.2025.12.22.00.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Dec 2025 00:24:15 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, ukaszb@chromium.org, louis.chauvet@bootlin.com Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, groeck@google.com, yanivt@google.com, bleung@google.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v7 16/31] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module Date: Mon, 22 Dec 2025 21:20:33 +1300 Message-ID: <20251222082049.1782440-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251222082049.1782440-3-jim.cromie@gmail.com> References: <20251222082049.1782440-3-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 c9377a444fc8..d668140794ac 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -170,8 +170,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; @@ -1247,30 +1247,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. @@ -1278,6 +1283,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; @@ -1300,6 +1307,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