From nobody Sat Apr 11 13:58:17 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 EEFB6C6FA82 for ; Sun, 4 Sep 2022 21:46:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236080AbiIDVqt (ORCPT ); Sun, 4 Sep 2022 17:46:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236058AbiIDVpW (ORCPT ); Sun, 4 Sep 2022 17:45:22 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C06630F4C for ; Sun, 4 Sep 2022 14:43:03 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id d16so3873630ils.8 for ; Sun, 04 Sep 2022 14:43:03 -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=QW8Yf/f/bBn0zBgArR4hEtkqhYHoLP9Dq69jouppMcg=; b=CI4O5/XsaFLXciSt5Rdge4MemsUClxFVBZfystEbNfehM5+pbWGL+3/LfbSrWpLkDe QLouWGHfFHkP9Q9uTLPz7X3ERsbJXjw8LNi6aoavpvlpTPh0dTvh+IgfdUCbYJdj0GgH lUfG76Rd0gmLjbbl/3rZMOmYqTD+WkTN/9K2f2dm2qZHEDNaVZgbBO5+nFxuSbB/CFz4 0MWqrUks5jKXTp61hPvRrQtbY7qo2RxRkVavCrphAIUunhh48rh0GzTzPFGrJ6BKZ0CD yShrbz0hun/rGp39oZ6PrAdWgNTyqGMKHUoak/rTVekwOK81+67c+ffYoQ1p3mVC8bzd oPTw== 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=QW8Yf/f/bBn0zBgArR4hEtkqhYHoLP9Dq69jouppMcg=; b=UKEYYXR83PsD/sLaeIv86Nev4PbhIk/5RfQK266quicJ2zR6vrMV9JaxDU4lCFlzg/ kFCwzs4kf9b4aEe1kX8ADZV1fxAIg7gtmQMk3vY9tqYPvq/KK1riYzo3BmRmNrN5kOUv f32CeNVUsWnDNwXdfHddOQ33USs+qiwamefgHpxwvm7XH2Aj2zZl5+jwtuVr36yZ8s0I nbrzKB3bYhqb+miQ4HC9LM5S063p9YfAsT/N/mJ+2aZoBewtcLEDB9J6WRRcjTRaiIdM jrPBfFcGHsODmiYkiFxQsvED255ZaOqIr3jXeG/+uHak9RT2f9W2FSVd1OxNzNtwoQOW ZlrA== X-Gm-Message-State: ACgBeo0APjm57J1bvPDaCWn4gkM7KubZO3q8CPGVMayYjyFLH+5lOFoG JgtuHge/M+GhhKSFdxU1x5s= X-Google-Smtp-Source: AA6agR7eGPKnIe81RJVDfoPI3jJBBD+OXvseERYIHoYQlkUb2mdyRY/RHX6luTHiUDhiH85tZBOfIg== X-Received: by 2002:a05:6e02:180c:b0:2f1:5405:4bba with SMTP id a12-20020a056e02180c00b002f154054bbamr1923294ilv.152.1662327782986; Sun, 04 Sep 2022 14:43:02 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 14:43:02 -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 , david@redhat.com Subject: [PATCH v6 55/57] dyndbg: dynamic_debug_sites_reclaim() using free_reserved_page() WAG Date: Sun, 4 Sep 2022 15:41:32 -0600 Message-Id: <20220904214134.408619-56-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" STATUS: broken with some over-free, punt and comment out late_initcall Implement dymamic_debug_sites_reclaim(as a late_initcall) to free the tail~47% of the builtin __dyndbg_sites[] vector back to the buddy allocator. Code is copied from mm/init.c:free_initmem(), wo the poisoning. Comments cargo culted wo grokking. v3pr_info: dyndbg: freeing range: ffffea00000c5500-ffffea00000c5700, ffffffff83154668= -ffffffff8315c480 dyndbg: ie range: ffffea00000c5500-ffffea00000c5700, ffffffff83154000= -ffffffff8315c000 dyndbg: freeing page: ffffea00000c5540, ffffffff83155000 dyndbg: freeing page: ffffea00000c5580, ffffffff83156000 dyndbg: freeing page: ffffea00000c55c0, ffffffff83157000 dyndbg: freeing page: ffffea00000c5600, ffffffff83158000 dyndbg: freeing page: ffffea00000c5640, ffffffff83159000 dyndbg: freeing page: ffffea00000c5680, ffffffff8315a000 dyndbg: freeing page: ffffea00000c56c0, ffffffff8315b000 Presuming those are 4k pages, 28kb is reclaimed, which is reasonably consistent with the numbers below; 1532/2761 compresson of 64KiB. I have fixed one edge-case over-free, which gave me a coredump on ```cat control```, there may be (one) other. dyndbg: 2762 prdebugs in 235 modules, 11 KiB in ddebug tables, 86 KiB \ in __dyndbg section, 64 KiB in __dyndbg_sites section CC: david@redhat.com # free_reserved_page() tip Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 0a68fbfd8432..194367bc13fb 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1542,6 +1542,7 @@ static int __init dynamic_debug_init_control(void) fs_initcall(dynamic_debug_init_control); =20 static struct _ddebug_info builtin_state; +static __initdata struct _ddebug_site *last_site; =20 static int __init dynamic_debug_init(void) { @@ -1622,11 +1623,12 @@ static int __init dynamic_debug_init(void) if (ret) goto out_err; =20 + last_site =3D &__start___dyndbg_sites[site_base]; ddebug_init_success =3D 1; =20 - 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)); + vpr_info("%d prdebugs in %d functions, %d modules, %d KiB in ddebug table= s, %d,%d kiB in __dyndbg,_sites sections\n", + i, site_base, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 1= 0), + (int)((i * sizeof(struct _ddebug)) >> 10), (int)((site_base * sizeof(st= ruct _ddebug_site)) >> 10)); =20 if (di.num_classes) v2pr_info(" %d builtin ddebug class-maps\n", di.num_classes); @@ -1652,3 +1654,40 @@ static int __init dynamic_debug_init(void) /* Allow early initialization for boot messages via boot param */ early_initcall(dynamic_debug_init); =20 +static int __init dynamic_debug_sites_reclaim(void) +{ + unsigned long addr, end, start; + /* + * from mm/init.c:free_initmem (void) wo poisoning + * The init section is aligned to 8k in vmlinux.lds. + * Page align for >8k pagesizes. + */ + start =3D (unsigned long)__start___dyndbg_sites; + end =3D (unsigned long)__stop___dyndbg_sites; + addr =3D (unsigned long)last_site; + + vpr_info("full range: %px-%px, %lx-%lx\n", + virt_to_page(start), virt_to_page(end), start, end); + + vpr_info("freeing range: %px-%px, %lx-%lx\n", + virt_to_page(addr), virt_to_page(end), addr, end); + + addr &=3D PAGE_MASK; + addr +=3D PAGE_SIZE; + end &=3D PAGE_MASK; + end +=3D PAGE_SIZE; + + vpr_info("ie range: %px-%px, %lx-%lx\n", + virt_to_page(addr), virt_to_page(end), addr, end); + + if (verbose < 2) { + vpr_info(" skipping reclaim cuz its broken by `cat control`\n"); + return 0; + } + for (; addr < end; addr +=3D PAGE_SIZE) { + vpr_info("freeing page: %px, %lx\n", virt_to_page(addr), addr); + free_reserved_page(virt_to_page(addr)); + } + return 0; +} +//late_initcall(dynamic_debug_sites_reclaim); --=20 2.37.2