From nobody Thu Apr 2 20:20:47 2026 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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 08F1C3AE717 for ; Thu, 26 Mar 2026 18:54:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774551298; cv=none; b=ocs6l7+aN4LZm19KeCtqpM5fXZDbqrb7iqzJ4sO0QQTq2freME1G6fFJEqpYAI3FKVw08AkJ5RddvKBFYOCSxarozVOkyIJ0ULzQTGvlkiAceiyaiEIV3kS6qF7p4rFqp72QFGiGnUC9zmixBUSqPDbzo9vPkazaRAcK15UJ0qQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774551298; c=relaxed/simple; bh=NxQl7h9bWLiIoq2p4gJ9qOg7QnNWnUPnOXXB1pgHnho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BnyrKIseYHdKIn9pkSdtMJHRcdzUlFdqfNAJv9ILuCixgb0st3GxVRv0TY1uKiJowcJyruraFiS36yH9xHZry68tGasOrZcGd1Cd3AwkjgBkWtBTlZUfwpJX4Ir+uI2MEELw10nWK9j4lNSfKuAkmWUM2bjLuKnCGp0vYFIdyTU= 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=A8GK4MKN; arc=none smtp.client-ip=209.85.210.44 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="A8GK4MKN" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-7d7ebe11bffso1031852a34.0 for ; Thu, 26 Mar 2026 11:54:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774551296; x=1775156096; 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=MC2lsh0Qhp0IwkFoRFt/G0LqEbae5jgNK4VV9aW2FC4=; b=A8GK4MKNSJuy5DoajckxO+t0eM0Lq87EeZnxXhUhhNOmwKeQPftiMLC5jndMt56oQ/ xJ9nf7oBMtg0zbxOMn2g2KQgyTG4RWifu2uxfUX1szbkbwFVzmC9Cg1EBcD/hN7nwkl1 Z4yJpVnkTFo5rnuttpSbmyGC6dnBiBlMpkTLEhjwBYg1FR0AH1ZQyfaa/ZbFXJ16frF9 Z+pnuIaRtPMNxekWLGWjcZxcncy4785wXqBAwl3h9SuDbLRUKV2SQA9keNa+TGKTTOsE vnncz/AvAstaV6T3cye4nFKVICzQ/xbofv5njakrFMQSdRb1neKhQwbnY/oux1hJeu4s J3Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774551296; x=1775156096; 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=MC2lsh0Qhp0IwkFoRFt/G0LqEbae5jgNK4VV9aW2FC4=; b=YBLaULwk8kpooJa8h/5Z3zB10xoewBrvMLKznYjfZV+gUpCNWruGbw/6lMnexS3yqI /KSLZNsTg1CpXh2gHWtNkLLZfnR6sjA18swLx0vFvl5i0QCVC5OgYolnN07gVqA/jOZf 6gxz25Mf+tiluLEzWcGdibvn9Nx92ZxTNwfmjW2bK4L82SkfPtjWbsZ6unXwZqcKE5dX 2uhEfD7vUGYUh8ALsO1+fo4dV7mb7yYElnjDCk/tbWr3f/8/kTPI2ya1KoSu9da01pi3 kWHGVaXpG7tk79jv7FfwS2Ec/it1yl5J+X4FdHhRsCPgGkEO4dDN1BS7N1f/YpdTU47G 3IxA== X-Gm-Message-State: AOJu0YwbdlJ7OE5zgCF8Y94OvZYTZNAMlkXB7F6A1LwBLSU4nzk/hD05 UfeXUmAe0MtGBO8YFFjQglisubOM654Gk2Lyg5uTj0joATn4pn3UrxIuyt76YQ== X-Gm-Gg: ATEYQzzXKGRzllp82gyDxOi5FQpXO8oIUl32oZmRRlqJkrxSLcn7w7nGp17ADyVu4HO Z7hBa2wx1nHVH9ymiJ1cUUS3N/q3xJBoefXS4htHa38ZM98afZw8fMP+XO+nHEqVwuwlJnBEW4u dn/1mq8GzzPmTilksYVHEHj0z30mBQyyV2izLR0n6joQNRQY3cHhMei95ws3luLkwni9wuhF/WN 6RGBtp/1th+/NY9RKO0h98aXQpWK1vXIf5OEcZdd6CnLl02zlLJACL6z1vzPMK7/lsuUP2UGloF VLjiiINJTmrZEDm3GB5FF2MLM0/frWs0hpiACZdw7E/QBWsaLDOGO9esty131zjVsMb9ZXpy5tE hZE04mOMfhe/NwKUdMfQcYEFjOWiM6H7b937FN0lhqfvWM9MrBacgsJXiiwXvqAgz7q6WDPENgf 2k5fARr6CS8i9w0GSpNTaM3gvZYkddy1vP8ISIsFfoed5J8eVm X-Received: by 2002:a05:6820:1686:b0:662:f2ea:8f9b with SMTP id 006d021491bc7-67dff41d463mr4535409eaf.20.1774551295761; Thu, 26 Mar 2026 11:54:55 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 11:54:55 -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 17/69] dyndbg: replace classmap list with a vector Date: Thu, 26 Mar 2026 12:53:21 -0600 Message-ID: <20260326185413.1205870-18-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" Classmaps are stored in an elf section/array, but currently are individually list-linked onto dyndbg's per-module ddebug_table for operation. This is unnecessary. Just like dyndbg's descriptors, classes are packed in compile order; so even with many builtin modules employing multiple classmaps, each modules' maps are packed contiguously, and can be treated as a array-start-address & array-length. So this drops the whole list building operation done in ddebug_attach_module_classes(), and removes the list-head members. The "select-by-modname" condition is reused to find the start,end of the subrange. NOTE: This "filter-by-modname" on classmaps should really be done in ddebug_add_module(1); ie at least one step closer to ddebug_init(2), which already splits up pr-debug descriptors into subranges by modname, then calls (1) on each. (2) knows nothing of classmaps currently, and doesn't need to. For now, just add comment. Reviewed-by: Louis Chauvet Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 1 - lib/dynamic_debug.c | 62 ++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 92627a03b4d1..9fd36339db52 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -84,7 +84,6 @@ enum class_map_type { }; =20 struct ddebug_class_map { - struct list_head link; struct module *mod; const char *mod_name; /* needed for builtins */ const char **class_names; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a18f4bc63473..94a66c8537ab 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -45,10 +45,11 @@ extern struct ddebug_class_map __start___dyndbg_classes= []; extern struct ddebug_class_map __stop___dyndbg_classes[]; =20 struct ddebug_table { - struct list_head link, maps; + struct list_head link; const char *mod_name; - unsigned int num_ddebugs; struct _ddebug *ddebugs; + struct ddebug_class_map *classes; + unsigned int num_ddebugs, num_classes; }; =20 struct ddebug_query { @@ -149,12 +150,13 @@ static void vpr_info_dq(const struct ddebug_query *qu= ery, const char *msg) } =20 static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_tabl= e const *dt, - const char *class_string, int *class_id) + const char *class_string, + int *class_id) { struct ddebug_class_map *map; - int idx; + int i, idx; =20 - list_for_each_entry(map, &dt->maps, link) { + for (map =3D dt->classes, i =3D 0; i < dt->num_classes; i++, map++) { idx =3D match_string(map->class_names, map->length, class_string); if (idx >=3D 0) { *class_id =3D idx + map->base; @@ -165,7 +167,6 @@ static struct ddebug_class_map *ddebug_find_valid_class= (struct ddebug_table cons return NULL; } =20 -#define __outvar /* filled by callee */ /* * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching @@ -227,7 +228,7 @@ static int ddebug_change(const struct ddebug_query *que= ry, unsigned int nfound =3D 0; struct flagsbuf fbuf, nbuf; struct ddebug_class_map *map =3D NULL; - int __outvar valid_class; + int valid_class; =20 /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -1134,9 +1135,10 @@ static void *ddebug_proc_next(struct seq_file *m, vo= id *p, loff_t *pos) =20 static const char *ddebug_class_name(struct ddebug_iter *iter, struct _dde= bug *dp) { - struct ddebug_class_map *map; + struct ddebug_class_map *map =3D iter->table->classes; + int i, nc =3D iter->table->num_classes; =20 - list_for_each_entry(map, &iter->table->maps, link) + for (i =3D 0; i < nc; i++, map++) if (class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 @@ -1220,30 +1222,31 @@ static const struct proc_ops proc_fops =3D { .proc_write =3D ddebug_proc_write }; =20 -static void ddebug_attach_module_classes(struct ddebug_table *dt, - struct ddebug_class_map *classes, - int num_classes) +static void ddebug_attach_module_classes(struct ddebug_table *dt, struct _= ddebug_info *di) { struct ddebug_class_map *cm; - int i, j, ct =3D 0; + int i, nc =3D 0; =20 - for (cm =3D classes, i =3D 0; i < num_classes; i++, cm++) { + /* + * 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 (cm =3D di->classes, i =3D 0; i < di->num_classes; i++, cm++) { =20 if (!strcmp(cm->mod_name, dt->mod_name)) { - - v2pr_info("class[%d]: module:%s base:%d len:%d ty:%d\n", i, - cm->mod_name, cm->base, cm->length, cm->map_type); - - for (j =3D 0; j < cm->length; j++) - v3pr_info(" %d: %d %s\n", j + cm->base, j, - cm->class_names[j]); - - list_add(&cm->link, &dt->maps); - ct++; + 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->classes =3D cm; + } + nc++; } } - if (ct) - vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); + if (nc) { + dt->num_classes =3D nc; + vpr_info("module:%s attached %d classes\n", dt->mod_name, nc); + } } =20 /* @@ -1275,10 +1278,9 @@ static int ddebug_add_module(struct _ddebug_info *di= , const char *modname) dt->num_ddebugs =3D di->num_descs; =20 INIT_LIST_HEAD(&dt->link); - INIT_LIST_HEAD(&dt->maps); =20 if (di->classes && di->num_classes) - ddebug_attach_module_classes(dt, di->classes, di->num_classes); + ddebug_attach_module_classes(dt, di); =20 mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); @@ -1391,8 +1393,8 @@ static void ddebug_remove_all_tables(void) mutex_lock(&ddebug_lock); while (!list_empty(&ddebug_tables)) { struct ddebug_table *dt =3D list_entry(ddebug_tables.next, - struct ddebug_table, - link); + struct ddebug_table, + link); ddebug_table_free(dt); } mutex_unlock(&ddebug_lock); --=20 2.53.0