-.\" $OpenBSD: pool_cache_init.9,v 1.6 2017/06/22 02:30:34 dlg Exp $
+.\" $OpenBSD: pool_cache_init.9,v 1.7 2017/06/23 01:02:18 dlg Exp $
.\"
.\" Copyright (c) 2017 David Gwynne <dlg@openbsd.org>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 22 2017 $
+.Dd $Mdocdate: June 23 2017 $
.Dt POOL_CACHE_INIT 9
.Os
.Sh NAME
struct kinfo_pool_cache {
uint64_t pr_ngc;
unsigned int pr_len;
- unsigned int pr_nlist;
+ unsigned int pr_nitems;
unsigned int pr_contention;
};
.Ed
shows the maximum number of items that can be cached on a CPU's
active free list.
.Pp
-.Va pr_nlist
-shows the number of free lists that are currently stored in the
+.Va pr_nitems
+shows the number of free items that are currently stored in the
global depot.
.Pp
.Va pr_contention
-/* $OpenBSD: subr_pool.c,v 1.215 2017/06/19 23:57:12 dlg Exp $ */
+/* $OpenBSD: subr_pool.c,v 1.216 2017/06/23 01:02:18 dlg Exp $ */
/* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */
/*-
mtx_init(&pp->pr_cache_mtx, pp->pr_ipl);
arc4random_buf(pp->pr_cache_magic, sizeof(pp->pr_cache_magic));
TAILQ_INIT(&pp->pr_cache_lists);
- pp->pr_cache_nlist = 0;
+ pp->pr_cache_nitems = 0;
pp->pr_cache_tick = ticks;
pp->pr_cache_items = 8;
pp->pr_cache_contention = 0;
pl = TAILQ_FIRST(&pp->pr_cache_lists);
if (pl != NULL) {
TAILQ_REMOVE(&pp->pr_cache_lists, pl, ci_nextl);
- pp->pr_cache_nlist--;
+ pp->pr_cache_nitems -= POOL_CACHE_ITEM_NITEMS(pl);
pool_cache_item_magic(pp, pl);
if (TAILQ_EMPTY(&pp->pr_cache_lists))
pp->pr_cache_tick = ticks;
+ pp->pr_cache_nitems += POOL_CACHE_ITEM_NITEMS(ci);
TAILQ_INSERT_TAIL(&pp->pr_cache_lists, ci, ci_nextl);
- pp->pr_cache_nlist++;
pc->pc_nlput++;
pl = TAILQ_FIRST(&pp->pr_cache_lists);
if (pl != NULL) {
TAILQ_REMOVE(&pp->pr_cache_lists, pl, ci_nextl);
+ pp->pr_cache_nitems -= POOL_CACHE_ITEM_NITEMS(pl);
pp->pr_cache_tick = ticks;
- pp->pr_cache_nlist--;
pp->pr_cache_ngc++;
}
contention = pp->pr_cache_contention;
if ((contention - pp->pr_cache_contention_prev) > 8 /* magic */) {
- unsigned int limit = pp->pr_npages * pp->pr_itemsperpage;
- unsigned int items = pp->pr_cache_items + 8;
- unsigned int cache = ncpusfound * items * 2;
-
- /* are there enough items around so every cpu can hold some? */
-
- if (cache < limit)
- pp->pr_cache_items = items;
+ if ((ncpusfound * 8 * 2) <= pp->pr_cache_nitems)
+ pp->pr_cache_items += 8;
}
pp->pr_cache_contention_prev = contention;
}
mtx_enter(&pp->pr_cache_mtx);
kpc.pr_ngc = pp->pr_cache_ngc;
kpc.pr_len = pp->pr_cache_items;
- kpc.pr_nlist = pp->pr_cache_nlist;
+ kpc.pr_nitems = pp->pr_cache_nitems;
kpc.pr_contention = pp->pr_cache_contention;
mtx_leave(&pp->pr_cache_mtx);
-/* $OpenBSD: pool.h,v 1.72 2017/06/19 23:57:12 dlg Exp $ */
+/* $OpenBSD: pool.h,v 1.73 2017/06/23 01:02:18 dlg Exp $ */
/* $NetBSD: pool.h,v 1.27 2001/06/06 22:00:17 rafal Exp $ */
/*-
struct kinfo_pool_cache {
uint64_t pr_ngc; /* # of times a list has been gc'ed */
unsigned int pr_len; /* current target for list len */
- unsigned int pr_nlist; /* # of lists in the pool */
+ unsigned int pr_nitems; /* # of idle items in the depot */
unsigned int pr_contention; /* # of times mtx was busy */
};
struct mutex pr_cache_mtx;
struct pool_cache_lists
pr_cache_lists; /* list of idle item lists */
- u_int pr_cache_nlist; /* # of idle lists */
+ u_int pr_cache_nitems; /* # of idle items */
u_int pr_cache_items; /* target list length */
u_int pr_cache_contention;
u_int pr_cache_contention_prev;
-/* $OpenBSD: pool.c,v 1.12 2017/06/15 03:47:07 dlg Exp $ */
+/* $OpenBSD: pool.c,v 1.13 2017/06/23 01:02:18 dlg Exp $ */
/*
* Copyright (c) 2008 Can Erkin Acar <canacar@openbsd.org>
*
field_def pool_cache_fields[] = {
{"NAME", 12, 32, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0},
{"LEN", 4, 4, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
- {"NL", 4, 4, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
+ {"IDLE", 4, 4, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{"NGC", 4, 4, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{"CPU", 4, 4, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
{"REQ", 8, 12, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0},
#define FLD_POOL_CACHE_NAME FIELD_ADDR(pool_cache_fields, 0)
#define FLD_POOL_CACHE_LEN FIELD_ADDR(pool_cache_fields, 1)
-#define FLD_POOL_CACHE_NL FIELD_ADDR(pool_cache_fields, 2)
+#define FLD_POOL_CACHE_IDLE FIELD_ADDR(pool_cache_fields, 2)
#define FLD_POOL_CACHE_NGC FIELD_ADDR(pool_cache_fields, 3)
#define FLD_POOL_CACHE_CPU FIELD_ADDR(pool_cache_fields, 4)
#define FLD_POOL_CACHE_GET FIELD_ADDR(pool_cache_fields, 5)
field_def *view_pool_cache_0[] = {
FLD_POOL_CACHE_NAME,
FLD_POOL_CACHE_LEN,
- FLD_POOL_CACHE_NL,
+ FLD_POOL_CACHE_IDLE,
FLD_POOL_CACHE_NGC,
FLD_POOL_CACHE_CPU,
FLD_POOL_CACHE_GET,
print_fld_str(FLD_POOL_CACHE_NAME, pc->name);
print_fld_uint(FLD_POOL_CACHE_LEN, kpc->pr_len);
- print_fld_uint(FLD_POOL_CACHE_NL, kpc->pr_nlist);
+ print_fld_uint(FLD_POOL_CACHE_IDLE, kpc->pr_nitems);
print_fld_uint(FLD_POOL_CACHE_NGC, kpc->pr_ngc);
for (cpu = 0; cpu < ncpusfound; cpu++) {