From owner-freebsd-current@freebsd.org Tue Aug 18 13:24:56 2020 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 13AE93BBEB9 for ; Tue, 18 Aug 2020 13:24:56 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4BWBTz5Jg9z43T9 for ; Tue, 18 Aug 2020 13:24:55 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mailman.nyi.freebsd.org (Postfix) id B62C23BBB6B; Tue, 18 Aug 2020 13:24:55 +0000 (UTC) Delivered-To: current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B5F683BBB6A for ; Tue, 18 Aug 2020 13:24:55 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BWBTz1NZvz43Bt for ; Tue, 18 Aug 2020 13:24:55 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wr1-x443.google.com with SMTP id p20so18287224wrf.0 for ; Tue, 18 Aug 2020 06:24:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=j+g2yLiDZzLtm3YyuS9aN0Tew9axnqKmg3j6ZnMnecY=; b=SqiGfoSXSt8qeDatxpZnwwAcCl4vTBFOciIBx6nKTSzo5JaBxK69zWKwn6ADeDN+P+ yqdPMWzte/x9LJW0SPocazRdFdDZCRYa1FxPucsYhie7Tn88od0fPN57uRl5RFRHdPeK zyWa1gCi8ouKt8E2ViHExt1ne86UGM5YLnlB7lxxF1ckfO2/6paV5ZKKiQZBpGOd3QUX Jua1PetJrzBmUQCvpFEQJjPPYxub4yqH7Qde12wPJ2saclPPkMKWYakBUjRVuqTpdLxR i9aTSevDddFDSsVhcaMJ24VUFlAMm6Z+BPoYfXNwA01pA4kS+9p/YVw90O0/h5JKO6Gs 8BTQ== X-Gm-Message-State: AOAM530hz7JO6rxJOswssj6qEV4dZ0f+nhQxQEm0/zqeaQJLpiVXNrzh jxDal7iHXPYSln78b1z+EZ8T1Dv8IkTckup60T1jfSF2 X-Google-Smtp-Source: ABdhPJxEptuEK+L/qx5vvve13rrEm6VZp7Xgub5v19NQl+Y9JnQZAIKv7a1ifIWUY6xCUpug59yt5Y7HqYNm/GPY3MY= X-Received: by 2002:adf:e94c:: with SMTP id m12mr20304458wrn.109.1597757093672; Tue, 18 Aug 2020 06:24:53 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a5d:614c:0:0:0:0:0 with HTTP; Tue, 18 Aug 2020 06:24:52 -0700 (PDT) In-Reply-To: <20200818125825.GP1394@albert.catwhisker.org> References: <20200818124419.GO1394@albert.catwhisker.org> <20200818125825.GP1394@albert.catwhisker.org> From: Mateusz Guzik Date: Tue, 18 Aug 2020 15:24:52 +0200 Message-ID: Subject: Re: "panic: malloc(M_WAITOK) in non-sleepable context" after r364296 -> r364341 To: current@freebsd.org, Mateusz Guzik Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4BWBTz1NZvz43Bt X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Aug 2020 13:24:56 -0000 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 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