version 1.215, 2017/11/09 22:52:26 |
version 1.216, 2017/11/14 15:02:06 |
Line 809 pool_get(struct pool *pp, int flags) |
|
Line 809 pool_get(struct pool *pp, int flags) |
|
pp->pr_nfail++; |
pp->pr_nfail++; |
|
|
mutex_exit(&pp->pr_lock); |
mutex_exit(&pp->pr_lock); |
KASSERT((flags & (PR_WAITOK|PR_NOWAIT)) == PR_NOWAIT); |
KASSERT((flags & (PR_NOWAIT|PR_LIMITFAIL)) != 0); |
return (NULL); |
return (NULL); |
} |
} |
|
|
Line 1062 pool_put(struct pool *pp, void *v) |
|
Line 1062 pool_put(struct pool *pp, void *v) |
|
static int |
static int |
pool_grow(struct pool *pp, int flags) |
pool_grow(struct pool *pp, int flags) |
{ |
{ |
struct pool_item_header *ph = NULL; |
|
char *cp; |
|
int error; |
|
|
|
/* |
/* |
* If there's a pool_grow in progress, wait for it to complete |
* If there's a pool_grow in progress, wait for it to complete |
* and try again from the top. |
* and try again from the top. |
Line 1083 pool_grow(struct pool *pp, int flags) |
|
Line 1079 pool_grow(struct pool *pp, int flags) |
|
pp->pr_flags |= PR_GROWING; |
pp->pr_flags |= PR_GROWING; |
|
|
mutex_exit(&pp->pr_lock); |
mutex_exit(&pp->pr_lock); |
cp = pool_allocator_alloc(pp, flags); |
char *cp = pool_allocator_alloc(pp, flags); |
if (__predict_true(cp != NULL)) { |
if (__predict_false(cp == NULL)) |
ph = pool_alloc_item_header(pp, cp, flags); |
goto out; |
} |
|
if (__predict_false(cp == NULL || ph == NULL)) { |
struct pool_item_header *ph = pool_alloc_item_header(pp, cp, flags); |
if (cp != NULL) { |
if (__predict_false(ph == NULL)) { |
pool_allocator_free(pp, cp); |
pool_allocator_free(pp, cp); |
} |
|
mutex_enter(&pp->pr_lock); |
|
error = ENOMEM; |
|
goto out; |
goto out; |
} |
} |
|
|
mutex_enter(&pp->pr_lock); |
mutex_enter(&pp->pr_lock); |
pool_prime_page(pp, cp, ph); |
pool_prime_page(pp, cp, ph); |
pp->pr_npagealloc++; |
pp->pr_npagealloc++; |
error = 0; |
KASSERT(pp->pr_flags & PR_GROWING); |
|
pp->pr_flags &= ~PR_GROWING; |
out: |
|
/* |
/* |
* If anyone was waiting for pool_grow, notify them that we |
* If anyone was waiting for pool_grow, notify them that we |
* may have just done it. |
* may have just done it. |
*/ |
*/ |
|
cv_broadcast(&pp->pr_cv); |
|
return 0; |
|
out: |
KASSERT(pp->pr_flags & PR_GROWING); |
KASSERT(pp->pr_flags & PR_GROWING); |
pp->pr_flags &= ~PR_GROWING; |
pp->pr_flags &= ~PR_GROWING; |
cv_broadcast(&pp->pr_cv); |
mutex_enter(&pp->pr_lock); |
|
return ENOMEM; |
return error; |
|
} |
} |
|
|
/* |
/* |
Line 1126 pool_prime(struct pool *pp, int n) |
|
Line 1120 pool_prime(struct pool *pp, int n) |
|
|
|
newpages = roundup(n, pp->pr_itemsperpage) / pp->pr_itemsperpage; |
newpages = roundup(n, pp->pr_itemsperpage) / pp->pr_itemsperpage; |
|
|
while (newpages-- > 0) { |
while (newpages > 0) { |
error = pool_grow(pp, PR_NOWAIT); |
error = pool_grow(pp, PR_NOWAIT); |
if (error) { |
if (error) { |
if (error == ERESTART) |
if (error == ERESTART) |
Line 1134 pool_prime(struct pool *pp, int n) |
|
Line 1128 pool_prime(struct pool *pp, int n) |
|
break; |
break; |
} |
} |
pp->pr_minpages++; |
pp->pr_minpages++; |
|
newpages--; |
} |
} |
|
|
if (pp->pr_minpages >= pp->pr_maxpages) |
if (pp->pr_minpages >= pp->pr_maxpages) |