From 828447e0caf40a47509812498d4116e55fc5b577 Mon Sep 17 00:00:00 2001 From: Cameron Grant Date: Thu, 14 Aug 2003 21:16:46 +0000 Subject: [PATCH] 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. --- sys/kern/subr_kobj.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sys/kern/subr_kobj.c b/sys/kern/subr_kobj.c index c02662a095cb..a3fc230d16ad 100644 --- a/sys/kern/subr_kobj.c +++ b/sys/kern/subr_kobj.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifndef TEST #include #endif @@ -46,20 +47,21 @@ static MALLOC_DEFINE(M_KOBJ, "kobj", "Kernel object structures"); #ifdef KOBJ_STATS -#include - 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