diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2018-07-10 10:17:43 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2018-07-10 10:17:43 +0000 |
commit | 1cb8f2759a711e83f5b59687cae09db8c3ed9e21 (patch) | |
tree | d721685be647dbb91df0b84ae894cb32ae2f56b6 /sys/kern/kern_malloc.c | |
parent | 878e7225ac9f490f32a6f128aea39af025a219aa (diff) |
In free(9) call wakeup() after mtx_leave() consistently.
OK kettenis@ visa@ mpi@
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r-- | sys/kern/kern_malloc.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index ac48383baa1..f39b17942b4 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_malloc.c,v 1.135 2018/07/09 20:02:18 bluhm Exp $ */ +/* $OpenBSD: kern_malloc.c,v 1.136 2018/07/10 10:17:42 bluhm Exp $ */ /* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */ /* @@ -373,6 +373,7 @@ free(void *addr, int type, size_t freedsize) #endif #ifdef KMEMSTATS struct kmemstats *ksp = &kmemstats[type]; + int wake; #endif if (addr == NULL) @@ -421,12 +422,13 @@ free(void *addr, int type, size_t freedsize) #ifdef KMEMSTATS mtx_enter(&malloc_mtx); ksp->ks_memuse -= size; - if (ksp->ks_memuse + size >= ksp->ks_limit && - ksp->ks_memuse < ksp->ks_limit) - wakeup(ksp); + wake = ksp->ks_memuse + size >= ksp->ks_limit && + ksp->ks_memuse < ksp->ks_limit; ksp->ks_inuse--; kbp->kb_total -= 1; mtx_leave(&malloc_mtx); + if (wake) + wakeup(ksp); #endif return; } @@ -466,13 +468,16 @@ free(void *addr, int type, size_t freedsize) } kbp->kb_totalfree++; ksp->ks_memuse -= size; - if (ksp->ks_memuse + size >= ksp->ks_limit && - ksp->ks_memuse < ksp->ks_limit) - wakeup(ksp); + wake = ksp->ks_memuse + size >= ksp->ks_limit && + ksp->ks_memuse < ksp->ks_limit; ksp->ks_inuse--; #endif XSIMPLEQ_INSERT_TAIL(&kbp->kb_freelist, freep, kf_flist); mtx_leave(&malloc_mtx); +#ifdef KMEMSTATS + if (wake) + wakeup(ksp); +#endif } /* |