mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-04 23:50:27 +00:00
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.
This commit is contained in:
parent
145b960169
commit
828447e0ca
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=118921
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue