Date: Tue, 18 Aug 2020 15:24:52 +0200 From: Mateusz Guzik <mjguzik@gmail.com> To: current@freebsd.org, Mateusz Guzik <mjguzik@gmail.com> Subject: Re: "panic: malloc(M_WAITOK) in non-sleepable context" after r364296 -> r364341 Message-ID: <CAGudoHHJLoQhU%2Bb4%2Btt_dmChYj=qXA%2BiVaC5mFW8sFxoqq54pw@mail.gmail.com> In-Reply-To: <20200818125825.GP1394@albert.catwhisker.org> References: <20200818124419.GO1394@albert.catwhisker.org> <CAGudoHEEnZVaBwY1L-wjmDcrsHyP4pE3-0qyurh-kWsCO9Edhg@mail.gmail.com> <20200818125825.GP1394@albert.catwhisker.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Try this: 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 @@ -618,8 +618,8 @@ 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 @@ -3355,8 +3355,8 @@ 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/18/20, David Wolfskill <david@catwhisker.org> wrote: > On Tue, Aug 18, 2020 at 02:48:47PM +0200, Mateusz Guzik wrote: >> see https://reviews.freebsd.org/D26027 >> .... > > Right; I was just reviewing the list of updated files and noted > src/sys/kern/kern_malloc.c, and its svn log showed: > > ------------------------------------------------------------------------ > r364310 | glebius | 2020-08-17 08:37:08 -0700 (Mon, 17 Aug 2020) | 8 > lines > > With INVARIANTS panic immediately if M_WAITOK is requested in a > non-sleepable context. Previously only _sleep() would panic. > This will catch misuse of M_WAITOK at development stage rather > than at stress load stage. > > Reviewed by: markj > Differential Revision: https://reviews.freebsd.org/D26027 > > ------------------------------------------------------------------------ > > And if we were still going in to the office, I'd discuss it with Gleb. :-) > > But in the mean time: I'm not a committer; I didn't cause the error. > Seems I can't try running head now with a GENERIC kernel. > > Peace, > david > -- > David H. Wolfskill david@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. > -- Mateusz Guzik <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGudoHHJLoQhU%2Bb4%2Btt_dmChYj=qXA%2BiVaC5mFW8sFxoqq54pw>