diff options
author | cg <cg@FreeBSD.org> | 2003-08-14 21:16:46 +0000 |
---|---|---|
committer | cg <cg@FreeBSD.org> | 2003-08-14 21:16:46 +0000 |
commit | d647a00dc323eab7097c63997b8b974374b96fa6 (patch) | |
tree | d5d7374f52e30d7eb5b94572ecd1f2a68888b3b5 | |
parent | 587cb35d193eb6639cab071555ebb380f48f69b4 (diff) | |
download | FreeBSD-src-d647a00dc323eab7097c63997b8b974374b96fa6.zip FreeBSD-src-d647a00dc323eab7097c63997b8b974374b96fa6.tar.gz |
add a read-only sysctl to display the number of entries in the fixed size
kobj global method table; also kassert that the table has not overflowed
when defining a new method.
there are indications that the table is being overflowed in certain
situations as we gain more kobj consumers- this will allow us to check
whether kobj is at fault. symptoms would be incorrect methods being called.
-rw-r--r-- | sys/kern/subr_kobj.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sys/kern/subr_kobj.c b/sys/kern/subr_kobj.c index c02662a..a3fc230 100644 --- a/sys/kern/subr_kobj.c +++ b/sys/kern/subr_kobj.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/module.h> #include <sys/errno.h> +#include <sys/sysctl.h> #ifndef TEST #include <sys/systm.h> #endif @@ -46,20 +47,21 @@ static MALLOC_DEFINE(M_KOBJ, "kobj", "Kernel object structures"); #ifdef KOBJ_STATS -#include <sys/sysctl.h> - u_int kobj_lookup_hits; u_int kobj_lookup_misses; SYSCTL_UINT(_kern, OID_AUTO, kobj_hits, CTLFLAG_RD, - &kobj_lookup_hits, 0, "") + &kobj_lookup_hits, 0, ""); SYSCTL_UINT(_kern, OID_AUTO, kobj_misses, CTLFLAG_RD, - &kobj_lookup_misses, 0, "") + &kobj_lookup_misses, 0, ""); #endif static int kobj_next_id = 1; +SYSCTL_UINT(_kern, OID_AUTO, kobj_methodcount, CTLFLAG_RD, + &kobj_next_id, 0, ""); + static int kobj_error_method(void) { @@ -69,8 +71,10 @@ kobj_error_method(void) static void kobj_register_method(struct kobjop_desc *desc) { - if (desc->id == 0) + if (desc->id == 0) { + KASSERT((kobj_next_id < KOBJ_CACHE_SIZE), ("kobj method table overflow")); desc->id = kobj_next_id++; + } } static void |