Re: "panic: malloc(M_WAITOK) in non-sleepable context" when inserting usb stick

From: Mateusz Guzik <mjguzik_at_gmail.com>
Date: Tue, 18 Aug 2020 15:31:41 +0200
Hello,

this sould take care of it (in that it will print the warning, but not
panic the box):

diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index 46eb1c4347c..7b94ca7b880 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
_at__at_ -618,8 +618,8 _at__at_ void *
        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;
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index 37d78354200..2e1267ec02f 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
_at__at_ -3355,8 +3355,8 _at__at_ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags)
        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);

On 8/17/20, moridin_at_mm.st <moridin_at_mm.st> wrote:
> r364323, previously I think it was just a warning from witness.  Happens
> both on boot with stick already inserted, and when inserting the stick in
> booted system.
>
> Looks like my swap partition is no longer big enough for dump, translating
> from screen:
>
> umass0 numa-domain 0 on uhub4
> umass0:2:0: Attached to scbus2
> panic: malloc(M_WAITOK) in non-sleepable context
>
> vpanic()
> panic()
> malloc()
> disk_alloc()
> daregister()
> cam_periph_alloc()
> daasync()
> xpt_async_process_dev()
> xpt_async_process()
> xpt_done_process()
> xpt_done_td()
> fork_exit()
> fork_trampoline()
> _______________________________________________
> freebsd-current_at_freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"
>


-- 
Mateusz Guzik <mjguzik gmail.com>
Received on Tue Aug 18 2020 - 11:31:46 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:24 UTC