Provide macros that allow easily export uma(9) zone limits and
current usage via sysctl(9): SYSCTL_UMA_MAX() SYSCTL_ADD_UMA_MAX() SYSCTL_UMA_CUR() SYSCTL_ADD_UMA_CUR() Sponsored by: Nginx, Inc.
This commit is contained in:
parent
5e6abd57c8
commit
e8c2426587
@ -25,7 +25,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 21, 2013
|
||||
.Dd February 7, 2014
|
||||
.Dt ZONE 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -71,6 +71,11 @@
|
||||
.Fn uma_zone_get_cur "uma_zone_t zone"
|
||||
.Ft void
|
||||
.Fn uma_zone_set_warning "uma_zone_t zone" "const char *warning"
|
||||
.In sys/sysctl.h
|
||||
.Fn SYSCTL_UMA_MAX parent nbr name access zone descr
|
||||
.Fn SYSCTL_ADD_UMA_MAX ctx parent nbr name access zone descr
|
||||
.Fn SYSCTL_UMA_CUR parent nbr name access zone descr
|
||||
.Fn SYSCTL_ADD_UMA_CUR ctx parent nbr name access zone descr
|
||||
.Sh DESCRIPTION
|
||||
The zone allocator provides an efficient interface for managing
|
||||
dynamically-sized collections of items of similar size.
|
||||
@ -307,6 +312,38 @@ Warnings can be turned off globally by setting the
|
||||
.Va vm.zone_warnings
|
||||
sysctl tunable to
|
||||
.Va 0 .
|
||||
.Pp
|
||||
The
|
||||
.Fn SYSCTL_UMA_MAX parent nbr name access zone descr
|
||||
macro declares a static
|
||||
.Xr sysctl
|
||||
oid that exports the effective upper limit number of items for a zone.
|
||||
The
|
||||
.Fa zone
|
||||
argument should be a pointer to
|
||||
.Vt uma_zone_t .
|
||||
A read of the oid returns value obtained through
|
||||
.Fn uma_zone_get_max .
|
||||
A write to the oid sets new value via
|
||||
.Fn uma_zone_set_max .
|
||||
The
|
||||
.Fn SYSCTL_ADD_UMA_MAX ctx parent nbr name access zone descr
|
||||
macro is provided to create this type of oid dynamically.
|
||||
.Pp
|
||||
The
|
||||
.Fn SYSCTL_UMA_CUR parent nbr name access zone descr
|
||||
macro declares a static read only
|
||||
.Xr sysctl
|
||||
oid that exports the approximate current occupancy of the zone.
|
||||
The
|
||||
.Fa zone
|
||||
argument should be a pointer to
|
||||
.Vt uma_zone_t .
|
||||
A read of the oid returns value obtained through
|
||||
.Fn uma_zone_get_cur .
|
||||
The
|
||||
.Fn SYSCTL_ADD_UMA_CUR ctx parent nbr name zone descr
|
||||
macro is provided to create this type of oid dynamically.
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Fn uma_zalloc
|
||||
|
@ -186,6 +186,9 @@ int sysctl_handle_string(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_counter_u64(SYSCTL_HANDLER_ARGS);
|
||||
|
||||
int sysctl_handle_uma_zone_max(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_handle_uma_zone_cur(SYSCTL_HANDLER_ARGS);
|
||||
|
||||
int sysctl_dpcpu_int(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_dpcpu_long(SYSCTL_HANDLER_ARGS);
|
||||
int sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS);
|
||||
@ -431,6 +434,30 @@ SYSCTL_ALLOWED_TYPES(UINT64, uint64_t *a; unsigned long long *b; );
|
||||
sysctl_add_oid(ctx, parent, nbr, name, (access), \
|
||||
ptr, arg, handler, fmt, __DESCR(descr))
|
||||
|
||||
/* Oid to handle limits on uma(9) zone specified by pointer. */
|
||||
#define SYSCTL_UMA_MAX(parent, nbr, name, access, ptr, descr) \
|
||||
SYSCTL_ASSERT_TYPE(INT, ptr, parent, name); \
|
||||
SYSCTL_OID(parent, nbr, name, \
|
||||
CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \
|
||||
ptr, 0, sysctl_handle_uma_zone_max, "I", descr)
|
||||
#define SYSCTL_ADD_UMA_MAX(ctx, parent, nbr, name, access, ptr, descr)\
|
||||
sysctl_add_oid(ctx, parent, nbr, name, \
|
||||
CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \
|
||||
SYSCTL_ADD_ASSERT_TYPE(INT, ptr), 0, \
|
||||
sysctl_handle_uma_zone_max, "I", __DESCR(descr))
|
||||
|
||||
/* Oid to obtain current use of uma(9) zone specified by pointer. */
|
||||
#define SYSCTL_UMA_CUR(parent, nbr, name, access, ptr, descr) \
|
||||
SYSCTL_ASSERT_TYPE(INT, ptr, parent, name); \
|
||||
SYSCTL_OID(parent, nbr, name, \
|
||||
CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
|
||||
ptr, 0, sysctl_handle_uma_zone_cur, "I", descr)
|
||||
#define SYSCTL_ADD_UMA_CUR(ctx, parent, nbr, name, access, ptr, descr) \
|
||||
sysctl_add_oid(ctx, parent, nbr, name, \
|
||||
CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \
|
||||
SYSCTL_ADD_ASSERT_TYPE(INT, ptr), 0, \
|
||||
sysctl_handle_uma_zone_cur, "I", __DESCR(descr))
|
||||
|
||||
/*
|
||||
* A macro to generate a read-only sysctl to indicate the presense of optional
|
||||
* kernel features.
|
||||
|
@ -3465,6 +3465,35 @@ skip:
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
sysctl_handle_uma_zone_max(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
uma_zone_t zone = *(uma_zone_t *)arg1;
|
||||
int error, max, old;
|
||||
|
||||
old = max = uma_zone_get_max(zone);
|
||||
error = sysctl_handle_int(oidp, &max, 0, req);
|
||||
if (error || !req->newptr)
|
||||
return (error);
|
||||
|
||||
if (max < old)
|
||||
return (EINVAL);
|
||||
|
||||
uma_zone_set_max(zone, max);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
sysctl_handle_uma_zone_cur(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
uma_zone_t zone = *(uma_zone_t *)arg1;
|
||||
int cur;
|
||||
|
||||
cur = uma_zone_get_cur(zone);
|
||||
return (sysctl_handle_int(oidp, &cur, 0, req));
|
||||
}
|
||||
|
||||
#ifdef DDB
|
||||
DB_SHOW_COMMAND(uma, db_show_uma)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user