"panic: malloc(M_WAITOK) in non-sleepable context" after r364296 -> r364341

David Wolfskill david at catwhisker.org
Tue Aug 18 15:08:48 UTC 2020


On Tue, Aug 18, 2020 at 03:37:50PM +0200, Mateusz Guzik wrote:
> So the previous patch should just print a warning.
> 
> Does this take care of the problem in general? I don't have means to
> test the patch.
> ....

Sorry for the delay, but finished patching & rebuilding, and
(essentially), yes.  (The difference is that I replaced all 3 of the
KASSERT()s from r364310 with the WITNESS_WARN() constructs, rather
than only 2.)

FreeBSD freebeast.catwhisker.org 13.0-CURRENT FreeBSD 13.0-CURRENT #1004 r364296M/364296: Mon Aug 17 06:04:40 PDT 2020     root at freebeast.catwhisker.org:/common/S4/obj/usr/src/amd64.amd64/sys/GENERIC  amd64 1300109 1300109

FreeBSD freebeast.catwhisker.org 13.0-CURRENT FreeBSD 13.0-CURRENT #1006 r364341M/364341: Tue Aug 18 06:59:10 PDT 2020     root at freebeast.catwhisker.org:/common/S4/obj/usr/src/amd64.amd64/sys/GENERIC  amd64 1300110 1300110

Peace,
david
-- 
David H. Wolfskill				david at catwhisker.org
Donald Trump is either ignorant of how to govern or is refusing to do so.

See http://www.catwhisker.org/~david/publickey.gpg for my public key.
-------------- next part --------------
Index: sys/kern/kern_malloc.c
===================================================================
--- sys/kern/kern_malloc.c	(revision 364341)
+++ sys/kern/kern_malloc.c	(working copy)
@@ -618,8 +618,8 @@
 	unsigned long osize = size;
 #endif
 
-	KASSERT((flags & M_WAITOK) == 0 || THREAD_CAN_SLEEP(),
-	    ("malloc(M_WAITOK) in non-sleepable context"));
+	if ((flags & M_WAITOK) != 0)
+		WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
 
 #ifdef MALLOC_DEBUG
 	va = NULL;
Index: sys/vm/uma_core.c
===================================================================
--- sys/vm/uma_core.c	(revision 364341)
+++ sys/vm/uma_core.c	(working copy)
@@ -3328,8 +3328,8 @@
 	uma_cache_bucket_t bucket;
 	uma_cache_t cache;
 
-	KASSERT((flags & M_WAITOK) == 0 || THREAD_CAN_SLEEP(),
-	    ("uma_zalloc_smr(M_WAITOK) in non-sleepable context"));
+	if ((flags & M_WAITOK) != 0)
+		WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
 
 #ifdef UMA_ZALLOC_DEBUG
 	void *item;
@@ -3355,8 +3355,8 @@
 	uma_cache_bucket_t bucket;
 	uma_cache_t cache;
 
-	KASSERT((flags & M_WAITOK) == 0 || THREAD_CAN_SLEEP(),
-	    ("uma_zalloc(M_WAITOK) in non-sleepable context"));
+	if ((flags & M_WAITOK) != 0)
+		WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
 
 	/* Enable entropy collection for RANDOM_ENABLE_UMA kernel option */
 	random_harvest_fast_uma(&zone, sizeof(zone), RANDOM_UMA);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 618 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20200818/8b40742d/attachment.sig>


More information about the freebsd-current mailing list