From 18a4c8dc91f351f9aa317c2d69113563e9509cce Mon Sep 17 00:00:00 2001 From: Venkatesh Srinivas Date: Tue, 14 Jun 2011 07:09:43 -0700 Subject: [PATCH] kernel -- vm_object DEBUG_LOCKS: Record file/line of vm_object holds. --- sys/vm/vm_object.c | 12 ++++++++++++ sys/vm/vm_object.h | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 19dfef9111..b658995450 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -157,6 +157,8 @@ vm_object_lock_init(vm_object_t obj) obj->debug_hold_ovfl = 0; for (i = 0; i < VMOBJ_DEBUG_ARRAY_SIZE; i++) { obj->debug_hold_thrs[i] = NULL; + obj->debug_hold_file[i] = NULL; + obj->debug_hold_line[i] = 0; } #endif } @@ -186,7 +188,11 @@ vm_object_assert_held(vm_object_t obj) } void +#ifndef DEBUG_LOCKS vm_object_hold(vm_object_t obj) +#else +debugvm_object_hold(vm_object_t obj, char *file, int line) +#endif { if (obj == NULL) return; @@ -211,6 +217,8 @@ vm_object_hold(vm_object_t obj) obj->debug_hold_bitmap |= (1 << i); obj->debug_hold_thrs[i] = curthread; + obj->debug_hold_file[i] = file; + obj->debug_hold_line[i] = line; #endif } @@ -229,6 +237,8 @@ vm_object_drop(vm_object_t obj) (obj->debug_hold_thrs[i] == curthread)) { obj->debug_hold_bitmap &= ~(1 << i); obj->debug_hold_thrs[i] = NULL; + obj->debug_hold_file[i] = NULL; + obj->debug_hold_line[i] = 0; found = 1; break; } @@ -263,6 +273,8 @@ vm_object_hold_wait(vm_object_t obj) for (i = 0; i < VMOBJ_DEBUG_ARRAY_SIZE; i++) { if ((obj->debug_hold_bitmap & (1 << i)) && (obj->debug_hold_thrs[i] == curthread)) { + kprintf("vm_object %p: self-hold in at %s:%d\n", obj, + obj->debug_hold_file[i], obj->debug_hold_line[i]); panic("vm_object: self-hold in terminate or collapse"); } } diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 9af6d8c9f3..145c52e7a5 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -155,6 +155,8 @@ struct vm_object { #define VMOBJ_DEBUG_ARRAY_SIZE (32) u_int debug_hold_bitmap; thread_t debug_hold_thrs[VMOBJ_DEBUG_ARRAY_SIZE]; + char *debug_hold_file[VMOBJ_DEBUG_ARRAY_SIZE]; + int debug_hold_line[VMOBJ_DEBUG_ARRAY_SIZE]; u_int debug_hold_ovfl; #endif @@ -304,7 +306,15 @@ void vm_object_dead_sleep(vm_object_t, const char *); void vm_object_dead_wakeup(vm_object_t); void vm_object_lock(vm_object_t); void vm_object_unlock(vm_object_t); + +#ifndef DEBUG_LOCKS void vm_object_hold(vm_object_t); +#else +#define vm_object_hold(obj) \ + debugvm_object_hold(obj, __FILE__, __LINE__) +void debugvm_object_hold(vm_object_t, char *, int); +#endif + void vm_object_drop(vm_object_t); #endif /* _KERNEL */ -- 2.41.0