Index: sys/vm/vm_fault.c =================================================================== --- sys/vm/vm_fault.c (revision 228712) +++ sys/vm/vm_fault.c (working copy) @@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -104,6 +105,18 @@ __FBSDID("$FreeBSD$"); #define PFFOR 4 #define PAGEORDER_SIZE (PFBAK+PFFOR) +#define KTR_LOG_FAULTSTATE(fs) do { \ + CTR4(KTR_LVL, \ + "fs: %p, fs.m: %p, fs.object: %p, fs.pindex: %ju", \ + &(fs), (fs).m, (fs).object, (fs).pindex); \ + CTR3(KTR_LVL, \ + "fs.first_m: %p, fs.first_object: %p, fs.first_pindex: %ju",\ + (fs).first_m, (fs).first_object, (fs).first_pindex); \ + CTR4(KTR_LVL, \ + "fs.map: %p, fs.entry: %p, fs.valid: %d, fs.vp: %p", \ + (fs).map, (fs).entry, (fs).lookup_still_valid, (fs).vp); \ +} while (0) + static int prefault_pageorder[] = { -1 * PAGE_SIZE, 1 * PAGE_SIZE, -2 * PAGE_SIZE, 2 * PAGE_SIZE, @@ -238,6 +251,7 @@ vm_fault_hold(vm_map_t map, vm_offset_t vaddr, vm_ faultcount = behind = 0; RetryFault:; + KTR_LOG_FAULTSTATE(fs); /* * Find the backing store object and offset into it to begin the @@ -250,11 +264,15 @@ RetryFault:; if (growstack && result == KERN_INVALID_ADDRESS && map != kernel_map) { result = vm_map_growstack(curproc, vaddr); - if (result != KERN_SUCCESS) + if (result != KERN_SUCCESS) { + KTR_LOG_FAULTSTATE(fs); return (KERN_FAILURE); + } + KTR_LOG_FAULTSTATE(fs); growstack = FALSE; goto RetryFault; } + KTR_LOG_FAULTSTATE(fs); return (result); } @@ -292,10 +310,12 @@ RetryFault:; fs.object = fs.first_object; fs.pindex = fs.first_pindex; while (TRUE) { + KTR_LOG_FAULTSTATE(fs); /* * If the object is dead, we stop here */ if (fs.object->flags & OBJ_DEAD) { + KTR_LOG_FAULTSTATE(fs); unlock_and_deallocate(&fs); return (KERN_PROTECTION_FAILURE); } @@ -305,6 +325,7 @@ RetryFault:; */ fs.m = vm_page_lookup(fs.object, fs.pindex); if (fs.m != NULL) { + KTR_LOG_FAULTSTATE(fs); /* * check for page-based copy on write. * We check fs.object == fs.first_object so @@ -318,6 +339,7 @@ RetryFault:; if ((fs.m->cow) && (fault_type & VM_PROT_WRITE) && (fs.object == fs.first_object)) { + KTR_LOG_FAULTSTATE(fs); vm_page_cowfault(fs.m); unlock_and_deallocate(&fs); goto RetryFault; @@ -340,6 +362,7 @@ RetryFault:; * to pmap it. */ if ((fs.m->oflags & VPO_BUSY) || fs.m->busy) { + KTR_LOG_FAULTSTATE(fs); /* * Reference the page before unlocking and * sleeping so that the page daemon is less @@ -350,6 +373,7 @@ RetryFault:; if (fs.object != fs.first_object) { if (!VM_OBJECT_TRYLOCK( fs.first_object)) { + KTR_LOG_FAULTSTATE(fs); VM_OBJECT_UNLOCK(fs.object); VM_OBJECT_LOCK(fs.first_object); VM_OBJECT_LOCK(fs.object); @@ -364,6 +388,7 @@ RetryFault:; unlock_map(&fs); if (fs.m == vm_page_lookup(fs.object, fs.pindex)) { + KTR_LOG_FAULTSTATE(fs); vm_page_sleep_if_busy(fs.m, TRUE, "vmpfw"); } @@ -371,6 +396,7 @@ RetryFault:; VM_OBJECT_UNLOCK(fs.object); PCPU_INC(cnt.v_intrans); vm_object_deallocate(fs.first_object); + KTR_LOG_FAULTSTATE(fs); goto RetryFault; } vm_pageq_remove(fs.m); @@ -383,8 +409,11 @@ RetryFault:; * found the page ). */ vm_page_busy(fs.m); - if (fs.m->valid != VM_PAGE_BITS_ALL) + if (fs.m->valid != VM_PAGE_BITS_ALL) { + KTR_LOG_FAULTSTATE(fs); goto readrest; + } + KTR_LOG_FAULTSTATE(fs); break; } Index: sys/amd64/conf/GENERIC =================================================================== --- sys/amd64/conf/GENERIC (revision 228712) +++ sys/amd64/conf/GENERIC (working copy) @@ -67,6 +67,11 @@ options INCLUDE_CONFIG_FILE # Include this fi options KDB # Kernel debugger related code options KDB_TRACE # Print a stack trace for a panic +options KTR +options KTR_COMPILE=KTR_LVL +options KTR_MASK=KTR_LVL +options KTR_ENTRIES=65536 + # Make an SMP-capable kernel by default options SMP # Symmetric MultiProcessor Kernel Index: sys/sys/ktr.h =================================================================== --- sys/sys/ktr.h (revision 228712) +++ sys/sys/ktr.h (working copy) @@ -75,7 +75,8 @@ #define KTR_INET6 0x10000000 /* IPv6 stack */ #define KTR_SCHED 0x20000000 /* Machine parsed sched info. */ #define KTR_BUF 0x40000000 /* Buffer cache */ -#define KTR_ALL 0x7fffffff +#define KTR_LVL 0x80000000 /* Livelock */ +#define KTR_ALL 0xffffffff /* Trace classes to compile in */ #ifdef KTR