From cb993534d12b98cd1ba9d48fa00de63bfb6ffc7e Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 31 May 2013 20:44:11 +0000 Subject: open up some races. if pool_debug == 2, force a yield() whenever waitok. ok miod --- sys/kern/kern_malloc.c | 10 ++++++++-- sys/kern/subr_pool.c | 7 +++++-- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index e72e675729d..74a4aab6b9f 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_malloc.c,v 1.100 2013/05/03 18:26:07 tedu Exp $ */ +/* $OpenBSD: kern_malloc.c,v 1.101 2013/05/31 20:44:10 tedu Exp $ */ /* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */ /* @@ -180,8 +180,14 @@ malloc(unsigned long size, int type, int flags) KASSERT(flags & (M_WAITOK | M_NOWAIT)); - if ((flags & M_NOWAIT) == 0) +#ifdef DIAGNOSTIC + if ((flags & M_NOWAIT) == 0) { + extern int pool_debug; assertwaitok(); + if (pool_debug == 2) + yield(); + } +#endif #ifdef MALLOC_DEBUG if (debug_malloc(size, type, flags, (void **)&va)) { diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c index 0a8bbb95368..ddaab3988d5 100644 --- a/sys/kern/subr_pool.c +++ b/sys/kern/subr_pool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_pool.c,v 1.120 2013/05/03 18:26:07 tedu Exp $ */ +/* $OpenBSD: subr_pool.c,v 1.121 2013/05/31 20:44:10 tedu Exp $ */ /* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */ /*- @@ -484,8 +484,11 @@ pool_get(struct pool *pp, int flags) KASSERT(flags & (PR_WAITOK | PR_NOWAIT)); #ifdef DIAGNOSTIC - if ((flags & PR_WAITOK) != 0) + if ((flags & PR_WAITOK) != 0) { assertwaitok(); + if (pool_debug == 2) + yield(); + } #endif /* DIAGNOSTIC */ mtx_enter(&pp->pr_mtx); -- cgit v1.2.3