From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 B2F0038F23B for ; Wed, 8 Apr 2026 20:02:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678556; cv=none; b=qaPkKIYbdo+yHkOiNRZc2UjxvM/J6K6i3as6+vq26pGVqBgFc1ddeM2TixulZZ2Vj2cJSpfPHyCMBv9WlNpKfblbdXp/zT76C9v/WsIvRxT9SNMZmZlL+BQC5v5PXhw2giFjqUmtE+irakg35M6XK7fChAoeHfUHaJouDkiNAuk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775678556; c=relaxed/simple; bh=NxQl7h9bWLiIoq2p4gJ9qOg7QnNWnUPnOXXB1pgHnho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QaAOi3n3dX59h4QewnWwkQW9PjDuWGcRte8+I/qiO+3RXrESMNjEcMsXyNfa4BD2LqkP7WYvMauf4isfT4arodB4gXQ1p+0c+Tq5cqDmR38/FaZGGNoeNqlTTH5SAZNqfGHL2F634dH2hMw5/bl0oFqiaPd4Rt2akXVQni70HaY= 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=Hcjj9w7V; arc=none smtp.client-ip=209.85.161.47 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="Hcjj9w7V" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-685013eb590so89308eaf.1 for ; Wed, 08 Apr 2026 13:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775678553; x=1776283353; 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=Hcjj9w7VLwwRdWvacuYn4hSg+TOGAH15qDbWfxcWPcwTgNQGYYQ7yQZ8z7VsLyR0IH JyEF3KYl2CgKkCs4GsqUPnwAjlN1eoAXCQgBSfIhLKN9VvnfTjtfiMIm15nylmViSp7X r4aCBPdkgXQ5AJc31m73+CabnMzW1BL8RJKv57dr/HatHjlOkAnh2j1YD/OKn93eUxJ/ H7X+Us8Sruz1fDG2KN01jyii3WDoEPMs4XxVxSml5Fyow6iQwMsTaTz+mNUbSK9XzM3R ueWrPT4LT7UR1165Lx7aZD0rSEfpjOEnS/Au4rxc3f8ewWQ3MYsYbrjpxaYVNQ8kPIhF PIBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775678553; x=1776283353; 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=cDO4YD8wPkeWrGvDIuOP1+umMOAHm3Aa00sCXawjv7InoXbwIJh/0nr8XE2ifa2zLe 7RPSWM2kHboIZ6DYba1OIxAjFY36l7lQr8o5ZNDxvhCL0lnwT4sHcwaCiVxOsWAIt8P+ kyDJOcXgSihlW1KGuu5SGIq97jPZzQkc+AfZKjma6VMigvRnp3lNbBjG5r+l9YF5FjmH NeyiHC0haTtOGW29CseMK77md6UE4hqSHUsT3gEFnynXRLnjIRWOrqMu7ngqrNEoPagx qnTj7xZYZYw6x+9jAMeUFfIHdQMDstVmI5AjLzHQKaQWzVFDd3T55N694Babmu0YHSuS YihA== X-Gm-Message-State: AOJu0YwRSGUmaR5yMo72rTkZazfhP0xQxesC0VpIXS0ytG6vdiKtkFqo NHF3RethjJ5lvEtguqfGGNFFMRe2O5FvwrntgvPTDituoit7qfUNla0EhrCMXw== X-Gm-Gg: AeBDiet/feviX7eF2xyEsDNCuNYqdGuXPHKiPcRwn+pfYfLbnH4BCi6jReD7hdlz7fJ id3W3R1W4jZiUzA7HpqUpz48eXXyrpl5cgV4p0osODeeZsfcnbvivemDqpikOy2P3+ZZxt82Vff WEEwKHMPfiPc+KS9Uy+brP4HcWeOuwn4pFO3L55NorkC/MlEZR001bQf1krHDvFZ8V6kF/p2pvE 3zXhQsQP04NOq50eWSfs64hzF6wiYgUiZdx72UtZJecOZzKQrJ2rhG1jf7jP8JjYGmOFtF/lUVA q0oQRBuP8X4AAmVswuIuPthDE6RB26bWvIkkj3XkWgrskWSrSQJM3AuOyaKn0RTSQla5TLI726m Ootbd2Ih0oI+kPEnG5xoDDT+MAru8yLORuQINFAthm4KOhFY15tasZCmDDWa/UUiX7S69kMgfgA roiH2bbfRO4YJONlfEmcXI6qdqRs5GG3xKVNq0s2JA/PgaEpTNIX5R/r1Kt8nE2kgg5go8a8AIl L8= X-Received: by 2002:a05:6820:209:b0:688:6d55:189 with SMTP id 006d021491bc7-68a6a7b40aamr423338eaf.18.1775678553418; Wed, 08 Apr 2026 13:02:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 13:02:33 -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 17/36] dyndbg: replace classmap list with a vector Date: Wed, 8 Apr 2026 14:01:52 -0600 Message-ID: <20260408200211.43821-18-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 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 { }; 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[]; 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; }; struct ddebug_query { @@ -149,12 +150,13 @@ 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 idx; + int i, idx; - list_for_each_entry(map, &dt->maps, link) { + for (map = dt->classes, i = 0; i < dt->num_classes; i++, map++) { idx = match_string(map->class_names, map->length, class_string); if (idx >= 0) { *class_id = idx + map->base; @@ -165,7 +167,6 @@ static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table cons return NULL; } -#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 *query, unsigned int nfound = 0; struct flagsbuf fbuf, nbuf; struct ddebug_class_map *map = NULL; - int __outvar valid_class; + int valid_class; /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -1134,9 +1135,10 @@ static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos) static const char *ddebug_class_name(struct ddebug_iter *iter, struct _ddebug *dp) { - struct ddebug_class_map *map; + struct ddebug_class_map *map = iter->table->classes; + int i, nc = iter->table->num_classes; - list_for_each_entry(map, &iter->table->maps, link) + for (i = 0; i < nc; i++, map++) if (class_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; @@ -1220,30 +1222,31 @@ static const struct proc_ops proc_fops = { .proc_write = ddebug_proc_write }; -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 = 0; + int i, nc = 0; - for (cm = classes, i = 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 = di->classes, i = 0; i < di->num_classes; i++, cm++) { 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 = 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 = cm; + } + nc++; } } - if (ct) - vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); + if (nc) { + dt->num_classes = nc; + vpr_info("module:%s attached %d classes\n", dt->mod_name, nc); + } } /* @@ -1275,10 +1278,9 @@ static int ddebug_add_module(struct _ddebug_info *di, const char *modname) dt->num_ddebugs = di->num_descs; INIT_LIST_HEAD(&dt->link); - INIT_LIST_HEAD(&dt->maps); if (di->classes && di->num_classes) - ddebug_attach_module_classes(dt, di->classes, di->num_classes); + ddebug_attach_module_classes(dt, di); 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 = list_entry(ddebug_tables.next, - struct ddebug_table, - link); + struct ddebug_table, + link); ddebug_table_free(dt); } mutex_unlock(&ddebug_lock); -- 2.53.0