Index: subr_lockdebug.c
===================================================================
RCS file: /cvsroot/src/sys/kern/subr_lockdebug.c,v
retrieving revision 1.57.2.1
diff -u -u -r1.57.2.1 subr_lockdebug.c
--- subr_lockdebug.c	2 Apr 2018 09:07:52 -0000	1.57.2.1
+++ subr_lockdebug.c	12 Apr 2018 21:05:38 -0000
@@ -53,6 +53,8 @@
 #include <sys/rbtree.h>
 #include <sys/ksyms.h>
 
+#include <uvm/uvm.h>
+
 #include <machine/lock.h>
 
 unsigned int		ld_panic;
@@ -369,8 +371,11 @@
 	/*
 	 * Can't call kmem_alloc() if in interrupt context.  XXX We could
 	 * deadlock, because we don't know which locks the caller holds.
+	 * We also don't want to allocate more memory when called from
+	 * the pagedaemon, because we don't want to sleep.
 	 */
-	if (cpu_intr_p() || (curlwp->l_pflag & LP_INTR) != 0) {
+	if (cpu_intr_p() || (curlwp->l_pflag & LP_INTR) != 0
+	   || curlwp == uvm.pagedaemon_lwp) {
 		return s;
 	}