From nobody Tue Apr 7 12:55:29 2026 Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (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 50657330B3B for ; Fri, 13 Mar 2026 13:23:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408206; cv=none; b=V4wJcto2EdCA9OrspyOGovPDJZKuQxy5e6GWXv3JRMAXO/pZbw+uMJjuCRMn066dO5YYo+daUYcs8C99XdRFsF5cgPxihYM7Mhnt5g7f7JiClPuLxiPdqamFue1454A1UWrIQq/xIcGojwcgSi71yb4p8CBT+UdqRcjUM2dEI1E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408206; c=relaxed/simple; bh=NxQl7h9bWLiIoq2p4gJ9qOg7QnNWnUPnOXXB1pgHnho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L6a2U4LhV51o7zaOsUXY9hAbF7iDQSYwPr0W3nKBNtPUy0hTXG+MzSAL5+Xq/nPnOjLv3MsaLlQAkUuLY7YBlNttM1DURGyRWfllHw8QesL2FH5jyDcOkpWEYNn3GeXTAVERgEbecFOU3Xh2DT2JCLX1c/hXqQQzT3I06aLYYoA= 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=NVABEWSo; arc=none smtp.client-ip=209.85.167.170 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="NVABEWSo" Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-4670676ba03so829421b6e.1 for ; Fri, 13 Mar 2026 06:23:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773408204; x=1774013004; 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=NVABEWSoxsfdxgtY8Y3RreAdftZWjb0omOz4hF/3gF+QuZkZFioNzghINVXzoNAC0z 4KZE0OkD7L+rw8s8CF0ugQUMyFozl7xAWm9lki8TUwNl8oy4c9PvDA6sTq5jHOKlRRIq OyeUkzcC/YEtMJDG6ldrc/WUhHhM8OFCtgv5KVYOlXG7fy6WpfqSsiIvn0TvLUTXO9yo bYzjcxgJiU2d03dLU+gUdKr/MYpf6Gi+wR9bRXIoeESGtmZc5hwBpyFfMXmZsIXJU6+U nAKA70LGpwUD3pqbvtseGu4I15ppMQwKX+ZngDrgpfVv269w2H9fTVqxztxO3lhEsT4/ RKcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773408204; x=1774013004; 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=BsmPUXQuuEEbfEiuFkwHhNfUdq7UDF5xQFEXSBkTgKKtjwa4vehqn9kuNgotdomiRZ YC7igO3n/F8laGqZUldvLd4kJ/gX5Hosey/poGGn0XfI2RupWMgtqn/DsaRPRtp2XECj bL1RE176t9WWU0RpqacUWrDjdMx+1CtiZUPnRN3k2QHXOYi32P2esUF4MVddK+xieLDL L8AKsUMF6lpKdNkJho+NZhhbW3P41u9+WXYJIk87VUcZxCWzYTu88s0uHlvnq+lPVs/V 21DNROaNSW8tFIl6ZUrNW0nHfMJLPUEsJdFwh0iHQSPsocHAujFJzc1Tdvrz7nZitks5 O1Bg== X-Forwarded-Encrypted: i=1; AJvYcCX8eyUIfnhCHi9G1MBM5q11YXbSmPjixNK4dWEMJ1lKX3mYai0zWXE5ly34S10Zlewz8aMwhDGoeZjGzfg=@vger.kernel.org X-Gm-Message-State: AOJu0YzM8avkKz8dI4RFz3v6Hvs3w5ZShTzdcId9U2CQBmaPZgkRYu9J 7VqwFgP3NBrSOTFVXW3/X4/T0DyrxSTu1pG2KWiKeT2ZV0KawhknIRAS X-Gm-Gg: ATEYQzzfeLYtgRs4B+CYJSo5Jd3qrnGlzNHqE+8mrs95wrnGAEXGRvtCiyY4fLVcnKz l/bOf07cDXkmaUp7uN2tatqkH9LHZ1/T5T6airfb8hHztQ9El/9CFFh6Ugos0OBc8bZL1u83kw6 bJBw9bPgfSm1ZJodDprDQfEwrqCOAN90vBcUDaDPw5ll4dcD3l1JboykiuDuf4Fu+pnG0Wqe7ta DiEZ9mayPhOn9O6fmwPL4MwdAOBRuZo9U2IxI4xwY7gKgZwfj2Fn39aTeU38A9UgjdnMorepxYJ xg1ZFaKmO/CRdmLvvg75Xj4JTVmKRU+ZXHXE9S8gAoo6sbOmI4hDTI2OkgYjVxsrNx+QhVNewI7 TYuxeja3Us559VyfESgWCbf6QRgxzTnhND1J70pqmFxwNjMB1BGpaMimEJkr/ZjChmrHdpLEOvj nj/NQ3jysvciLwyTWUTuhqQ9J5BNqDlKL6A370w4WcnN4DqVuMBUvzNvsz3VI= X-Received: by 2002:a05:6808:1641:b0:467:2be4:9e39 with SMTP id 5614622812f47-46757550476mr1689903b6e.39.1773408204096; Fri, 13 Mar 2026 06:23:24 -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 5614622812f47-4673434a35csm4795987b6e.20.2026.03.13.06.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 06:23:23 -0700 (PDT) From: Jim Cromie To: airlied@gmail.com, simona@ffwll.ch, jbaron@akamai.com, gregkh@linuxfoundation.org, Jim Cromie , Andrew Morton , linux-kernel@vger.kernel.org Cc: 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 v11 14/65] dyndbg: replace classmap list with a vector Date: Fri, 13 Mar 2026 07:19:39 -0600 Message-ID: <20260313132103.2529746-15-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313132103.2529746-1-jim.cromie@gmail.com> References: <20260313132103.2529746-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