--- //depot/projects/smpng/sys/amd64/amd64/trap.c 2006/01/06 20:21:45 +++ //depot/user/jhb/lock/amd64/amd64/trap.c 2006/01/06 21:17:48 @@ -237,8 +237,16 @@ * do the VM lookup, so just consider it a fatal trap so the * kernel can print out a useful trap message and even get * to the debugger. + * + * If we get a page fault while holding a non-sleepable + * lock, then it is most likely a fatal kernel page fault. + * If WITNESS is enabled, then it's going to whine about + * bogus LORs with various VM locks, so just skip to the + * fatal trap handling directly. */ - if (td->td_critnest != 0) + if (td->td_critnest != 0 || + WITNESS_CHECK(WARN_SLEEPOK | WARN_GIANTOK, NULL, + "Kernel page fault") != 0) trap_fatal(&frame, frame.tf_addr); } --- //depot/projects/smpng/sys/i386/i386/trap.c 2006/01/06 20:21:45 +++ //depot/user/jhb/lock/i386/i386/trap.c 2006/01/06 21:17:48 @@ -265,12 +265,20 @@ * do the VM lookup, so just consider it a fatal trap so the * kernel can print out a useful trap message and even get * to the debugger. + * + * If we get a page fault while holding a non-sleepable + * lock, then it is most likely a fatal kernel page fault. + * If WITNESS is enabled, then it's going to whine about + * bogus LORs with various VM locks, so just skip to the + * fatal trap handling directly. */ eva = rcr2(); - if (td->td_critnest == 0) + if (td->td_critnest != 0 || + WITNESS_CHECK(WARN_SLEEPOK | WARN_GIANTOK, NULL, + "Kernel page fault") != 0) + trap_fatal(&frame, eva); + else enable_intr(); - else - trap_fatal(&frame, eva); } if ((ISPL(frame.tf_cs) == SEL_UPL) || --- //depot/projects/smpng/sys/sys/lock.h 2006/01/17 17:16:05 +++ //depot/user/jhb/lock/sys/lock.h 2006/01/24 22:27:09 @@ -268,6 +269,9 @@ #define WITNESS_UNLOCK(lock, flags, file, line) \ witness_unlock((lock), (flags), (file), (line)) +#define WITNESS_CHECK(flags, lock, fmt, ...) \ + witness_warn((flags), (lock), (fmt), ## __VA_ARGS__) + #define WITNESS_WARN(flags, lock, fmt, ...) \ witness_warn((flags), (lock), (fmt), ## __VA_ARGS__) @@ -296,6 +300,7 @@ #define WITNESS_UPGRADE(lock, flags, file, line) #define WITNESS_DOWNGRADE(lock, flags, file, line) #define WITNESS_UNLOCK(lock, flags, file, line) +#define WITNESS_CHECK(flags, lock, fmt, ...) 0 #define WITNESS_WARN(flags, lock, fmt, ...) #define WITNESS_SAVE_DECL(n) #define WITNESS_SAVE(lock, n) --- //depot/projects/smpng/sys/vm/uma_core.c 2006/01/06 20:21:45 +++ //depot/user/jhb/lock/vm/uma_core.c 2006/01/06 21:17:48 @@ -1789,7 +1789,7 @@ ("malloc(M_WAITOK) in interrupt context")); if (nosleepwithlocks) { #ifdef WITNESS - badness = WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, + badness = WITNESS_CHECK(WARN_GIANTOK | WARN_SLEEPOK, NULL, "malloc(M_WAITOK) of \"%s\", forcing M_NOWAIT", zone->uz_name);