diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2013-03-26 16:37:46 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2013-03-26 16:37:46 +0000 |
commit | 6ada396006bd41ead7de7dc584b765c3f80a423c (patch) | |
tree | 59ded45b44306b15eebcba9230865a7ffa5e1cb0 /sys/kern | |
parent | 8d4375be1a5e1ca33e59afa516419d2270212a19 (diff) |
simpleq is lighter weight and sufficient for pool's needs.
ok deraadt
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_pool.c | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c index 47459a8e332..df0f1d40e55 100644 --- a/sys/kern/subr_pool.c +++ b/sys/kern/subr_pool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_pool.c,v 1.114 2013/02/17 17:39:29 miod Exp $ */ +/* $OpenBSD: subr_pool.c,v 1.115 2013/03/26 16:37:45 tedu Exp $ */ /* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */ /*- @@ -58,7 +58,7 @@ */ /* List of all pools */ -TAILQ_HEAD(,pool) pool_head = TAILQ_HEAD_INITIALIZER(pool_head); +SIMPLEQ_HEAD(,pool) pool_head = SIMPLEQ_HEAD_INITIALIZER(pool_head); /* Private pool for page header structures */ struct pool phpool; @@ -67,7 +67,7 @@ struct pool_item_header { /* Page headers */ LIST_ENTRY(pool_item_header) ph_pagelist; /* pool page list */ - TAILQ_HEAD(,pool_item) ph_itemlist; /* chunk list for this page */ + SIMPLEQ_HEAD(,pool_item) ph_itemlist; /* chunk list for this page */ RB_ENTRY(pool_item_header) ph_node; /* Off-page page headers */ int ph_nmissing; /* # of chunks in use */ @@ -82,7 +82,7 @@ struct pool_item { u_int32_t pi_magic; #endif /* Other entries use only this list entry */ - TAILQ_ENTRY(pool_item) pi_list; + SIMPLEQ_ENTRY(pool_item) pi_list; }; #ifdef DEADBEEF1 @@ -406,7 +406,7 @@ pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags, pp->pr_crange = &kp_dirty; /* Insert this into the list of all pools. */ - TAILQ_INSERT_HEAD(&pool_head, pp, pr_poollist); + SIMPLEQ_INSERT_HEAD(&pool_head, pp, pr_poollist); } void @@ -423,6 +423,7 @@ void pool_destroy(struct pool *pp) { struct pool_item_header *ph; + struct pool *prev, *iter; #ifdef DIAGNOSTIC if (pp->pr_nout != 0) @@ -436,7 +437,19 @@ pool_destroy(struct pool *pp) KASSERT(LIST_EMPTY(&pp->pr_partpages)); /* Remove from global pool list */ - TAILQ_REMOVE(&pool_head, pp, pr_poollist); + if (pp == SIMPLEQ_FIRST(&pool_head)) + SIMPLEQ_REMOVE_HEAD(&pool_head, pr_poollist); + else { + prev = SIMPLEQ_FIRST(&pool_head); + SIMPLEQ_FOREACH(iter, &pool_head, pr_poollist) { + if (iter == pp) { + SIMPLEQ_REMOVE_AFTER(&pool_head, prev, + pr_poollist); + break; + } + prev = iter; + } + } } struct pool_item_header * @@ -616,7 +629,7 @@ startover: /* Start the allocation process over. */ goto startover; } - if ((v = pi = TAILQ_FIRST(&ph->ph_itemlist)) == NULL) { + if ((v = pi = SIMPLEQ_FIRST(&ph->ph_itemlist)) == NULL) { panic("pool_do_get: %s: page empty", pp->pr_wchan); } #ifdef DIAGNOSTIC @@ -650,7 +663,7 @@ startover: /* * Remove from item list. */ - TAILQ_REMOVE(&ph->ph_itemlist, pi, pi_list); + SIMPLEQ_REMOVE_HEAD(&ph->ph_itemlist, pi_list); pp->pr_nitems--; pp->pr_nout++; if (ph->ph_nmissing == 0) { @@ -668,7 +681,7 @@ startover: LIST_INSERT_HEAD(&pp->pr_partpages, ph, ph_pagelist); } ph->ph_nmissing++; - if (TAILQ_EMPTY(&ph->ph_itemlist)) { + if (SIMPLEQ_EMPTY(&ph->ph_itemlist)) { #ifdef DIAGNOSTIC if (ph->ph_nmissing != pp->pr_itemsperpage) { panic("pool_do_get: %s: nmissing inconsistent", @@ -775,7 +788,7 @@ pool_do_put(struct pool *pp, void *v) #endif /* POOL_DEBUG */ #endif /* DIAGNOSTIC */ - TAILQ_INSERT_HEAD(&ph->ph_itemlist, pi, pi_list); + SIMPLEQ_INSERT_HEAD(&ph->ph_itemlist, pi, pi_list); ph->ph_nmissing--; pp->pr_nitems++; pp->pr_nout--; @@ -881,7 +894,7 @@ pool_prime_page(struct pool *pp, caddr_t storage, struct pool_item_header *ph) * Insert page header. */ LIST_INSERT_HEAD(&pp->pr_emptypages, ph, ph_pagelist); - TAILQ_INIT(&ph->ph_itemlist); + SIMPLEQ_INIT(&ph->ph_itemlist); ph->ph_page = storage; ph->ph_pagesize = pp->pr_alloc->pa_pagesz; ph->ph_nmissing = 0; @@ -916,7 +929,7 @@ pool_prime_page(struct pool *pp, caddr_t storage, struct pool_item_header *ph) KASSERT(((((vaddr_t)pi) + ioff) & (align - 1)) == 0); /* Insert on page list */ - TAILQ_INSERT_TAIL(&ph->ph_itemlist, pi, pi_list); + SIMPLEQ_INSERT_TAIL(&ph->ph_itemlist, pi, pi_list); #ifdef DIAGNOSTIC pi->pi_magic = PI_MAGIC; @@ -1108,7 +1121,7 @@ pool_reclaim_all(void) int s; s = splhigh(); - TAILQ_FOREACH(pp, &pool_head, pr_poollist) + SIMPLEQ_FOREACH(pp, &pool_head, pr_poollist) pool_reclaim(pp); splx(s); } @@ -1141,7 +1154,7 @@ pool_print_pagelist(struct pool_pagelist *pl, (*pr)("\t\tpage %p, nmissing %d\n", ph->ph_page, ph->ph_nmissing); #ifdef DIAGNOSTIC - TAILQ_FOREACH(pi, &ph->ph_itemlist, pi_list) { + SIMPLEQ_FOREACH(pi, &ph->ph_itemlist, pi_list) { if (pi->pi_magic != PI_MAGIC) { (*pr)("\t\t\titem %p, magic 0x%x\n", pi, pi->pi_magic); @@ -1230,7 +1243,7 @@ db_show_all_pools(db_expr_t expr, int haddr, db_expr_t count, char *modif) db_printf("%-12s %18s %18s\n", "Name", "Address", "Allocator"); - TAILQ_FOREACH(pp, &pool_head, pr_poollist) { + SIMPLEQ_FOREACH(pp, &pool_head, pr_poollist) { if (mode == 'a') { db_printf("%-12s %18p %18p\n", pp->pr_wchan, pp, pp->pr_alloc); @@ -1295,9 +1308,9 @@ pool_chk_page(struct pool *pp, struct pool_item_header *ph, int expected) return 1; } - for (pi = TAILQ_FIRST(&ph->ph_itemlist), n = 0; + for (pi = SIMPLEQ_FIRST(&ph->ph_itemlist), n = 0; pi != NULL; - pi = TAILQ_NEXT(pi,pi_list), n++) { + pi = SIMPLEQ_NEXT(pi,pi_list), n++) { #ifdef DIAGNOSTIC if (pi->pi_magic != PI_MAGIC) { @@ -1395,7 +1408,7 @@ pool_walk(struct pool *pp, int full, n = ph->ph_nmissing; do { - TAILQ_FOREACH(pi, &ph->ph_itemlist, pi_list) { + SIMPLEQ_FOREACH(pi, &ph->ph_itemlist, pi_list) { if (cp == (caddr_t)pi) break; } @@ -1447,7 +1460,7 @@ sysctl_dopool(int *name, u_int namelen, char *where, size_t *sizep) s = splvm(); - TAILQ_FOREACH(pp, &pool_head, pr_poollist) { + SIMPLEQ_FOREACH(pp, &pool_head, pr_poollist) { npools++; if (lookfor == pp->pr_serial) { foundpool = pp; |