From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) (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 E3E27246778 for ; Mon, 4 May 2026 20:45:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777927533; cv=none; b=E7D6GU28G4x0A9bvJ6aTkQJ+lnyW9JXP00UyBu9jhjKORu6e76kii+oc4x5iMdndIt+L3ADmCeQdngus/RDMrFhcNV5A5MdgMtCfLCYTqsNUHuQKWx7KdnP/FRcGMl1nwzM5VCZ/HDqP+FINp6dG79VycCfK8EbZiIE21Zph74g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777927533; c=relaxed/simple; bh=YzpVlr+neWT2/LWkGMoyvfkqvUybg/U4Va9v6w4EBao=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MWPqQppOfwxVm8ZW2iv00eROFgP2rzRnpDgM4wxHteL5wexYkGzetW+Ju2n/18TLSySAQ1aSQbUow+Ln7DPTp4qjrP3CXSWkLGpWWeB3BOkrgVhepikAiLQ241JjaOETVZD+axMpBue+0IDtHWGZBpO0f61Ad/g0H3UXFGv+aRY= 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=gWNmFoR/; arc=none smtp.client-ip=209.85.161.50 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="gWNmFoR/" Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-6967080e6beso1332894eaf.2 for ; Mon, 04 May 2026 13:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777927530; x=1778532330; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wim9cqsthvYPUEudyHNLJdRCqnGrz1B6yKCAEeqHKQ4=; b=gWNmFoR/r+RRFSfvPgkWY1bCzRqckrilykMfFS6SWkV7NYGAkRmZCndWCdsQayyUcC 3siNgwin+1sUuFU/P1pzwhxo2UG+o9nTOYm/9HbA9FWpTq704h/Hte4ZKt76KYPEWrtq WxW5WUlhvBR5lAYN12YszuxkGmonctUOepIy8yNoNyXDEDHBLyfOjhyX4GmqIm+npeyl WSC0qRrBM/LpFan21jVgmCBQBSCxvG7fouTHj/xGkO4rZhB4QV3ANR9rMvtE1rARn8P5 oxlRyPLZjoP2L0qJcve4pANdsh7C9hNIW5OSvdvWxV0fGIi6nI4O95gUf9p899S2oOHE I9Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777927530; x=1778532330; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=wim9cqsthvYPUEudyHNLJdRCqnGrz1B6yKCAEeqHKQ4=; b=qdZVRqXj7KYEIv/yN0vx/b4ibspPRCksVsvKdapSjE6q6b7kMQ5ZG4lhOwsPjxmUjI hCBfrnsAXiJF8k/D1m9Dic/BxGlIDy/H+fDjXznn2enM5cQiuPN5Dzyb75+NqRsOl0SF ggPY6fPdWKN1ZFzSy5H0aFf5FLruTijkb4OHsFUgZwhIzdXRWf1rIWfSKi4Z75VlE2g/ UegnaB9yrcIK6QwfMYwaF5/aBZMcVlvhEigmvEq3emz/cTFWEFO6X/46vX/Tdue/GivK 8oTa/Os0oZPpn6lxShMIrQbxx+iP6Mc8Fn8SMsfebKzsyv3L8vUkYK/tEw3n7gZUGGlm MEFQ== X-Gm-Message-State: AOJu0Yz4J+JdzETPnoEUqFa66hmDqgcwvIclWbbNZaiXvQsDQskcjUDV JGM8QlT6R2jqyWoWWz+nRDBh51L02P2NCYMQrvejTL0t/4Ouigf9nQF2uq88BvSl X-Gm-Gg: AeBDietKDccS2tP2qbvSASdHFizs0t5azyZiGXGEEvsUz2Blv9QJhCpIeUsRCaqqVbK DIho7acScporFVF2i79IQpZ9e498X1AN5X3j69mF6i8UXwi72/vpl/SUCwaUuzzQ/Y+EXB1SfnI Gzy3yQ7Ttr5r2yfyr3LvCHPbcXqzrFAGzD8DrRkZdZfOY97vtj+RLsORLHLAKuGOmuTAv1viR3X KQpDUzX3dWnIzkWXubqKPRJYJd87DoqkJvYRbkij4cXdQ5GwffPB6Nry+4Y+Lw/63xlaplaeqQ2 /O47R9+abh+rp8WhuIWA6L6Yh2kDvOGXMn4u0W0IEjxgMD5VyNgXxuq6c/x9v1hfHHysgiMLfCy 8Z5IHdnEFVusNHjqoPpWgYF7RA1V4UlwgMJhB98ocVhbpbcv04p1lOVrKF8RGe/t+5D7TtWKrpM 66rsrwSwT6xW03B1TaTN9wbdaFuT06Mym95Mt+r2iuFQmZBHCp+OL1fZPzUEWFhYS4M5ZtRn0aZ h0PuNZPT6U= X-Received: by 2002:a05:6820:16a6:b0:685:d435:1471 with SMTP id 006d021491bc7-696979c86d7mr5810090eaf.10.1777927529681; Mon, 04 May 2026 13:45:29 -0700 (PDT) Received: from [100.82.231.29] (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 006d021491bc7-69689266bacsm7144713eaf.0.2026.05.04.13.45.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 13:45:29 -0700 (PDT) From: Jim Cromie Date: Mon, 04 May 2026 14:45:16 -0600 Subject: [PATCH 10/17] dyndbg: replace classmap list with a vector Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260504-dd-cleanups-2-v1-10-6fdd24040642@gmail.com> References: <20260504-dd-cleanups-2-v1-0-6fdd24040642@gmail.com> In-Reply-To: <20260504-dd-cleanups-2-v1-0-6fdd24040642@gmail.com> To: Andrew Morton , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Shuah Khan , Louis Chauvet Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, Jim Cromie X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777927513; l=6247; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=YzpVlr+neWT2/LWkGMoyvfkqvUybg/U4Va9v6w4EBao=; b=Xdmn0YJItXbm6bnC/BTN5CwaHPz2R1X2hVi1LxvxVQ3JOz+xoR9SD3arQcO3wa2SIKiXYiFpH HEAIxQg15qTDsi1qRF0aVyx6PYq12W6mDI5A77AeZLtdtFbEuYICDDs X-Developer-Key: i=jim.cromie@gmail.com; a=ed25519; pk=C6E5ODlPQo7ZBynATXH9wg7K6HxP0pIXyf4s38Qw0XE= 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.54.0