From 3996f2220fa4f858546d4b5d8183f8c91e05f5fd Mon Sep 17 00:00:00 2001 From: mrg Date: Sat, 19 Dec 2020 23:38:21 +0000 Subject: [PATCH] ddb: add two new modifiers to "show pool" and "show all pools" - /s shows a short single-line per pool list (the normal output is about 10 lines per.) - /S skips pools with zero allocations. --- share/man/man4/ddb.4 | 15 +++++++++++---- sys/kern/subr_pool.c | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/share/man/man4/ddb.4 b/share/man/man4/ddb.4 index b723eeba5973..ec9bc45d06b7 100644 --- a/share/man/man4/ddb.4 +++ b/share/man/man4/ddb.4 @@ -1,4 +1,4 @@ -.\" $NetBSD: ddb.4,v 1.196 2020/10/31 22:43:01 uwe Exp $ +.\" $NetBSD: ddb.4,v 1.197 2020/12/19 23:38:21 mrg Exp $ .\" .\" Copyright (c) 1997 - 2019 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -56,7 +56,7 @@ .\" any improvements or extensions that they make and grant Carnegie Mellon .\" the rights to redistribute these changes. .\" -.Dd August 23, 2020 +.Dd December 19, 2020 .Dt DDB 4 .Os .Sh NAME @@ -584,7 +584,7 @@ is specified, the complete vnode list is printed. Display basic information about all physical pages managed by the VM system. For more detailed information about a single page, use .Ic show page . -.It Ic show all pools Ns Op Cm /clp +.It Ic show all pools Ns Op Cm /clpsS Display all pool information. Modifiers are the same as .Ic show pool . @@ -721,7 +721,7 @@ If is specified, the complete page is printed. .It Ic show panic Print the current "panic" string. -.It Ic show pool Ns Oo Cm /clp Oc Ar address +.It Ic show pool Ns Oo Cm /clpsS Oc Ar address Print the pool at .Ar address . Valid modifiers: @@ -732,6 +732,13 @@ Print the cachelist and its statistics for this pool. Print the log entries for this pool. .It Cm /p Print the pagelist for this pool. +.It Cm /s +Print a short (one line) list per pool, showing the wait channel, pool +address, allocation size, alignment, allocated pages, allocated items, +consumed items, allocation requests, allocation frees, pages allocated, +pages freed, and currently idle pages, respectively. +.It Cm /S +Skip pools with zero allocations. .El .It Ic show proc Ns Oo Cm /ap Oc Ar address | pid Show information about a process and its LWPs. diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c index 6dfcd35f91a7..258781d18f43 100644 --- a/sys/kern/subr_pool.c +++ b/sys/kern/subr_pool.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr_pool.c,v 1.274 2020/09/05 17:33:11 riastradh Exp $ */ +/* $NetBSD: subr_pool.c,v 1.275 2020/12/19 23:38:21 mrg Exp $ */ /* * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014, 2015, 2018, @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.274 2020/09/05 17:33:11 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.275 2020/12/19 23:38:21 mrg Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1833,28 +1833,47 @@ pool_print1(struct pool *pp, const char *modif, void (*pr)(const char *, ...)) pool_cache_cpu_t *cc; uint64_t cpuhit, cpumiss, pchit, pcmiss; uint32_t nfull; - int i, print_log = 0, print_pagelist = 0, print_cache = 0; + int i; + bool print_log = false, print_pagelist = false, print_cache = false; + bool print_short = false, skip_empty = false; char c; while ((c = *modif++) != '\0') { if (c == 'l') - print_log = 1; + print_log = true; if (c == 'p') - print_pagelist = 1; + print_pagelist = true; if (c == 'c') - print_cache = 1; + print_cache = true; + if (c == 's') + print_short = true; + if (c == 'S') + skip_empty = true; } + if (skip_empty && pp->pr_nget == 0) + return; + if ((pc = pp->pr_cache) != NULL) { - (*pr)("POOL CACHE"); + (*pr)("POOLCACHE"); } else { (*pr)("POOL"); } + /* Single line output. */ + if (print_short) { + (*pr)(" %s:%p:%u:%u:%u:%u:%u:%u:%u:%u:%u:%u\n", + pp->pr_wchan, pp, pp->pr_size, pp->pr_align, pp->pr_npages, + pp->pr_nitems, pp->pr_nout, pp->pr_nget, pp->pr_nput, + pp->pr_npagealloc, pp->pr_npagefree, pp->pr_nidle); + + return; + } + (*pr)(" %s: size %u, align %u, ioff %u, roflags 0x%08x\n", pp->pr_wchan, pp->pr_size, pp->pr_align, pp->pr_itemoffset, pp->pr_roflags); - (*pr)("\talloc %p\n", pp->pr_alloc); + (*pr)("\tpool %p, alloc %p\n", pp, pp->pr_alloc); (*pr)("\tminitems %u, minpages %u, maxpages %u, npages %u\n", pp->pr_minitems, pp->pr_minpages, pp->pr_maxpages, pp->pr_npages); (*pr)("\titemsperpage %u, nitems %u, nout %u, hardlimit %u\n", @@ -1865,7 +1884,7 @@ pool_print1(struct pool *pp, const char *modif, void (*pr)(const char *, ...)) (*pr)("\tnpagealloc %lu, npagefree %lu, hiwat %u, nidle %lu\n", pp->pr_npagealloc, pp->pr_npagefree, pp->pr_hiwat, pp->pr_nidle); - if (print_pagelist == 0) + if (!print_pagelist) goto skip_pagelist; if ((ph = LIST_FIRST(&pp->pr_emptypages)) != NULL) @@ -1884,7 +1903,7 @@ pool_print1(struct pool *pp, const char *modif, void (*pr)(const char *, ...)) (*pr)("\tcurpage %p\n", pp->pr_curpage->ph_page); skip_pagelist: - if (print_log == 0) + if (print_log) goto skip_log; (*pr)("\n");