From nobody Tue Dec 2 02:41:30 2025 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) (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 3366B2FF64E for ; Tue, 18 Nov 2025 20:19:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497158; cv=none; b=aysd5KfJ3Ep/sMek5vSCy1mEWwBs/mHVBwYCkhZTSx8qynqd5VyWkhW2v/Nb7RAhwqDZr+qAT04+GjIyugyU8fB4abOsuh2yWL+nEjzaBG5NNpD+uA7Z7iURUcKExe2oVEcRIOIymTV4+04zO7xz7TmSXX7CQeDEHwKlMBO4T1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763497158; c=relaxed/simple; bh=bL4ibxMMbvG1UAfybh2imUq82eqkvgfowHH3kNvv034=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q73Y0IBaV9K456AHSuBSbGPEarQr3ipTZLezs/Hwf9m3ES3W0YKigzMhjvnkI0k5+oZJYVEX8A1jNaLTRg9hl40AS9OgdM7wDQ6rO/CFC4nunJLv5oXyrIpKBmSJAKzeV5afIHLVR3vVyfuj8C70YsAM5nX2rPa+1Cj60OupXqQ= 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=QpV7FXnu; arc=none smtp.client-ip=209.85.166.46 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="QpV7FXnu" Received: by mail-io1-f46.google.com with SMTP id ca18e2360f4ac-948733e7810so226467439f.0 for ; Tue, 18 Nov 2025 12:19:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763497155; x=1764101955; 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=sinG7VNY3wU1UNNZMH5t/yVFvlHMG8pS2a7wiUGdlB8=; b=QpV7FXnuckxW6SndB/qJNmUjx8PQ2h35lbbjr90TFfRznzoP8n3Iq6Tgvrhl6jaI5g /CoU3fbUu4i8QJjgSyj6D1si2Aihakq0AAI/IMYVPOCp10eG85A4xUMAGAWvPQbfEwBq Wnj7YBfaaEm4uWtBKjP0AU3cjmxealV2Dh3fBeZTvCzjoDwW3wgcm3TO8dYXYbhf4G+w Y+2cQZuZucc2MLnhBB/GiYHIbz2NPq9bPaIoa51yZsKn+5UZ6Av9qnE1VAU/yyWTNbxu M1elVB7gknpSX2Ze2e/0AA29mjC/B5TQvRsUEvYO5eZkZC4a8o1mLmLoDqBD8akzaf6v O1mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763497155; x=1764101955; 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=sinG7VNY3wU1UNNZMH5t/yVFvlHMG8pS2a7wiUGdlB8=; b=gOWRyok+MO7xF54wXvyCGEHb5z+wXwkfo4snS8M53Qi9YtBkr7+E+15N/y6/b1bXHU 6RVuli9zmk3IblebtI4O+wNpgZjVZGZ4ZJZqSRoZ3CvN9/KLqAq8dQCDkIddRZ4DWGTg NlqeRXhHRzYmSsQBeR3MgPUdhg1TgmKCTfATWX5y6eMWYsPeP7IdTcjSutqgEKxfLhap gb2iSu7UG1wxKqnO4tCc4QjWiLe40ipPynUPavX/QXTiId9++2/9JnCmeyNyVQP3gZwR 696vPrZNPm6G0HhrnDeNCIXXVwiy+hZfnt9oILubDAGbeRQt9JBAr7petm+sPeB740HR KoDQ== X-Gm-Message-State: AOJu0Yw6H9sTGvoyEz3X7Vo7GTY6ZGMmql149oq+5AwwPo8a6zM9sF1t NnWANbBNTzpAwAYqI9JcXl6pVPlz5Cyn29zt8GXIYclKr59X/j8r5ZjFiyNRxDHE X-Gm-Gg: ASbGncv07bcasyly6WZr6Jm1fNn6zCRVbBccF/zGhZdyGoekFPGrr9aPMZ+WX8tpp95 5dZOz2SUlNcqCrP55xHBoTSLv7dHa4kYMU4ZSTFAifI+ufh0SfwXy2hvn9NuSz3ySCR4Ka6gKci hDrluDZIjB5Q3fbuoHM3s8akCLfOosits759b1YcZKGzB4lL/76AozJlt+JE9+4o4kB6xKoLedI QzBthndcdnsUPXKkHdRYdSOGwoDmQIiSkYD3w5SKsU66ZaZFGwI9Zq2UkJ2cBoc7wH7t9Rp25y9 e5slOhdosXJB6Nm5BnyUSVS7YAx3AueU+Jvhln3i6B2qMzyZpfsFzP0D96y21RLvuU4GkJ0L+iJ z2YFRoVzsM9oZVkILwDfLnwVY6VoYVyfbaxTLqPa+bpYvp56nwQAMmA8KQLq6kDOCe5uoJEFlXd tJ0uhgUJ8kF7ClIU9plBDcaOvEPPsjipcytXM/5Ig6irw+fNcaO9q79X15AxzCVZ1untBzzCR+j wM5lg== X-Google-Smtp-Source: AGHT+IGLH8MW7sVNPOn75BPqpruphqjyrqoEjIYIdZ9n/nXMEfVigTO8hiXOfgareRNrHy3bHEKarw== X-Received: by 2002:a05:6602:1551:b0:949:f77:4231 with SMTP id ca18e2360f4ac-9490f7747a1mr751322939f.3.1763497154983; Tue, 18 Nov 2025 12:19:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 12:19:14 -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 13/31] dyndbg: replace classmap list with a vector Date: Tue, 18 Nov 2025 13:18:23 -0700 Message-ID: <20251118201842.1447666-14-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" 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. Signed-off-by: Jim Cromie --- v3- drop __outvar as promising magic it doesnt have --- 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 c4ae79f934d9..51ed26e42032 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -83,7 +83,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 db0559763e60..e882e951d585 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 { @@ -148,12 +149,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; @@ -164,7 +166,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 @@ -226,7 +227,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); @@ -1133,9 +1134,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 @@ -1219,30 +1221,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 /* @@ -1274,10 +1277,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); @@ -1390,8 +1392,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.51.1