From nobody Sat Apr 11 13:58:16 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C73A0ECAAD5 for ; Sun, 4 Sep 2022 21:46:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235880AbiIDVqh (ORCPT ); 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-Google-Smtp-Source: AA6agR5Ky+BjL0NnfIX4cYKS1KnsINOXh0NpNlMijj01ekGHcYdvtJWlYQecsvf47LfzeAoLHEZ2MA== 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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 ddeb= ug_table *dt, vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); } =20 +/* + * 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 =3D (struct _ddebug_site_hdr *) ((struct _ddebug_hdr *)hdr)->_uplink; + return hdr =3D=3D (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 =3D 0; =20 v3pr_info("add-module: %s %d/%d sites, start: %d\n", modname, di->num_des= cs, di->num_sites, base); + + if (is_dyndbg_header((struct _ddebug_hdr *)&di->descs[0])) { + pr_info("module header\n"); + di->hdr =3D (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) =20 struct _ddebug_info di =3D { .hdr =3D __dyndbg_header, + .site_hdr =3D __dyndbg_site_header, .descs =3D __start___dyndbg, .sites =3D __start___dyndbg_sites, .classes =3D __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_site= s); 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); =20 + if (is_dyndbg_header(di.hdr)) { + di.hdr->_uplink =3D &builtin_state; + } else { + pr_err("missing header records: cannot continue!\n"); + return 1; + } iter =3D iter_mod_start =3D __start___dyndbg; site =3D site_mod_start =3D __start___dyndbg_sites; modname =3D site->_modname; --=20 2.37.2