From patchwork Fri Aug 5 21:53:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12937877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 973F3C00140 for ; Fri, 5 Aug 2022 22:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pifWGTPYWyKdbexmjZODYhDZHlNBHa/ftNjYo+lAukw=; b=iYJRMNGySCzKnq za4YBXuJpVfZRPKmkT8oRQ5FogxHICbf+CwN2X253DOiwJTofbeRQO3FnDO1bc88konCMsAWViF5N QQGRCktI+eDvsnOkeXXBGwPEmtsP+M+cgXy3x9gJPtxI6jTcHsbG06JA20yC74G6+LadmTbtRRLHX gapbQeSaOGO0cU15KEZ4dlHyJY9BjVrMGP8TQV5oKjMO1Xn8l9l4J7MvUc2rSy7Pk1X6uDB8y+2GC pqCpISKZ5My8dXP11XewsCd1gcdh0n/+hc5XDtnamlmWsbHf5wHINjeo9ljuFvYrXR/WnJPYuGTnX YjCSrEMxXsXFnN7ZS+jw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oK649-001Nox-7X; Fri, 05 Aug 2022 22:45:15 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oK632-001N5d-RZ for linux-arm-kernel@bombadil.infradead.org; Fri, 05 Aug 2022 22:44:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=03YfOG/DYkz2iArGNb3db5n/xIxeb8G0N8JzLa+YgtM=; b=iTIp7k4Z6TtGSHQR4mYqWOfwpe 51MurQf2FxEzfilkFqw0lwEbAMohS6fnXi97QQaChCNFt3Epz41S3gWT8dMirlKfIfG9d4rlAh5Uh otRKVN0IOrcmTxCvdsXWPPn5k/QsgRGNTdqgEmGmrT9CiuynnDSClUrDZ5vbpxZZ3Cj6Trf2sWuJA t9gn6eg/SXOMK3VExYJR/98DDCLmp+vfNMMoNBZvAobPqJlnaDaUCxvslWdoonVdJ2O2gj1N1SZdl F0wfAqC1Nx0mJh3xFQXiAQSSD7JL7rmJaPPnE5O5XNj82zVkn8bI3hYVp/jzi2pDOenQjST5dAkXn qFQOSVAA==; Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oK5HR-003LQL-FB for linux-arm-kernel@lists.infradead.org; Fri, 05 Aug 2022 21:54:57 +0000 Received: by mail-io1-xd2b.google.com with SMTP id p82so2864971iod.2 for ; Fri, 05 Aug 2022 14:54:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=03YfOG/DYkz2iArGNb3db5n/xIxeb8G0N8JzLa+YgtM=; b=Ef8WxDG6NyTqC1EZi34gpAEnT+rPZyUcpKaupYnsastTiTGt/Zml/WC2ZzmjZbPHJd phHYyJnYLo6WNB7AlpKLXeN7qbGd1YhUzPvz54QZqQHrtKcLgdsPeyn5+iu9TjI7SjCc Qt/6C50I1yy1ZjGFAU+VCo8OEqIPU+1me4r5nevY5orszEf7tJIjZit7XmergLU/BhIS ORDvsxyCYrTMPQgMLi5PvpsAC4TmoxZwKTf11WtCzm1JE0tcK5kecwMswiOh5HEtMNgs rPlk4sTnLuYzZlm/RO3Nt/CpOY5B3amJFFyJpZOUJOsMWYTIJo5Bn0xeyqAHZ46Benmm PB+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=03YfOG/DYkz2iArGNb3db5n/xIxeb8G0N8JzLa+YgtM=; b=m55Q5wT0hV9oOSaqOut4tpJuGMzo8GKK9JKE+5DqgwE3yO/byAWOQKfTcqKBdHt1px A+NNRMZuvOOjfKaYRWFDst37ei+HsfaeKkh5LBqD31Y8YlJEwyfg5TTWhd3nLZ43xL+c mIN5mFeDwaEttVN/RJa78OQoJFMSIqaEauQDCTIkQEwuOW2oRTM7aH/cMOkTlPwv2zYR 23l3IafwXSJEd5pg1UdU/I53NmCJKJohk4DRCb0dO5SgoNnijgFmIrt0KHlLqp8Lnay8 Vu3XwnLnxC/zpjNq60aGObHTDnXE419BxChzUeEYoj8+w39MOPIfBisIlpRjAZ2/eN4p 34Og== X-Gm-Message-State: ACgBeo0DwFEGUZeqXtQeF1iCsxAJ2DrLaf0Z8gAXHopKBzeuXrcWj7am 8qiskTk+/35k/cynYv7LdFs= X-Google-Smtp-Source: AA6agR55/RU9MHoTbUutY3ptQmA/V1qzWroUOdNy6Xs+Ay1Qupqmyek5BzBPcr17ZMFLvPmsNZWM3A== X-Received: by 2002:a05:6638:d86:b0:341:4ece:3c4 with SMTP id l6-20020a0566380d8600b003414ece03c4mr3708242jaj.235.1659736477900; Fri, 05 Aug 2022 14:54:37 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id e12-20020a056602044c00b0067c09fd0b53sm1765532iov.21.2022.08.05.14.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 14:54:37 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, Jim Cromie Subject: [PATCH v5 16/33] dyndbg: add ddebug_attach_module_classes Date: Fri, 5 Aug 2022 15:53:38 -0600 Message-Id: <20220805215355.3509287-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220805215355.3509287-1-jim.cromie@gmail.com> References: <20220805215355.3509287-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220805_225455_633332_9D68283E X-CRM114-Status: GOOD ( 17.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add ddebug_attach_module_classes(), call it from ddebug_add_module(). It scans the classes/section its given, finds records where the module-name matches the module being added, and adds them to the module's maps list. No locking here, since the record isn't yet linked into the ddebug_tables list. It is called indirectly from 2 sources: - from load_module(), where it scans the module's __dyndbg_classes section, which contains DYNAMIC_DEBUG_CLASSES definitions from just the module. - from dynamic_debug_init(), where all DYNAMIC_DEBUG_CLASSES definitions of each builtin module have been packed together. This is why ddebug_attach_module_classes() checks module-name. NOTES Its (highly) likely that builtin classes will be ordered by module name (just like prdbg descriptors are in the __dyndbg section). So the list can be replaced by a vector (ptr + length), which will work for loaded modules too. This would imitate whats currently done for the _ddebug descriptors. That said, converting to vector,len is close to pointless; a small minority of modules will ever define a class-map, and almost all of them will have only 1 or 2 class-maps, so theres only a couple dozen pointers to save. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 0d6cb6b258bd..a3ace5866f1b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -45,7 +45,7 @@ extern struct ddebug_class_map __start___dyndbg_classes[]; extern struct ddebug_class_map __stop___dyndbg_classes[]; struct ddebug_table { - struct list_head link; + struct list_head link, maps; const char *mod_name; unsigned int num_ddebugs; struct _ddebug *ddebugs; @@ -921,6 +921,32 @@ 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) +{ + struct ddebug_class_map *cm; + int i, j, ct = 0; + + for (cm = classes, i = 0; i < 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 (ct) + vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); +} + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -953,6 +979,12 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, INIT_LIST_HEAD(&dt->link); + INIT_LIST_HEAD(&dt->link); + INIT_LIST_HEAD(&dt->maps); + + if (classes && num_classes) + ddebug_attach_module_classes(dt, classes, num_classes); + mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock);