Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add kern.pool for memory pool stats.
details: https://anonhg.NetBSD.org/src/rev/208b22210d84
branches: trunk
changeset: 329912:208b22210d84
user: joerg <joerg%NetBSD.org@localhost>
date: Fri Jun 13 19:09:07 2014 +0000
description:
Add kern.pool for memory pool stats.
diffstat:
share/man/man7/sysctl.7 | 11 ++++-
sys/kern/subr_pool.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++-
sys/sys/pool.h | 35 +++++++++++++++-
3 files changed, 144 insertions(+), 6 deletions(-)
diffs (218 lines):
diff -r f542c1e3c18d -r 208b22210d84 share/man/man7/sysctl.7
--- a/share/man/man7/sysctl.7 Fri Jun 13 18:49:41 2014 +0000
+++ b/share/man/man7/sysctl.7 Fri Jun 13 19:09:07 2014 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: sysctl.7,v 1.81 2014/05/30 01:43:20 christos Exp $
+.\" $NetBSD: sysctl.7,v 1.82 2014/06/13 19:09:07 joerg Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
.\"
-.Dd May 29, 2014
+.Dd June 13, 2014
.Dt SYSCTL 7
.Os
.Sh NAME
@@ -329,6 +329,7 @@
.It kern.ostype string no
.\".It kern.panic_now integer yes
.It kern.pipe node not applicable
+.It kern.pool struct pool_sysctl no
.\" .It kern.posix node not applicable
.It kern.posix1version integer no
.It kern.posix_aio integer no
@@ -849,6 +850,12 @@
.Dq big
pipes.
.El
+.It Li kern.pool
+Provides statistics about the
+.Xr pool 9
+and
+.Xr pool_cache 9
+subsystems.
.\" XXX: Undocumented .It Li kern.posix ( ? )
.\" This is a node in which the only variable is semmax.
.It Li kern.posix1version ( KERN_POSIX1 )
diff -r f542c1e3c18d -r 208b22210d84 sys/kern/subr_pool.c
--- a/sys/kern/subr_pool.c Fri Jun 13 18:49:41 2014 +0000
+++ b/sys/kern/subr_pool.c Fri Jun 13 19:09:07 2014 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: subr_pool.c,v 1.202 2014/04/26 16:30:05 abs Exp $ */
+/* $NetBSD: subr_pool.c,v 1.203 2014/06/13 19:09:07 joerg Exp $ */
/*-
- * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010
+ * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014
* The NetBSD Foundation, Inc.
* All rights reserved.
*
@@ -32,13 +32,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.202 2014/04/26 16:30:05 abs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.203 2014/06/13 19:09:07 joerg Exp $");
#include "opt_ddb.h"
#include "opt_lockdebug.h"
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/sysctl.h>
#include <sys/bitops.h>
#include <sys/proc.h>
#include <sys/errno.h>
@@ -2751,3 +2752,100 @@
}
}
#endif /* defined(DDB) */
+
+static int
+pool_sysctl(SYSCTLFN_ARGS)
+{
+ struct pool_sysctl data;
+ struct pool *pp;
+ struct pool_cache *pc;
+ pool_cache_cpu_t *cc;
+ int error;
+ size_t i, written;
+
+ if (oldp == NULL) {
+ *oldlenp = 0;
+ TAILQ_FOREACH(pp, &pool_head, pr_poollist)
+ *oldlenp += sizeof(data);
+ return 0;
+ }
+
+ memset(&data, 0, sizeof(data));
+ error = 0;
+ written = 0;
+ TAILQ_FOREACH(pp, &pool_head, pr_poollist) {
+ if (written + sizeof(data) > *oldlenp)
+ break;
+ strlcpy(data.pr_wchan, pp->pr_wchan, sizeof(data.pr_wchan));
+ data.pr_pagesize = pp->pr_alloc->pa_pagesz;
+ data.pr_flags = pp->pr_roflags | pp->pr_flags;
+#define COPY(field) data.field = pp->field
+ COPY(pr_size);
+
+ COPY(pr_itemsperpage);
+ COPY(pr_nitems);
+ COPY(pr_nout);
+ COPY(pr_hardlimit);
+ COPY(pr_npages);
+ COPY(pr_minpages);
+ COPY(pr_maxpages);
+
+ COPY(pr_nget);
+ COPY(pr_nfail);
+ COPY(pr_nput);
+ COPY(pr_npagealloc);
+ COPY(pr_npagefree);
+ COPY(pr_hiwat);
+ COPY(pr_nidle);
+#undef COPY
+
+ data.pr_cache_nmiss_pcpu = 0;
+ data.pr_cache_nhit_pcpu = 0;
+ if (pp->pr_cache) {
+ pc = pp->pr_cache;
+ data.pr_cache_meta_size = pc->pc_pcgsize;
+ data.pr_cache_nfull = pc->pc_nfull;
+ data.pr_cache_npartial = pc->pc_npart;
+ data.pr_cache_nempty = pc->pc_nempty;
+ data.pr_cache_ncontended = pc->pc_contended;
+ data.pr_cache_nmiss_global = pc->pc_misses;
+ data.pr_cache_nhit_global = pc->pc_hits;
+ for (i = 0; i < pc->pc_ncpu; ++i) {
+ cc = pc->pc_cpus[i];
+ if (cc == NULL)
+ continue;
+ data.pr_cache_nmiss_pcpu = cc->cc_misses;
+ data.pr_cache_nhit_pcpu = cc->cc_hits;
+ }
+ } else {
+ data.pr_cache_meta_size = 0;
+ data.pr_cache_nfull = 0;
+ data.pr_cache_npartial = 0;
+ data.pr_cache_nempty = 0;
+ data.pr_cache_ncontended = 0;
+ data.pr_cache_nmiss_global = 0;
+ data.pr_cache_nhit_global = 0;
+ }
+
+ error = sysctl_copyout(l, &data, oldp, sizeof(data));
+ if (error)
+ break;
+ written += sizeof(data);
+ oldp = (char *)oldp + sizeof(data);
+ }
+
+ *oldlenp = written;
+ return error;
+}
+
+SYSCTL_SETUP(sysctl_pool_setup, "sysctl kern.pool setup")
+{
+ const struct sysctlnode *rnode = NULL;
+
+ sysctl_createv(clog, 0, NULL, &rnode,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_STRUCT, "pool",
+ SYSCTL_DESCR("Get pool statistics"),
+ pool_sysctl, 0, NULL, 0,
+ CTL_KERN, CTL_CREATE, CTL_EOL);
+}
diff -r f542c1e3c18d -r 208b22210d84 sys/sys/pool.h
--- a/sys/sys/pool.h Fri Jun 13 18:49:41 2014 +0000
+++ b/sys/sys/pool.h Fri Jun 13 19:09:07 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pool.h,v 1.75 2012/06/05 22:51:47 jym Exp $ */
+/* $NetBSD: pool.h,v 1.76 2014/06/13 19:09:07 joerg Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2000, 2007 The NetBSD Foundation, Inc.
@@ -32,6 +32,39 @@
#ifndef _SYS_POOL_H_
#define _SYS_POOL_H_
+#include <sys/stdint.h>
+
+struct pool_sysctl {
+ char pr_wchan[16];
+ uint64_t pr_flags;
+ uint64_t pr_size;
+ uint64_t pr_pagesize;
+ uint64_t pr_itemsperpage;
+ uint64_t pr_nitems;
+ uint64_t pr_nout;
+ uint64_t pr_hardlimit;
+ uint64_t pr_npages;
+ uint64_t pr_minpages;
+ uint64_t pr_maxpages;
+
+ uint64_t pr_nget;
+ uint64_t pr_nfail;
+ uint64_t pr_nput;
+ uint64_t pr_npagealloc;
+ uint64_t pr_npagefree;
+ uint64_t pr_hiwat;
+ uint64_t pr_nidle;
+
+ uint64_t pr_cache_meta_size;
+ uint64_t pr_cache_nfull;
+ uint64_t pr_cache_npartial;
+ uint64_t pr_cache_nempty;
+ uint64_t pr_cache_ncontended;
+ uint64_t pr_cache_nmiss_global;
+ uint64_t pr_cache_nhit_global;
+ uint64_t pr_cache_nmiss_pcpu;
+ uint64_t pr_cache_nhit_pcpu;
+};
#ifdef _KERNEL
#define __POOL_EXPOSE
Home |
Main Index |
Thread Index |
Old Index