Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm Add a sysctl hashstat collector for ubchash.
details: https://anonhg.NetBSD.org/src/rev/b06789a92585
branches: trunk
changeset: 960882:b06789a92585
user: simonb <simonb%NetBSD.org@localhost>
date: Thu Apr 01 06:26:26 2021 +0000
description:
Add a sysctl hashstat collector for ubchash.
diffstat:
sys/uvm/uvm_bio.c | 40 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 38 insertions(+), 2 deletions(-)
diffs (79 lines):
diff -r 4846d7ecc67d -r b06789a92585 sys/uvm/uvm_bio.c
--- a/sys/uvm/uvm_bio.c Thu Apr 01 06:26:14 2021 +0000
+++ b/sys/uvm/uvm_bio.c Thu Apr 01 06:26:26 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_bio.c,v 1.125 2021/03/13 15:29:55 skrll Exp $ */
+/* $NetBSD: uvm_bio.c,v 1.126 2021/04/01 06:26:26 simonb Exp $ */
/*
* Copyright (c) 1998 Chuck Silvers.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.125 2021/03/13 15:29:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.126 2021/04/01 06:26:26 simonb Exp $");
#include "opt_uvmhist.h"
#include "opt_ubc.h"
@@ -44,6 +44,7 @@
#include <sys/kmem.h>
#include <sys/kernel.h>
#include <sys/proc.h>
+#include <sys/sysctl.h>
#include <sys/vnode.h>
#include <sys/bitops.h> /* for ilog2() */
@@ -61,6 +62,7 @@
static int ubc_fault(struct uvm_faultinfo *, vaddr_t, struct vm_page **,
int, int, vm_prot_t, int);
static struct ubc_map *ubc_find_mapping(struct uvm_object *, voff_t);
+static int ubchash_stats(struct hashstat_sysctl *hs, bool fill);
#ifdef UBC_USE_PMAP_DIRECT
static int __noinline ubc_uiomove_direct(struct uvm_object *, struct uio *, vsize_t,
int, int);
@@ -215,6 +217,8 @@
UVM_ADV_RANDOM, UVM_FLAG_NOMERGE)) != 0) {
panic("ubc_init: failed to map ubc_object");
}
+
+ hashstat_register("ubchash", ubchash_stats);
}
void
@@ -1104,3 +1108,35 @@
}
rw_exit(ubc_object.uobj.vmobjlock);
}
+
+static int
+ubchash_stats(struct hashstat_sysctl *hs, bool fill)
+{
+ struct ubc_map *umap;
+ uint64_t chain;
+
+ strlcpy(hs->hash_name, "ubchash", sizeof(hs->hash_name));
+ strlcpy(hs->hash_desc, "ubc object hash", sizeof(hs->hash_desc));
+ if (!fill)
+ return 0;
+
+ hs->hash_size = ubc_object.hashmask + 1;
+
+ for (size_t i = 0; i < hs->hash_size; i++) {
+ chain = 0;
+ rw_enter(ubc_object.uobj.vmobjlock, RW_READER);
+ LIST_FOREACH(umap, &ubc_object.hash[i], hash) {
+ chain++;
+ }
+ rw_exit(ubc_object.uobj.vmobjlock);
+ if (chain > 0) {
+ hs->hash_used++;
+ hs->hash_items += chain;
+ if (chain > hs->hash_maxchain)
+ hs->hash_maxchain = chain;
+ }
+ preempt_point();
+ }
+
+ return 0;
+}
Home |
Main Index |
Thread Index |
Old Index