From: Venkatesh Srinivas Date: Thu, 21 Apr 2011 20:46:39 +0000 (-0700) Subject: kernel -- Slight changes to refcount_wait/_wakeup. X-Git-Tag: v2.12.0~774 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/ed2fb120da2038d13bb9f0aebfba177ee57b1e4d?ds=sidebyside kernel -- Slight changes to refcount_wait/_wakeup. * Pass waitstring into refcount_wait. * Record long waits in kernel log. --- diff --git a/sys/kern/kern_refcount.c b/sys/kern/kern_refcount.c index a34c8eced4..86ba884c45 100644 --- a/sys/kern/kern_refcount.c +++ b/sys/kern/kern_refcount.c @@ -62,18 +62,25 @@ * up waiters. */ void -_refcount_wait(volatile u_int *countp) +_refcount_wait(volatile u_int *countp, const char *wstr) { u_int n; + int loops = 0; + int threshold = 5; for (;;) { n = *countp; if (n == 0) break; + if (loops > threshold) { + kprintf("refcount_wait %s long wait\n", wstr); + loops = 0; + } KKASSERT(n != REFCNTF_WAITING); /* impossible state */ tsleep_interlock(countp, 0); if (atomic_cmpset_int(countp, n, n | REFCNTF_WAITING)) - tsleep(countp, PINTERLOCKED, "refwait", 0); + tsleep(countp, PINTERLOCKED, wstr, hz*10); + loops++; } } diff --git a/sys/sys/refcount.h b/sys/sys/refcount.h index 6065327695..c12ab67aad 100644 --- a/sys/sys/refcount.h +++ b/sys/sys/refcount.h @@ -37,7 +37,7 @@ #define REFCNTF_WAITING 0x40000000 -void _refcount_wait(volatile u_int *countp); +void _refcount_wait(volatile u_int *countp, const char *wstr); int _refcount_release_wakeup(volatile u_int *countp); static __inline void @@ -83,10 +83,10 @@ refcount_release_wakeup(volatile u_int *countp) * use refcount_release_wakeup() instead of refcount_release(). */ static __inline void -refcount_wait(volatile u_int *countp) +refcount_wait(volatile u_int *countp, const char *wstr) { if (*countp) - _refcount_wait(countp); + _refcount_wait(countp, wstr); } #endif /* ! __SYS_REFCOUNT_H__ */