kernel -- Slight changes to refcount_wait/_wakeup.
authorVenkatesh Srinivas <me@endeavour.zapto.org>
Thu, 21 Apr 2011 20:46:39 +0000 (13:46 -0700)
committerVenkatesh Srinivas <me@endeavour.zapto.org>
Thu, 21 Apr 2011 20:46:39 +0000 (13:46 -0700)
* Pass waitstring into refcount_wait.

* Record long waits in kernel log.

sys/kern/kern_refcount.c
sys/sys/refcount.h

index a34c8ec..86ba884 100644 (file)
  * 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++;
        }
 }
 
index 6065327..c12ab67 100644 (file)
@@ -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__ */