From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 9F171346A11 for ; Sat, 23 May 2026 07:15:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779520532; cv=none; b=N0i+QH9KkYO42CTOn5G8s7U4j2vf12rMgICYXKhnJ2Hf18j+kvR88U4fa/O/QS93qAE1Ywe85Wx8fObdgKkzsDHj7HGU8KPuqABdl7sL8CZCnRQPZQjr5KtVxUaOROBSSzHf2HMUOXqGWv5z6Iwm+YsSmFamGLAglCWdKM2B0eE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779520532; c=relaxed/simple; bh=acmpE5f+cy4H0euAd/sWLVbXBhuyRVdVfvkTY1QfTl8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y5e0cVVCiklvbX4qY+wWc1Mh3o0iYoG9KtQToxtLEJ6HFcnRUROwzw/t999tdNjfQONmunoslL+U5QMCttnBJ/j71DJuzOXoXzXMGhhzTkAjI+s4MOiMohz7Vod+3iZcystXb+NuDXg063JzgOEdIcH0KbnQMFS8ZrddwAiwUvs= 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=mxxfzpKF; arc=none smtp.client-ip=209.85.221.53 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="mxxfzpKF" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-43d73422431so5711995f8f.2 for ; Sat, 23 May 2026 00:15:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779520529; x=1780125329; 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=Inkv515K3CDOqGmxKUbJA66Ndin1wkzy98GUXdhIoyc=; b=mxxfzpKFQLv/7ag+vvXGxDsuILctm7/pEpYZRMdTe5mKxLbRf0qYZ/gSm6r+PxjJy5 a+z2C0MXJcysZu3SMpV8t4X7A3zhccRscwiVXl4Fih2A7VuqVw5lFSmpJOMHxqhpLgPe PV9G4lECnPeeUX7LGSHPwcOX395GARUl1qibhbgmu+agawoQ+yObUByTs7URUSkd8uXB H5p0EqYIYa8A+YV9Y9YxjfPGNyzDdGTAZAzH8qLq5bE6qaow/aP0fC4pIU9lZa8bV3WZ Id68iJQAlgkbBcOvDqM2C2RUvMK+aXaIRpG7GY+lsRAQ3pWtFSsdgN53wTSn36UVJT5y yemg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779520529; x=1780125329; 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=Inkv515K3CDOqGmxKUbJA66Ndin1wkzy98GUXdhIoyc=; b=Pn80A4eEDNEMWdthtN1sAglo+5B/KlZJIuTfuj8eg4iQU2MM+gqP1DY1sFNt53l8x4 SEewx3QwKwdiE9DXcWPdEEy2V0EKHwLMCAn6Arf/YLUqlKidTUgQ863Bhw+yjRpM031l AvyqM9wTgDQjVlan6sMJs4YuETVSLl0DFrlVFdQwsy69CyCAvfnTlurxLTKnIaXLvvJO pUYwEJ8XKNtMmLD6CBzwzizOV/T3uVil+thqgNF83YDipBBklJQfrxUhsYe2HiKfZM+Q tUF68J8RonvpfBje99kgE9vgQQOocvM6fxEGBc8qtlrJ0iASewWFVjntJOHHD2QHiw33 JZKg== X-Forwarded-Encrypted: i=1; AFNElJ+nBKtSgeUk9lT7KeWnPNzPNyz1VZot2demWF3D65MB6CfDvfcf1l9ubR3dloUrHwYFSJKVGvgM7ogbUNE=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+2E/vixc+il6INXogtWKawtFpzUrRpBc8unKVlr4KEOk03ZcA vTLLM0uou83gEBNVtCQAxg7kWyfh0+bXGFKSrgoHerVPKRWYwy5YJU1I X-Gm-Gg: Acq92OGVsEvOElZ8EM5u2EXUl0rNgOxF0Fal8z2Z2PgNy5SqD8ITzwkQ2sIHFZ1Vgx4 5TQ8fucSbuX67iNLupLKvbu8bWNUBkHMwJ/2NnKpVSt6pA3tWITRG/1FV79OxpIg+9OMu4CtvZh /8kyv4dOgzvJhqSBqJA46FKcte5eP2G1F0EcX3KqRbwhhEowtzMD1pmRAlPa5upTxU6x+A7CQJU NpvueG/8hS4CEpl2DBFhsJJNxWCwWpDtIiW63j6sY6RN+EQ/37b44C12PoJowtEUMY06A2VShcC MChRL6L+zMxp+ItkuGUfIRHnOymanjWC/60Inz7a6y9a+luMe3O/lGAa1gaQNwyb6P/a5ba3hN/ RmQIuYEcUQsk3d06E/0hLoONXwp3y8OGDmQGMcEwz4XFBvNryw9UIbNRZpXXDJrgdwbrX5HpGlX WZX0EZde/rGRJPmLqfM7AcRqmCfRJ/0QljobdRQmk= X-Received: by 2002:a05:6000:610:b0:45e:742c:f195 with SMTP id ffacd0b85a97d-45eb3690ba8mr10344352f8f.12.1779520526578; Sat, 23 May 2026 00:15:26 -0700 (PDT) Received: from [192.168.0.174] ([31.96.183.250]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-45eb6d5cb76sm8639838f8f.25.2026.05.23.00.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2026 00:15:26 -0700 (PDT) From: Jim Cromie Date: Sat, 23 May 2026 01:14:49 -0600 Subject: [PATCH v2 16/24] dyndbg: replace classmap list with an array-slice 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: <20260523-dd-maint-2-v2-16-b937312aa083@gmail.com> References: <20260523-dd-maint-2-v2-0-b937312aa083@gmail.com> In-Reply-To: <20260523-dd-maint-2-v2-0-b937312aa083@gmail.com> To: Jonathan Corbet , Shuah Khan , Arnd Bergmann , Jason Baron , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Andrew Morton , Shuah Khan Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, Jim Cromie , Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1779520485; l=6627; i=jim.cromie@gmail.com; s=20260203; h=from:subject:message-id; bh=acmpE5f+cy4H0euAd/sWLVbXBhuyRVdVfvkTY1QfTl8=; b=+LlT89h5Zas1rnf6o1vCdzF04GdcJrVVBC0DVNyp/lojUnxHBDsi3KbK2sf4iEP6Z6JU0GAQD gRp8te91A/gDPQKNAolv23w1WGUsRCb95To3FYv6z7PAbLpnCZHB4aQ 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 of the classmap structs. The "select-by-modname" condition is reused to find the start,end of the subrange of classmaps belonging to the module. NOTES: There are multiple modules named "main" but thats an artifact of how KBUILD_MODNAME gets its value, and none of those repeats are contiguous. The legacy code segmenting the builtin descriptors depends upon this, we are "reusing" that dependency. The "filter-by-modname" on classmaps should really be done in ddebug_add_module(1); ie closer to dynamic_debug_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. Signed-off-by: Jim Cromie Reviewed-by: Louis Chauvet --- v2: RvB after SoB --- include/linux/dynamic_debug.h | 1 - lib/dynamic_debug.c | 65 +++++++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index e724f6b93663..0a137a586510 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -73,7 +73,6 @@ enum ddebug_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 d4cce0f4f197..7f03b331d185 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -46,10 +46,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 { @@ -150,12 +151,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; @@ -166,7 +168,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 @@ -228,7 +229,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); @@ -1061,9 +1062,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]; @@ -1147,30 +1149,34 @@ 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++; + } else if (nc) { + /* end of matching classmaps */ + break; } } - 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); + } } /* @@ -1202,10 +1208,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); @@ -1318,8 +1323,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