Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c
Show All 12 Lines | |||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/kstat.h> | #include <sys/kstat.h> | ||||
static MALLOC_DEFINE(M_KSTAT, "kstat_data", "Kernel statistics"); | static MALLOC_DEFINE(M_KSTAT, "kstat_data", "Kernel statistics"); | ||||
SYSCTL_ROOT_NODE(OID_AUTO, kstat, CTLFLAG_RW, 0, "Kernel statistics"); | SYSCTL_ROOT_NODE(OID_AUTO, kstat, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, | ||||
"Kernel statistics"); | |||||
kstat_t * | kstat_t * | ||||
kstat_create(char *module, int instance, char *name, char *class, uchar_t type, | kstat_create(char *module, int instance, char *name, char *class, uchar_t type, | ||||
ulong_t ndata, uchar_t flags) | ulong_t ndata, uchar_t flags) | ||||
{ | { | ||||
struct sysctl_oid *root; | struct sysctl_oid *root; | ||||
kstat_t *ksp; | kstat_t *ksp; | ||||
Show All 11 Lines | |||||
/* | /* | ||||
* Create sysctl tree for those statistics: | * Create sysctl tree for those statistics: | ||||
* | * | ||||
* kstat.<module>.<class>.<name>. | * kstat.<module>.<class>.<name>. | ||||
*/ | */ | ||||
sysctl_ctx_init(&ksp->ks_sysctl_ctx); | sysctl_ctx_init(&ksp->ks_sysctl_ctx); | ||||
root = SYSCTL_ADD_NODE(&ksp->ks_sysctl_ctx, | root = SYSCTL_ADD_NODE(&ksp->ks_sysctl_ctx, | ||||
SYSCTL_STATIC_CHILDREN(_kstat), OID_AUTO, module, CTLFLAG_RW, 0, | SYSCTL_STATIC_CHILDREN(_kstat), OID_AUTO, module, | ||||
""); | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, ""); | ||||
if (root == NULL) { | if (root == NULL) { | ||||
printf("%s: Cannot create kstat.%s tree!\n", __func__, module); | printf("%s: Cannot create kstat.%s tree!\n", __func__, module); | ||||
sysctl_ctx_free(&ksp->ks_sysctl_ctx); | sysctl_ctx_free(&ksp->ks_sysctl_ctx); | ||||
free(ksp, M_KSTAT); | free(ksp, M_KSTAT); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
root = SYSCTL_ADD_NODE(&ksp->ks_sysctl_ctx, SYSCTL_CHILDREN(root), | root = SYSCTL_ADD_NODE(&ksp->ks_sysctl_ctx, SYSCTL_CHILDREN(root), | ||||
OID_AUTO, class, CTLFLAG_RW, 0, ""); | OID_AUTO, class, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, ""); | ||||
if (root == NULL) { | if (root == NULL) { | ||||
printf("%s: Cannot create kstat.%s.%s tree!\n", __func__, | printf("%s: Cannot create kstat.%s.%s tree!\n", __func__, | ||||
module, class); | module, class); | ||||
sysctl_ctx_free(&ksp->ks_sysctl_ctx); | sysctl_ctx_free(&ksp->ks_sysctl_ctx); | ||||
free(ksp, M_KSTAT); | free(ksp, M_KSTAT); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
root = SYSCTL_ADD_NODE(&ksp->ks_sysctl_ctx, SYSCTL_CHILDREN(root), | root = SYSCTL_ADD_NODE(&ksp->ks_sysctl_ctx, SYSCTL_CHILDREN(root), | ||||
OID_AUTO, name, CTLFLAG_RW, 0, ""); | OID_AUTO, name, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, ""); | ||||
if (root == NULL) { | if (root == NULL) { | ||||
printf("%s: Cannot create kstat.%s.%s.%s tree!\n", __func__, | printf("%s: Cannot create kstat.%s.%s.%s tree!\n", __func__, | ||||
module, class, name); | module, class, name); | ||||
sysctl_ctx_free(&ksp->ks_sysctl_ctx); | sysctl_ctx_free(&ksp->ks_sysctl_ctx); | ||||
free(ksp, M_KSTAT); | free(ksp, M_KSTAT); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
ksp->ks_sysctl_root = root; | ksp->ks_sysctl_root = root; | ||||
Show All 12 Lines |