From nobody Tue Dec 2 02:42:11 2025 Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) (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 60D9E368263 for ; Tue, 18 Nov 2025 20:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497164; cv=none; b=EnBZ7DEkaazDJMziRdy8tifKaJv5N2DFv4fY+8DEDeCs4NRzHPHPPiTX+9SI21JIKncyuLDxWAhMIUILQBgYIyYhIp/YvkvyrqUK6+f22vwChzc9Wzp2VaUKzWeaTf0rn8kIaupBGtCEbRjetL+/ENEy/a68jhWpO40LzlbJo5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497164; c=relaxed/simple; bh=yb+YFqvhtiDI5igd/yCrKOrTyeTZhoGGv/vnhpqEfRc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mu2ews1wIWLyfasBqnbhLGYWVrogPYTIeXcKktnygPphwaSe6XumZCPDFBr4alAcw9eiQuOwVIZM62RwDG+wuCTkEM1vm+0wErtn2Cnx2tFOfEjMPY3i2neWHvj4ZCrdQVsK+Ctj2J+uvaJaLppKebk65uPBlBob5f8pSqdgLrU= 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=lAqjO6y6; arc=none smtp.client-ip=209.85.166.51 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="lAqjO6y6" Received: by mail-io1-f51.google.com with SMTP id ca18e2360f4ac-9490a482b7bso108349939f.1 for ; Tue, 18 Nov 2025 12:19:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497158; x=1764101958; 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=57tC5fcXib20YlGSpjepRBmCcERyspoSOH53yUhNSS8=; b=lAqjO6y6U1BQpQDR2TKs2b1vsuZMIn4EDXVvtdf5G0AIajecXaS36ab6b7WHUSRWuo KiXkcYnx4PddZ0Cl8Gd9I7s3/cjvGS1jZfWjYqKEmUo0ZbVBlp3WvZ9FKp0lafK7mQV0 C/nEqG0nDA9byFp0oacgfgX+SkGb2KU3BlWB8t0Ax2UuKt3vfoL54+SaWuGbRT0/AbEF 69wYsiGFPl1vHEHCNkCN1PRrIFGYVRYcDzvnoYOSRNQfQTsEduL3bMpiSE3c4kirXBAd gjs3cnklCzaN70XCyPi9VGse0wW4VhV/kS6PYyijaRBHqQLXQVLHgxvU6PrHGYmIcdYu qC0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497158; x=1764101958; 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=57tC5fcXib20YlGSpjepRBmCcERyspoSOH53yUhNSS8=; b=FJllny1zFxUIqff7Q+dRdZUk986EOWO5Nm/ZInNjmoOzrtBvT6cGLhAiOhuWgderjM UWoFlb6Pa/sV7dmHan9QLXxjwQhytETkOj4wkUbBh7l3qzNaYKfNk0hKWwTXTo9WNRyW sfhftbg8MH8wPwLb0cjKpApHIuu2oyC89El67TmRm80rYaiudUsnsy7Sm3BRF5xu+3BC PXQAbWgPpUBihbU8SSdMQnZwL27MMi3xFxI4PmW8oSrkuy05UhwWD4GWqruogVlQq+wG lVlUw4GXwoNYjUxsz2dmCJ6xTjBsFQ0TYcadXnXfAinRb0Fg8idn7NHJ1QAeVDWt5OPk nMFQ== X-Gm-Message-State: AOJu0YxsZ1yAh3tRVCjK1rnEspABby5S3JgivspQc1gzsl8fRJMOawfU QbaXBqeDuqDpt63iYVn0LkxU+IZsXHZ7VcaptRcL6fL5WadeXfgI6PHMclPQcI4M X-Gm-Gg: ASbGnctipOe3182YAlZ2fi4DIZUkDTYOicdzCNSpwf/gVrg3u1Jgsp5amJXkiF8Hg2A C8yPsAIH6XguE/IolObtTh8IVDAZOkdU3QCsaazTx8DQCaXYjHCN/VeIlSsnLbhwZNl3iG2JkD9 O9CIi/46KFflelJrVB5fl2+7CTNoeLVQ3vGAC4K1d/7ZcbEMljmqJcVSDVTLA5wiRg8NQRMfQyb SujGEJamwjSrd5lBYm6TKdTvqyXVsKXloNa/4+LniylbfhDB3mpuBNxlWp9qg7gUoWyIcNUy9QQ FImpdsHU9VeRNtS4l1i+dsg0AO4zGeBpmxqWv32qqzap/ei2EfDz4pE+N0T4yQuZLRJ1tMuWdhK maBAinlt5No5UjN0vC4Ziccovz0v3sZqAxMDjdTPSgueIU0u5uz5eKK0XBK2uHf3NviPjV/2Ho1 usLvfWQ//bOh+mVvfbIj0KZQCsuc5BfWCUbJC3fEr3erbEHlxxKS8nD+IoWxEYTwKxEKFmrxUs8 2XLd0c1p34JJF9h X-Google-Smtp-Source: AGHT+IHIJhkaq+ArqTWu43f/20jDi7p+m5ELZRQSWIDsTyPD3eZ+/5krpCWNcCzDlN6i90tbPAji5w== X-Received: by 2002:a05:6602:15cb:b0:949:93e:bc0 with SMTP id ca18e2360f4ac-949093e267amr992147039f.8.1763497158526; Tue, 18 Nov 2025 12:19:18 -0800 (PST) Received: from godzilla.raven-morpho.ts.net (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id ca18e2360f4ac-948fd4c273bsm419823939f.18.2025.11.18.12.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:17 -0800 (PST) From: Jim Cromie To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, gregkh@linuxfoundation.org, jbaron@akamai.com Cc: ukaszb@chromium.org, louis.chauvet@bootlin.com, Jim Cromie Subject: [PATCH v6 16/31] dyndbg: hoist classmap-filter-by-modname up to ddebug_add_module Date: Tue, 18 Nov 2025 13:18:26 -0700 Message-ID: <20251118201842.1447666-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251118201842.1447666-1-jim.cromie@gmail.com> References: <20251118201842.1447666-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 --- Ive review checkpatch complaints: all are lvalues, and not issues. CHECK: Macro argument reuse '_dst' - possible side-effects? CHECK: Macro argument reuse '_sp' - possible side-effects? CHECK: Macro argument reuse '_vec' - possible side-effects? --- 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..49de591f036a 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, _dst, _sp, _box, _vec) ({ \ + 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, dt, cm, di, maps); + if (di->maps.len) ddebug_attach_module_classes(dt, di); =20 --=20 2.51.1