From nobody Mon Jun 05 08:36:06 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 4QZRlV2wrNz4bLqD; Mon, 5 Jun 2023 08:36:06 +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 4QZRlV2VFRz3wxC; Mon, 5 Jun 2023 08:36:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685954166; 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=NR198L/rMjSiRPbNaPNJF1d6cE+DVWBVBGlrI2Q9IJA=; b=gdCfBq/8l6rERqCubMnAF363nRhHkVUZa+w9ZKld2AeR9/yUqWPVA/AavxDlhHwYImUqN4 yOjqEPfAKSisn45yKjNm2tWRf9VZ1X2gTIm0ukksQLf0WHK8jcJaQVNdHd3wL5BJVIWSjN UkDybyZFyDYJfM28q6SeTzByIvfhmMl/+XTgWfHiY8Yy2y5xu7bnrwKWFBql99fc0/klZM THFIvf0dS/aRurkBr8ee5xE+EqX/Zuniev9Hj3wQilZ7vdJNLVFQkjGg9dVnq+Vo7o7Kdg qEOawAa/rsfDN1mw/pAZz8AVH0fSZL21SjRVlVbaCdreahZvbllOOVlcvGDF/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685954166; 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=NR198L/rMjSiRPbNaPNJF1d6cE+DVWBVBGlrI2Q9IJA=; b=qHmt9f7WPgdnrMz/5yzabr9HMzIW7ZE7og/kEtVrPm1mSKgWzwUF787XOPYGgQitQBGX/3 +tKibuQJbuZ9TgszCp5TnOP7Q1595p8ePPfbktKdGZ2WWkooOVGb5WplanSF2KKeVB5Eq/ 91MXbntKhPCsyIhzdZ1RR7GRABc5TvXTgSmrhaekur/ktaH7TfHkAdVULZqcXmWA9jRJSx PlT6ZJlsspl+96LQVRVMApFJKE3dp4GTriywiUUGKnYHGf9GKka2Iy3pcGckpMOIRaoGiH sTL+/IbC6jn0GyYg1BheQXLJqU7zAZTmtMaPkrqYYj5vndRvjftBhSDXvsiMuw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685954166; a=rsa-sha256; cv=none; b=MaRYGeguunlf8tZdPE4Pi22yV+7Rtbfu1eftaeAAU0PAZYGIu2J9Bm4bKJHuZbxSKZ6W3d X3GU9wlGLba9Zvi554tOV7VkWljR64qnCXFN/+wBU2IlXsYZ6fvfNoxRABPkRwQ+YAC+Gt gte0BxA8mnOsxui/QvbYUGECyJwHFpFWTofZkcuDL+HVj7IpPJYt5e+YIRirdNSRAxJwBR 8ptdKK1yY9bci2gCpKNOZ/ia6/f9DQKGjC8sQJkcFct18gSckzXwiTrN5RDS9WTPjFuzye upyY9MIzL4nsRKSfoLONk/lCnlnmOfVT+8a92vf8frko1joClK41KsnORkaKuw== 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 4QZRlV1Mcszh0x; Mon, 5 Jun 2023 08:36:06 +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 3558a6AL024430; Mon, 5 Jun 2023 08:36:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3558a64s024429; Mon, 5 Jun 2023 08:36:06 GMT (envelope-from git) Date: Mon, 5 Jun 2023 08:36:06 GMT Message-Id: <202306050836.3558a64s024429@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 694714adcd19 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 694714adcd19b7463b2fe697f2d8301a13a25729 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=694714adcd19b7463b2fe697f2d8301a13a25729 commit 694714adcd19b7463b2fe697f2d8301a13a25729 Author: Konstantin Belousov AuthorDate: 2023-05-25 11:14:19 +0000 Commit: Konstantin Belousov CommitDate: 2023-06-05 08:35:01 +0000 unr(9): add 'show unrhdr' ddb command (cherry picked from commit f386b27736fe6dee535a530d5c7610d8a9827758) --- 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 a78b6ddf4840..0f4d25257553 100644 --- a/sys/kern/subr_unit.c +++ b/sys/kern/subr_unit.c @@ -939,15 +939,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) @@ -955,21 +958,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"); } } @@ -979,12 +982,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; @@ -993,6 +996,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[]) {