Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/subr_pool.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/subr_pool.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.218 retrieving revision 1.219 diff -u -p -r1.218 -r1.219 --- src/sys/kern/subr_pool.c 2017/12/04 03:05:24 1.218 +++ src/sys/kern/subr_pool.c 2017/12/16 03:13:29 1.219 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_pool.c,v 1.218 2017/12/04 03:05:24 mrg Exp $ */ +/* $NetBSD: subr_pool.c,v 1.219 2017/12/16 03:13:29 mrg Exp $ */ /*- * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014, 2015 @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.218 2017/12/04 03:05:24 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.219 2017/12/16 03:13:29 mrg Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1073,10 +1073,23 @@ pool_grow(struct pool *pp, int flags) } while (pp->pr_flags & PR_GROWING); return ERESTART; } else { + if (pp->pr_flags & PR_GROWINGNOWAIT) { + /* + * This needs an unlock/relock dance so + * that the other caller has a chance to + * run and actually do the thing. Note + * that this is effectively a busy-wait. + */ + mutex_exit(&pp->pr_lock); + mutex_enter(&pp->pr_lock); + return ERESTART; + } return EWOULDBLOCK; } } pp->pr_flags |= PR_GROWING; + if ((flags & PR_WAITOK) == 0) + pp->pr_flags |= PR_GROWINGNOWAIT; mutex_exit(&pp->pr_lock); char *cp = pool_allocator_alloc(pp, flags); @@ -1093,7 +1106,7 @@ pool_grow(struct pool *pp, int flags) pool_prime_page(pp, cp, ph); pp->pr_npagealloc++; KASSERT(pp->pr_flags & PR_GROWING); - pp->pr_flags &= ~PR_GROWING; + pp->pr_flags &= ~(PR_GROWING|PR_GROWINGNOWAIT); /* * If anyone was waiting for pool_grow, notify them that we * may have just done it. @@ -1102,7 +1115,7 @@ pool_grow(struct pool *pp, int flags) return 0; out: KASSERT(pp->pr_flags & PR_GROWING); - pp->pr_flags &= ~PR_GROWING; + pp->pr_flags &= ~(PR_GROWING|PR_GROWINGNOWAIT); mutex_enter(&pp->pr_lock); return ENOMEM; }