Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2442989rwb; Sun, 4 Sep 2022 16:25:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR7pn4LPGXvspNrRnhXGQGTW5TvdKbteh6RmQqb9baxYQQOpw7E3YuSKOdcsHcQgNjkQKUim X-Received: by 2002:a17:907:7f0b:b0:731:b81a:1912 with SMTP id qf11-20020a1709077f0b00b00731b81a1912mr34223828ejc.8.1662333949580; Sun, 04 Sep 2022 16:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662333949; cv=none; d=google.com; s=arc-20160816; b=c2wQl1MteUtm43vIgcMau6mk0lByzkVyvR8EXccp+M+cmmUnPbzl3sLMuvWulewPJ/ 7mQH6iXTEGYE7hc+jukjUOT+vALpWXjl5JFG22F4yIkxi6P1aFVCmjDI6Is5IHuLnRiI aAb5647UZw09zSvAz1nzLcJTHGbmxnRQMlXQBi3K98qscPC/Rh+OIWCGjrObTnO933TV fcV35vHdMk9LWe2vMs3E4BIEgP6lLKtsf6QDQZPdhtaIEHsGyYqdhxADkFzKAhDXHUcL sxVTWRmgPOpw88K2M88gacHkdxK+Nv8S3DjfuDuWIZHUSbC3rsxFont4p6XSI5MyjQq2 tPFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e3ozCdACMZmIXizqK002HFm7hj6BkwsMmmCq1NgZ3+4=; b=Z9AP4tbCR/F1sBx2aX/xvdJGMR/UJmiM8/42KY9SgZ9zIj8SsQDIILPkKntIGtoSRK w5ioFUMapf8vMZvgx6T4OwxybK0sHSsYJafk6pW7VeKn+mG9MVr4oDO01KvK661vhwdq 06UURyHlSSb7YOfEKxFu4Dw3lTUhSt0CDDnjuum3Sy6yYZ8TPp5zC5k+Xj5g2aZRK2y1 aQCJ1EyUSZqMNDLLdZBwk9rn+zX1C4r7gcZajlRshibht6MRBy/lEsIPa6qzbrwtdHNN iYsNOjliQnaWKI6mRKbCQKj5WI7nbrE8Bm9onniMTPfeZ1HrQixffi3OSYw5u3qvXrqQ 0NRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BbbFDk5D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170906854b00b0073dd49f3a7dsi5446825ejy.19.2022.09.04.16.25.24; Sun, 04 Sep 2022 16:25:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BbbFDk5D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235871AbiIDVqh (ORCPT + 99 others); Sun, 4 Sep 2022 17:46:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235709AbiIDVpL (ORCPT ); Sun, 4 Sep 2022 17:45:11 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7E09303EE for ; Sun, 4 Sep 2022 14:43:01 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id s11so3868428ilt.7 for ; Sun, 04 Sep 2022 14:43:01 -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:subject:date; bh=e3ozCdACMZmIXizqK002HFm7hj6BkwsMmmCq1NgZ3+4=; b=BbbFDk5Ds3TKsvXVbegzI7CpK80eT1rLEmQAVhGGmkbjefDTu1gcIWX3uZ+Gm3W16k 3S2yBAZFyR4M8ryCfllvuDfTEF5RipMBjPts8hfi0pV7bgB3wzkcHuY4zKj4khhmKXMX pSl1t58XXxStJLZnSVd/tYgQeSDea1W2Q0b2Yjqp1FxlZFqw6LWpNqFhC6szuGaRu8dl 5KSWJpEvt20IxDYiChjLMX8wBoKwHlILNtfzF8+iMXyfBHmY6aJSuvXzt1gP3PkSoi/Q ObHbdHfGYhfOUrMIzj4dzek2gnNfsuuTirJYodRLuPa4LRKsvPAHjppmK36ztUBZgFy/ TBLA== 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 :subject:date; bh=e3ozCdACMZmIXizqK002HFm7hj6BkwsMmmCq1NgZ3+4=; b=S9KnXZcqnACuZ6So5NKeF0/w0Odl3CYb2eJjRI+hzl4EYdj2jAYvoFY/bHYgTT6DzT 3vOZ56uH3/YIaYjRue7AfJv56/W+En5Zvt549lJ1KqXsPu2YgdXNAm7v2lGq1GA1/bdx mWRh9tyLhfKm+aei1TrqP15/BM+PazEWy6oii6vOKmY1YLx/MFKtTLNGnNyGfs8WnHeH FQR6Vp9Iwob/0M6WTNsupBSuPawfTJz+Yt05A/e5sfQjJOBSKP6wXxHNN5K/6aXiLoEQ +DG3DI1NXQ8F+qSzEYVqbYerlqfhV8ufL/MiEz2/WIP5E4TcQ9fnk9rQBTJHW//VOu+n kpxg== X-Gm-Message-State: ACgBeo1lBiIs/nj6ru9E8zXtgJQpwoto6rBswyA2WExa1+cy89g8m1hX W8uD5IBsCd0qH1YldCD3KyI= X-Received: by 2002:a05:6e02:1524:b0:2ec:71c6:7b85 with SMTP id i4-20020a056e02152400b002ec71c67b85mr9725292ilu.237.1662327781031; Sun, 04 Sep 2022 14:43:01 -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-20020a056602044c00b006889ea7be7bsm3727688iov.29.2022.09.04.14.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:43:00 -0700 (PDT) From: Jim Cromie To: 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-kernel@vger.kernel.org Cc: daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, linux@rasmusvillemoes.dk, joe@perches.com, Jim Cromie Subject: [PATCH v6 53/57] dyndbg: add/use is_dyndbg_header then set _uplink Date: Sun, 4 Sep 2022 15:41:30 -0600 Message-Id: <20220904214134.408619-54-jim.cromie@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220904214134.408619-1-jim.cromie@gmail.com> References: <20220904214134.408619-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add static int is_dyndbg_header(d), which verifies that the arg is initialized as expected; that it points to the _ddebug_hdr & _ddebug_site_hdr records initialized by DYNAMIC_DEBUG_TABLE(). That init macro sets the _uplink fields in the 2 records to point at each other. This is an impossible situation for the regular callsite record pairs built by *_METADATA_CLS(), so it provides a robust verification that linkage happened as we require/depend upon. In dynamic_debug_init(), is_dyndbg_header() validates the header, and sets _uplink to builtin_state. Thereafter, ddebug_map_site() can use it, and we can drop the _ddebug.site member, and shrink the DATA footprint. --- include/linux/dynamic_debug.h | 1 + lib/dynamic_debug.c | 38 +++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 23d3d2882882..ed3e1e1c08eb 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -149,6 +149,7 @@ struct _ddebug_site_hdr { /* encapsulate linker provided built-in (or module) dyndbg vectors */ struct _ddebug_info { struct _ddebug_hdr *hdr; + struct _ddebug_site_hdr *site_hdr; struct _ddebug *descs; struct _ddebug_site *sites; struct ddebug_class_map *classes; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 891d70d7fed4..0a68fbfd8432 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1339,6 +1339,25 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); } +/* + * detect the hardwired loopback initialized into the header pairs' + * _uplink member. In dynamic_debug_init(), it verifies the presence + * of the header, before setting its _uplink to either &builtin_state + * or the module's embedded _ddebug_info. __ddebug_add_module() will + * also use it.. + */ +static int is_dyndbg_header(struct _ddebug_hdr *hdr) +{ + struct _ddebug_site_hdr *sp; + + if (!hdr || !hdr->_uplink) + return 0; + + sp = (struct _ddebug_site_hdr *) ((struct _ddebug_hdr *)hdr)->_uplink; + return hdr == (struct _ddebug_hdr *) + ((struct _ddebug_site_hdr *)sp)->_uplink; +} + /* * Allocate a new ddebug_table for the given module * and add it to the global list. @@ -1351,6 +1370,15 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, int i, num_funcs = 0; v3pr_info("add-module: %s %d/%d sites, start: %d\n", modname, di->num_descs, di->num_sites, base); + + if (is_dyndbg_header((struct _ddebug_hdr *)&di->descs[0])) { + pr_info("module header\n"); + di->hdr = (struct _ddebug_hdr *) di->descs; + di->descs++; + di->sites++; + di->num_descs--; + di->num_sites--; + } if (!di->num_descs) { v3pr_info(" skip %s\n", modname); return 0; @@ -1525,6 +1553,7 @@ static int __init dynamic_debug_init(void) struct _ddebug_info di = { .hdr = __dyndbg_header, + .site_hdr = __dyndbg_site_header, .descs = __start___dyndbg, .sites = __start___dyndbg_sites, .classes = __start___dyndbg_classes, @@ -1548,11 +1577,16 @@ static int __init dynamic_debug_init(void) pr_err("unequal vectors: descs/sites %d/%d\n", di.num_descs, di.num_sites); return 1; } - /* these 2 print the same, until _TABLE is added */ - v2pr_info("%px %px \n", __dyndbg_header, __dyndbg_site_header); + v2pr_info("%px %px \n", di.hdr, __dyndbg_site_header); v2pr_info("%px %px \n", di.descs, di.sites); + if (is_dyndbg_header(di.hdr)) { + di.hdr->_uplink = &builtin_state; + } else { + pr_err("missing header records: cannot continue!\n"); + return 1; + } iter = iter_mod_start = __start___dyndbg; site = site_mod_start = __start___dyndbg_sites; modname = site->_modname; -- 2.37.2