summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2011-09-19 14:48:05 +0000
committerBob Beck <beck@cvs.openbsd.org>2011-09-19 14:48:05 +0000
commit371d1886fcd07af378f7149e9b287f39750f4fa3 (patch)
treead5a8aa6aee6d961ae8c2d01e2e7d275810fc958 /sys/kern
parente5866955255cba4325c7e748748da94671665e74 (diff)
clean up buffer cache statistics somewhat to
remove some now useless statistics, and add some relevant ones regarding kva usage in the cache. make systat io and show bcstats in ddb both show these counters. ok deraadt@ krw@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_bio.c18
-rw-r--r--sys/kern/vfs_biomem.c16
2 files changed, 22 insertions, 12 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index c8b9353a62e..1b589974153 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_bio.c,v 1.133 2011/07/06 20:50:05 beck Exp $ */
+/* $OpenBSD: vfs_bio.c,v 1.134 2011/09/19 14:48:04 beck Exp $ */
/* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */
/*
@@ -143,9 +143,9 @@ bremfree(struct buf *bp)
bcstats.numcleanpages -= atop(bp->b_bufsize);
} else {
bcstats.numdirtypages -= atop(bp->b_bufsize);
+ bcstats.delwribufs--;
}
TAILQ_REMOVE(dp, bp, b_freelist);
- bcstats.freebufs--;
}
void
@@ -818,6 +818,7 @@ brelse(struct buf *bp)
bufq = &bufqueues[BQ_CLEAN];
} else {
bcstats.numdirtypages += atop(bp->b_bufsize);
+ bcstats.delwribufs++;
bufq = &bufqueues[BQ_DIRTY];
}
if (ISSET(bp->b_flags, B_AGE)) {
@@ -830,7 +831,6 @@ brelse(struct buf *bp)
}
/* Unlock the buffer. */
- bcstats.freebufs++;
CLR(bp->b_flags, (B_AGE | B_ASYNC | B_NOCACHE | B_DEFERRED));
buf_release(bp);
@@ -1118,8 +1118,8 @@ buf_daemon(struct proc *p)
SET(bp->b_flags, B_DEFERRED);
s = splbio();
bcstats.numdirtypages += atop(bp->b_bufsize);
+ bcstats.delwribufs++;
binstailfree(bp, &bufqueues[BQ_DIRTY]);
- bcstats.freebufs++;
buf_release(bp);
continue;
}
@@ -1231,10 +1231,12 @@ void
bcstats_print(int (*pr)(const char *, ...))
{
(*pr)("Current Buffer Cache status:\n");
- (*pr)("numbufs %lld, freebufs %lld\n",
- bcstats.numbufs, bcstats.freebufs);
- (*pr)("bufpages %lld, freepages %lld, dirtypages %lld\n",
- bcstats.numbufpages, bcstats.numfreepages, bcstats.numdirtypages);
+ (*pr)("numbufs %lld busymapped %lld, delwri %lld\n",
+ bcstats.numbufs, bcstats.busymapped, bcstats.delwribufs);
+ (*pr)("kvaslots %lld avail kva slots %lld\n",
+ bcstats.kvaslots, bcstats.kvaslots_avail);
+ (*pr)("bufpages %lld, dirtypages %lld\n",
+ bcstats.numbufpages, bcstats.numdirtypages);
(*pr)("pendingreads %lld, pendingwrites %lld\n",
bcstats.pendingreads, bcstats.pendingwrites);
}
diff --git a/sys/kern/vfs_biomem.c b/sys/kern/vfs_biomem.c
index e0e1a5f1b39..2a1e342c62b 100644
--- a/sys/kern/vfs_biomem.c
+++ b/sys/kern/vfs_biomem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_biomem.c,v 1.17 2011/04/07 19:07:42 beck Exp $ */
+/* $OpenBSD: vfs_biomem.c,v 1.18 2011/09/19 14:48:04 beck Exp $ */
/*
* Copyright (c) 2007 Artur Grabowski <art@openbsd.org>
*
@@ -62,6 +62,9 @@ buf_mem_init(vsize_t size)
panic("bufinit: can't reserve VM for buffers");
buf_kva_end = buf_kva_start + size;
+ /* Contiguous mapping */
+ bcstats.kvaslots = bcstats.kvaslots_avail = size / MAXPHYS;
+
buf_object = &buf_object_store;
uvm_objinit(buf_object, NULL, 1);
@@ -118,6 +121,7 @@ buf_map(struct buf *bp)
if (buf_kva_start < buf_kva_end) {
va = buf_kva_start;
buf_kva_start += MAXPHYS;
+ bcstats.kvaslots_avail--;
} else {
struct buf *vbp;
@@ -145,6 +149,7 @@ buf_map(struct buf *bp)
bp->b_data = (caddr_t)va;
} else {
TAILQ_REMOVE(&buf_valist, bp, b_valist);
+ bcstats.kvaslots_avail--;
}
bcstats.busymapped++;
@@ -164,6 +169,7 @@ buf_release(struct buf *bp)
if (bp->b_data) {
bcstats.busymapped--;
TAILQ_INSERT_TAIL(&buf_valist, bp, b_valist);
+ bcstats.kvaslots_avail++;
if (buf_needva) {
buf_needva--;
wakeup_one(&buf_needva);
@@ -211,13 +217,14 @@ buf_dealloc_mem(struct buf *bp)
}
bp->b_data = data;
- if (!(bp->b_flags & B_BUSY)) /* XXX - need better test */
+ if (!(bp->b_flags & B_BUSY)) { /* XXX - need better test */
TAILQ_REMOVE(&buf_valist, bp, b_valist);
- else
+ bcstats.kvaslots_avail--;
+ } else
CLR(bp->b_flags, B_BUSY);
SET(bp->b_flags, B_RELEASED);
TAILQ_INSERT_HEAD(&buf_valist, bp, b_valist);
-
+ bcstats.kvaslots_avail++;
splx(s);
return (1);
@@ -253,6 +260,7 @@ buf_unmap(struct buf *bp)
s = splbio();
TAILQ_REMOVE(&buf_valist, bp, b_valist);
+ bcstats.kvaslots_avail--;
va = (vaddr_t)bp->b_data;
bp->b_data = 0;
pmap_kremove(va, bp->b_bufsize);