Module Name:    src
Committed By:   mrg
Date:           Sat Dec 19 23:38:21 UTC 2020

Modified Files:
        src/share/man/man4: ddb.4
        src/sys/kern: subr_pool.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/share/man/man4/ddb.4
cvs rdiff -u -r1.274 -r1.275 src/sys/kern/subr_pool.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man4/ddb.4
diff -u src/share/man/man4/ddb.4:1.196 src/share/man/man4/ddb.4:1.197
--- src/share/man/man4/ddb.4:1.196	Sat Oct 31 22:43:01 2020
+++ src/share/man/man4/ddb.4	Sat Dec 19 23:38:21 2020
@@ -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
 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 f
 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.

Index: src/sys/kern/subr_pool.c
diff -u src/sys/kern/subr_pool.c:1.274 src/sys/kern/subr_pool.c:1.275
--- src/sys/kern/subr_pool.c:1.274	Sat Sep  5 17:33:11 2020
+++ src/sys/kern/subr_pool.c	Sat Dec 19 23:38:21 2020
@@ -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 <sys/cdefs.h>
-__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 
 	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 
 	(*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 
 		(*pr)("\tcurpage %p\n", pp->pr_curpage->ph_page);
 
  skip_pagelist:
-	if (print_log == 0)
+	if (print_log)
 		goto skip_log;
 
 	(*pr)("\n");

Reply via email to