Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2429556rwb; Sun, 4 Sep 2022 16:05:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR4DujXb3/5uct1lc5M4fxwm1FsxH3zvxVUUIf3PkXgw2+iHHbA9eKbn8SactVGAdj21Cdtl X-Received: by 2002:a17:907:7f24:b0:731:535e:b709 with SMTP id qf36-20020a1709077f2400b00731535eb709mr33946001ejc.160.1662332742369; Sun, 04 Sep 2022 16:05:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662332742; cv=none; d=google.com; s=arc-20160816; b=GltMUXRwrdP7j5gMvK6m/QjvJ8Vo8n/PbdO8s/KBotwAYBgcpjIAxYVUE4HJAtGszo E3MurRPKwsbB4Z+3+0rJiS6bMmm6NhxeuP4o6JmwsfWFMRPPVqkbMrl4G688cknIE4vH gxPb3qoswwhGeA+XJcw3kTsRO1p8c1o6AGMIh4Beoha/l2q0sQVZMeu3RyjfLCvVsh5+ iVdN6sdQDywzbEopic6sgCGoST78TadWeHUZYp6+u44omHmWpaPWj8J9MuZRB1eSWg+R x5YPP4tSAxgpVvi+ZPGjfMLS1iay0mEeWw5bN6rLNggLgG3Yi4OtDMmDk8sqQMQeXB+N MzBA== 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=Bp0ePs8qbV0UvEjRZpFwk6Hm/6e1kM/XXrwCCotNRwY=; b=XdO75VMOz6w222dDhY6GY7h50AvbSvGifokNgAnLdGh7pt3iEgdeASdPWgsDnvG03R ijA29mXh9uSqMSpK2MoJE5/hEBiKQ+oWQxCf8+46/eyYwmfpsADJh9jAKZpVz37rPMZX nqBNGG4QHnmvfp4CZ1kPOWwQ9eORp6CrixH3GLkrvMj2Y8t7inMeukjSU+S8BE/2pGry CVCU6fpx9Ui85Lfl0g+r5Ntlmvr72rQvAB84R6I97gtpI/EoyKXDc6Ej7RqanyMmWUqG vk9RoFxrRqOEpBiMdBPpRE0yujTjcHo0ACx5OtgGgqmtgATBkkLubRHrfDZ0gQJWCADH iW4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XI+lDDMQ; 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 g4-20020a056402180400b00447cc666243si6151662edy.164.2022.09.04.16.05.17; Sun, 04 Sep 2022 16:05:42 -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=XI+lDDMQ; 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 S236160AbiIDVp6 (ORCPT + 99 others); Sun, 4 Sep 2022 17:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235920AbiIDVoY (ORCPT ); Sun, 4 Sep 2022 17:44:24 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17E1C30558 for ; Sun, 4 Sep 2022 14:42:52 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id e7so3873365ilc.5 for ; Sun, 04 Sep 2022 14:42:52 -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=Bp0ePs8qbV0UvEjRZpFwk6Hm/6e1kM/XXrwCCotNRwY=; b=XI+lDDMQn1sJTAtsYXCSCZllHbtd6NOelDveTu16Um2gjNpYLeMWEPdHoroi+WJR56 k3PgFGFfbCQMOWVL4snzUZdVG+0cVnNUbfzxIKDLpC2iJQFgtJDx0CvxlhMkm+BuNHYM JOpIUa7zmX68L2U/aSqdB7PBn6ttAlQuheS/8IeqXuRiGsnhj+Lnu52QEV+kNwnXaeJD afRgsXfC7uf0JeApZ0fm2iin8GGl0CcHiwA1rJtoEcVABdqcneG5T6RL110N966WpM0o k1FblDutKG52QhJ9j7imv5ETtSUwiKKH84KtJRukZEMY244luC3ugPo7akWliqMbT+Gf LhEw== 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=Bp0ePs8qbV0UvEjRZpFwk6Hm/6e1kM/XXrwCCotNRwY=; b=8QHK+ndyCc3ULphn7X+8yAfVmN/K8VHNeIKnKblt+9QGohCuUTqmIc0vAq71c+myWs CDHAR2vf3GlyK/GUGy4W/TE5etOlul3190KKv/gewOHsTT2TEgcc9AsD2TWd/xABQBi7 2PkKBXwKYMe9Im0yyZwb3fW1yi//LYuH3db/aO+rzlt0DP8NImumKqxyNBSCCZgqegnu cpvcAlKVTcAktF+XMhJCjYZ7gS+gx1Wn3nn+WteGl6Sn9nXNpffm1EIvdKrWyq/QEtrb 6Ie1EkWa98NjugP/8l4wBGhBgFvQFK9lGKNLcuOkvIO+RSVo40ccmK1PgP7ncivfw2Kr zChg== X-Gm-Message-State: ACgBeo0TeBlVKXdvMtNvKAkwRyT4tbhz0CNXKY8o28Kiz4sLKYZZtSzC 7/j1Gjg7/T18hDiwc3WdcJg= X-Received: by 2002:a92:dcc2:0:b0:2e4:38f2:a9f6 with SMTP id b2-20020a92dcc2000000b002e438f2a9f6mr24500432ilr.130.1662327772508; Sun, 04 Sep 2022 14:42:52 -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.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:42:52 -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 44/57] dyndbg: extend __ddebug_add_module proto to allow packing sites Date: Sun, 4 Sep 2022 15:41:21 -0600 Message-Id: <20220904214134.408619-45-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 In order to actually reclaim useful blocks of memory, we need to repack the vector of redundant site recs, not just detect the duplicates. To allow this, extend __ddebug_add_module()s prototype by adding: struct _ddebug_site *packed_sites - address of empty "stack" unsigned int *packed_base - index of Top-of-Stack This allows dynamic_debug_init() to tell __ddebug_add_module() where to push the unique site recs it finds while de-duplicating, and to communicate the new TOS back for the next iteration. Since we know we are shrinking data, we can overwrite _ddebug_sites[], for both builtins, and loadable modules, via ddebug_add_module(). For ddebug_add_module(), which is called from kernel/module/main, the 2 args: reuse the module.sites vector, with a 0 offset. This will allow de-duplication of the local vector. No de-duplication is done yet, so no use of the stack. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 506a7e2e59d6..1b57e43e9c31 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1341,7 +1341,8 @@ static void ddebug_attach_module_classes(struct ddebug_table *dt, * and add it to the global list. */ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, - const char *modname) + const char *modname, struct _ddebug_site *packed_sites, + unsigned int *packed_base) { struct ddebug_table *dt; int i; @@ -1390,7 +1391,8 @@ static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, int ddebug_add_module(struct _ddebug_info *di, const char *modname) { - return __ddebug_add_module(di, 0, modname); + unsigned int packed_base = 0; + return __ddebug_add_module(di, 0, modname, di->sites, &packed_base); } /* helper for ddebug_dyndbg_(boot|module)_param_cb */ @@ -1506,7 +1508,7 @@ static int __init dynamic_debug_init(void) { struct _ddebug *iter, *iter_mod_start; struct _ddebug_site *site, *site_mod_start; - int ret, i, mod_sites, mod_ct; + int ret, i, mod_sites, mod_ct, site_base; const char *modname; char *cmdline; @@ -1550,7 +1552,8 @@ static int __init dynamic_debug_init(void) di.num_descs = mod_sites; di.descs = iter_mod_start; di.sites = site_mod_start; - ret = __ddebug_add_module(&di, i - mod_sites, modname); + ret = __ddebug_add_module(&di, i - mod_sites, modname, + __start___dyndbg_sites, &site_base); if (ret) goto out_err; @@ -1563,11 +1566,13 @@ static int __init dynamic_debug_init(void) di.num_descs = mod_sites; di.descs = iter_mod_start; di.sites = site_mod_start; - ret = __ddebug_add_module(&di, i - mod_sites, modname); + ret = __ddebug_add_module(&di, i - mod_sites, modname, + __start___dyndbg_sites, &site_base); if (ret) goto out_err; ddebug_init_success = 1; + vpr_info("%d prdebugs in %d modules, %d KiB in ddebug tables, %d kiB in __dyndbg section\n", i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), (int)((i * sizeof(struct _ddebug)) >> 10)); -- 2.37.2