From nobody Mon May 29 22:11:22 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QVV9R0bwfz4XFkn; Mon, 29 May 2023 22:11:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QVV9R00yyz3KR0; Mon, 29 May 2023 22:11:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685398283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uZCe5o5Sn2a3+3DjGmXsfk8TTM0mq3MMGUfLYGojaeQ=; b=PC7iCwZ4YslIqNuHti2TUXkCn9GIsNt4fOuHNVgfZbGvUbKELGhbqx4eIkDXDjwEV6fNtj EnXmiq4o+WgPluznGWgTBkL7kRpX5/QMftW9ofW5dsjtGEl2V2xkZDIx6F2SQ00+3FhGq0 dMYX7DMJeWMdo+707AQ3ACfOSOdHJmtZXOsiXus5D9AuIueZQNWu0VntmDoP0oasKaZRjg t0WaAz9c0HROv8sa8P3D7uGOv4xFDCn6cKUchQnTToAAAJzJp0VGbZhlfzsFXk02TkEBu8 cj9DF1sM21A0yMbxEF6EcUp85LjlUJHCVCYfYA+syA+cQPqtMXoUvA8N/btjvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685398283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uZCe5o5Sn2a3+3DjGmXsfk8TTM0mq3MMGUfLYGojaeQ=; b=QPbi21jzKmEsbxpNsdiGnLt1OXSLd5tTyD7N689kJqGReoLSaheO/wiHL6hy8fCsX0DUaa /SRQrPEkNLNQIN41GnyGnl6OKKwDyyMhOtxdmiA7Fqyo//gGdkaqCqNW9VKDXROlN6rvSE vuos/Mj8totifGYOs9tzggC5iH5yy3SY0Ztcvt1umI0lQpttHgoeGDpQQEBocnhoLgQ4On laT+jkF01WwApu0TYcfoiifEx94QGJnMQ8l5c3gWdaPiaR4YfAskcqzuEkhiJpW5xCJSaM Hs+UEqOm1T527hhcaacVlEO5a8upSqmkF6LYte6dVVMDYSBnoQE4StZSub8hEA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685398283; a=rsa-sha256; cv=none; b=k3BLhv/pK4w2OK+6brrDjBeZJ+hECqXMBT9tfBHYyWCkFd5k7/Ezh5v3eLTGqzWCguRpKu eP5Ucpca4I3qqD0c4OjADUQOEKWALiYllPqBpiFhTFy5X9E0smZbcV2nCuIkeruNC1iMgF xEwCOvV7sVwqFhd3lfUomO4sANWa+XKgfLap2MOT/aHGpbzBe04B6wYloHg559O4vIvqak oq42yyDO4hlW3Ih2hjLKN/w7Jy8Oj5U4w8Cp2t8ICXTnaD0onQldeDSh5V2JludCMZKnNY kDmY1u4CEqSLcg7SWcbaLCMSjzMZWuTJ0JX5oh5PBdUcC1GESNpUGSeazHHOIA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QVV9Q5qFZzTNP; Mon, 29 May 2023 22:11:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34TMBMJi044754; Mon, 29 May 2023 22:11:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34TMBMUx044753; Mon, 29 May 2023 22:11:22 GMT (envelope-from git) Date: Mon, 29 May 2023 22:11:22 GMT Message-Id: <202305292211.34TMBMUx044753@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: f386b27736fe - main - unr(9): add 'show unrhdr' ddb command List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f386b27736fe6dee535a530d5c7610d8a9827758 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f386b27736fe6dee535a530d5c7610d8a9827758 commit f386b27736fe6dee535a530d5c7610d8a9827758 Author: Konstantin Belousov AuthorDate: 2023-05-25 11:14:19 +0000 Commit: Konstantin Belousov CommitDate: 2023-05-29 22:10:36 +0000 unr(9): add 'show unrhdr' ddb command Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D40089 --- sys/kern/subr_unit.c | 59 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/sys/kern/subr_unit.c b/sys/kern/subr_unit.c index b0977c3c01b9..0b8be66a8c4d 100644 --- a/sys/kern/subr_unit.c +++ b/sys/kern/subr_unit.c @@ -926,15 +926,18 @@ free_unr(struct unrhdr *uh, u_int item) Free(p2); } -#ifndef _KERNEL /* USERLAND test driver */ +#ifdef _KERNEL +#include "opt_ddb.h" +#ifdef DDB +#include +#endif +#endif -/* - * Simple stochastic test driver for the above functions. The code resides - * here so that it can access static functions and structures. - */ +#if (defined(_KERNEL) && defined(DDB)) || !defined(_KERNEL) -static bool verbose; -#define VPRINTF(...) {if (verbose) printf(__VA_ARGS__);} +#if !defined(_KERNEL) +#define db_printf printf +#endif static void print_unr(struct unrhdr *uh, struct unr *up) @@ -942,21 +945,21 @@ print_unr(struct unrhdr *uh, struct unr *up) u_int x; struct unrb *ub; - printf(" %p len = %5u ", up, up->len); + db_printf(" %p len = %5u ", up, up->len); if (up->ptr == NULL) - printf("free\n"); + db_printf("free\n"); else if (up->ptr == uh) - printf("alloc\n"); + db_printf("alloc\n"); else { ub = up->ptr; - printf("bitmap ["); + db_printf("bitmap ["); for (x = 0; x < up->len; x++) { if (bit_test(ub->map, x)) - printf("#"); + db_printf("#"); else - printf(" "); + db_printf(" "); } - printf("]\n"); + db_printf("]\n"); } } @@ -966,12 +969,12 @@ print_unrhdr(struct unrhdr *uh) struct unr *up; u_int x; - printf( + db_printf( "%p low = %u high = %u first = %u last = %u busy %u chunks = %u\n", uh, uh->low, uh->high, uh->first, uh->last, uh->busy, uh->alloc); x = uh->low + uh->first; TAILQ_FOREACH(up, &uh->head, list) { - printf(" from = %5u", x); + db_printf(" from = %5u", x); print_unr(uh, up); if (up->ptr == NULL || up->ptr == uh) x += up->len; @@ -980,6 +983,30 @@ print_unrhdr(struct unrhdr *uh) } } +#endif + +#if defined(_KERNEL) && defined(DDB) +DB_SHOW_COMMAND(unrhdr, unrhdr_print_unrhdr) +{ + if (!have_addr) { + db_printf("show unrhdr addr\n"); + return; + } + + print_unrhdr((struct unrhdr *)addr); +} +#endif + +#ifndef _KERNEL /* USERLAND test driver */ + +/* + * Simple stochastic test driver for the above functions. The code resides + * here so that it can access static functions and structures. + */ + +static bool verbose; +#define VPRINTF(...) {if (verbose) printf(__VA_ARGS__);} + static void test_alloc_unr(struct unrhdr *uh, u_int i, char a[]) {