From feea37dcd9407178e44a9e96baf1a31dada1978d Mon Sep 17 00:00:00 2001 From: Venkatesh Srinivas Date: Mon, 28 Mar 2011 17:02:43 -0700 Subject: [PATCH] kernel -- vm_object hold debugging should not panic if the debug array overflows If the debug array overflows, we lose the ability to test for object drops when we never established a hold. However the system keeps running. Suggested-by: dillon --- sys/vm/vm_object.c | 8 +++++--- sys/vm/vm_object.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index e227ccdb04..7066157620 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1823,6 +1823,7 @@ vm_object_lock_init(vm_object_t obj) int i; obj->debug_hold_bitmap = 0; + obj->debug_hold_ovfl = 0; for (i = 0; i < VMOBJ_DEBUG_ARRAY_SIZE; i++) { obj->debug_hold_thrs[i] = NULL; } @@ -1853,7 +1854,8 @@ vm_object_hold(vm_object_t obj) i = ffs(~obj->debug_hold_bitmap) - 1; if (i == -1) { - panic("vm_object hold count > VMOBJ_DEBUG_ARRAY_SIZE"); + kprintf("vm_object hold count > VMOBJ_DEBUG_ARRAY_SIZE"); + obj->debug_hold_ovfl = 1; } obj->debug_hold_bitmap |= (1 << i); @@ -1880,7 +1882,7 @@ vm_object_drop(vm_object_t obj) } } - if (found == 0) + if (found == 0 && obj->debug_hold_ovfl == 0) panic("vm_object: attempt to drop hold on non-self-held obj"); #endif @@ -1907,7 +1909,7 @@ 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)) + (obj->debug_hold_thrs[i] == curthread)) panic("vm_object: self-hold in terminate or collapse"); } #endif diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 68769f2326..a0c1650f92 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -155,7 +155,7 @@ struct vm_object { #define VMOBJ_DEBUG_ARRAY_SIZE (32) u_int debug_hold_bitmap; thread_t debug_hold_thrs[VMOBJ_DEBUG_ARRAY_SIZE]; - + u_int debug_hold_ovfl; #endif union { -- 2.41.0